Some applications use the EDID property of the monitor device to detect supported resolutions, and set the viewport size. Add a computed EDID to the virtual desktop monitor device to allow the virtual desktop driver to be better compatible with such applications.
Most fields of the EDID contain details that are of no relevance to applications, so populate only the native resolution and physical monitor dimensions. This should cover the vast majority of use cases.
Signed-off-by: Eduard Permyakov epermyakov@codeweavers.com --- dlls/winex11.drv/desktop.c | 40 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c index 71b3a0a5a27..0abd0ddf58b 100644 --- a/dlls/winex11.drv/desktop.c +++ b/dlls/winex11.drv/desktop.c @@ -20,6 +20,8 @@ */
#include "config.h" +#include <stdlib.h> +#include <stdint.h> #include <X11/cursorfont.h> #include <X11/Xlib.h>
@@ -111,6 +113,38 @@ static void add_desktop_mode( DEVMODEW *mode, DWORD depth, DWORD width, DWORD he mode->dmDisplayFrequency = 60; }
+static void get_virtual_edid( unsigned char **edid, unsigned long *len ) +{ + static const size_t desc_size = 128; + unsigned int width_mm, height_mm; + unsigned char *ret; + + *edid = NULL; + *len = 0; + + ret = calloc( desc_size, 1 ); + if (!ret) + return; + + /* Set the native resolution in the Preferred Timing Mode descriptor */ + ret[0x38] = max_width & 0xff; + ret[0x3A] = ((max_width >> 8) & 0xf) << 4; + + ret[0x3B] = max_height & 0xff; + ret[0x3D] = ((max_height >> 8) & 0xf) << 4; + + /* Set the monitor size (mm) in the Preferred Timing Mode descriptor */ + height_mm = 200; + width_mm = height_mm / ((float)max_height) * max_width; + + ret[0x42] = width_mm & 0xff; + ret[0x43] = height_mm & 0xff; + ret[0x44] = (((width_mm >> 8) & 0xf) << 4) | ((height_mm >> 8) & 0xf); + + *edid = ret; + *len = desc_size; +} + static BOOL X11DRV_desktop_get_modes( ULONG_PTR id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count ) { UINT depth_idx, size_idx, mode_idx = 0; @@ -265,8 +299,7 @@ static BOOL X11DRV_desktop_get_monitors( ULONG_PTR adapter_id, struct x11drv_mon SetRect( &monitor->rc_work, 0, 0, desktop_width, desktop_height ); query_desktop_work_area( &monitor->rc_work ); monitor->state_flags = DISPLAY_DEVICE_ATTACHED; - monitor->edid_len = 0; - monitor->edid = NULL; + get_virtual_edid( &monitor->edid, &monitor->edid_len ); if (desktop_width && desktop_height) monitor->state_flags |= DISPLAY_DEVICE_ACTIVE;
@@ -277,6 +310,9 @@ static BOOL X11DRV_desktop_get_monitors( ULONG_PTR adapter_id, struct x11drv_mon
static void X11DRV_desktop_free_monitors( struct x11drv_monitor *monitors, int count ) { + int i; + for (i = 0; i < count; i++) + free( monitors[i].edid ); heap_free( monitors ); }