diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c index a3b2f0cbf20..2428293c4f9 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 d3ee653f217..7ad74c9b4e1 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 4a6de9053da..ef8a42d609d 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;