Zhiyi Zhang : winex11.drv: Get virtual desktop size limit from the host primary display.

Alexandre Julliard julliard at winehq.org
Tue Nov 5 16:11:45 CST 2019


Module: wine
Branch: master
Commit: acf03ed9da0f7d3f94de9b47c44366be3ee47f8e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=acf03ed9da0f7d3f94de9b47c44366be3ee47f8e

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Tue Nov  5 21:05:10 2019 +0800

winex11.drv: Get virtual desktop size limit from the host primary display.

After 25167fb286822c93582457815bcf069fef040976, get_primary_monitor_rect()
maybe invalid before display device initialization or returns the desktop
rectangle after desktop initialization in virtual desktop mode, which is
wrong. The desktop size limit should come from host system.

This fixes a regression from efbbe66669a060dd01b3ae399f5a9e7328312f03.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47815
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/desktop.c |  8 +++-----
 dlls/winex11.drv/display.c | 21 +++++++++++++++++++++
 dlls/winex11.drv/x11drv.h  |  1 +
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c
index a3b2f0cbf2..2428293c4f 100644
--- a/dlls/winex11.drv/desktop.c
+++ b/dlls/winex11.drv/desktop.c
@@ -238,12 +238,14 @@ static void X11DRV_desktop_free_monitors( struct x11drv_monitor *monitors )
  */
 void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height )
 {
-    RECT primary_rect;
+    RECT primary_rect = get_host_primary_monitor_rect();
 
     root_window = win;
     managed_mode = FALSE;  /* no managed windows in desktop mode */
     desktop_width = width;
     desktop_height = height;
+    max_width = primary_rect.right;
+    max_height = primary_rect.bottom;
 
     /* Initialize virtual desktop mode display device handler */
     desktop_handler.name = "Virtual Desktop";
@@ -257,10 +259,6 @@ void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height )
     TRACE("Display device functions are now handled by: Virtual Desktop\n");
     X11DRV_DisplayDevices_Init( TRUE );
 
-    primary_rect = get_primary_monitor_rect();
-    max_width = primary_rect.right - primary_rect.left;
-    max_height = primary_rect.bottom - primary_rect.top;
-
     /* initialize the available resolutions */
     dd_modes = X11DRV_Settings_SetHandlers("desktop", 
                                            X11DRV_desktop_GetCurrentMode, 
diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c
index d3ee653f21..7ad74c9b4e 100644
--- a/dlls/winex11.drv/display.c
+++ b/dlls/winex11.drv/display.c
@@ -233,6 +233,27 @@ RECT get_primary_monitor_rect(void)
     return primary;
 }
 
+/* Get the primary monitor rect from the host system */
+RECT get_host_primary_monitor_rect(void)
+{
+    INT gpu_count, adapter_count, monitor_count;
+    struct x11drv_gpu *gpus = NULL;
+    struct x11drv_adapter *adapters = NULL;
+    struct x11drv_monitor *monitors = NULL;
+    RECT rect = {0};
+
+    /* The first monitor is always primary */
+    if (host_handler.get_gpus(&gpus, &gpu_count) && gpu_count &&
+        host_handler.get_adapters(gpus[0].id, &adapters, &adapter_count) && adapter_count &&
+        host_handler.get_monitors(adapters[0].id, &monitors, &monitor_count) && monitor_count)
+        rect = monitors[0].rc_monitor;
+
+    if (gpus) host_handler.free_gpus(gpus);
+    if (adapters) host_handler.free_adapters(adapters);
+    if (monitors) host_handler.free_monitors(monitors);
+    return rect;
+}
+
 void X11DRV_DisplayDevices_SetHandler(const struct x11drv_display_device_handler *new_handler)
 {
     if (new_handler->priority > host_handler.priority)
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 4a6de9053d..ef8a42d609 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -643,6 +643,7 @@ extern POINT virtual_screen_to_root( INT x, INT y ) DECLSPEC_HIDDEN;
 extern POINT root_to_virtual_screen( INT x, INT y ) DECLSPEC_HIDDEN;
 extern RECT get_virtual_screen_rect(void) DECLSPEC_HIDDEN;
 extern RECT get_primary_monitor_rect(void) DECLSPEC_HIDDEN;
+extern RECT get_host_primary_monitor_rect(void) DECLSPEC_HIDDEN;
 extern void query_work_area( RECT *rc_work ) DECLSPEC_HIDDEN;
 extern void xinerama_init( unsigned int width, unsigned int height ) DECLSPEC_HIDDEN;
 




More information about the wine-cvs mailing list