On 9/3/21 4:34 PM, Eduard Permyakov wrote:
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 | 41 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c index 71b3a0a5a27..3c39035b4db 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) +{
- const size_t desc_size = 128;
static const
- unsigned width_mm, height_mm;
unsigned int
- 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] = desktop_width & 0xff;
- ret[0x3A] = ((desktop_width >> 8) & 0xf) << 4;
desktop_width and desktop_height could change. I assume you want max_width and max_height.
- ret[0x3B] = desktop_height & 0xff;
- ret[0x3D] = ((desktop_height >> 8) & 0xf) << 4;
- /* Set the monitor size (mm) in the Preferred Timing Mode descriptor */
- height_mm = 2000;
2000mm doesn't seem to be a common monitor height.
- width_mm = height_mm / ((float)desktop_height) * desktop_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,10 @@ 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 );
}