[PATCH 2/7] winex11.drv: Introduce is_virtual_desktop().

Zhiyi Zhang zzhang at codeweavers.com
Thu Oct 3 02:54:14 CDT 2019


Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 dlls/winex11.drv/desktop.c  | 8 +++++++-
 dlls/winex11.drv/event.c    | 2 +-
 dlls/winex11.drv/mouse.c    | 2 +-
 dlls/winex11.drv/palette.c  | 2 +-
 dlls/winex11.drv/systray.c  | 2 +-
 dlls/winex11.drv/window.c   | 4 ++--
 dlls/winex11.drv/x11drv.h   | 1 +
 dlls/winex11.drv/xinerama.c | 4 ++--
 dlls/winex11.drv/xrandr.c   | 2 +-
 dlls/winex11.drv/xvidmode.c | 2 +-
 10 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c
index fed8dd32e9..e4eb61f7bd 100644
--- a/dlls/winex11.drv/desktop.c
+++ b/dlls/winex11.drv/desktop.c
@@ -77,6 +77,12 @@ static struct screen_size {
 #define _NET_WM_STATE_REMOVE 0
 #define _NET_WM_STATE_ADD 1
 
+/* Return TRUE if Wine is currently in virtual desktop mode */
+BOOL is_virtual_desktop(void)
+{
+    return root_window != DefaultRootWindow( gdi_display );
+}
+
 /* create the mode structures */
 static void make_modes(void)
 {
@@ -268,7 +274,7 @@ static void update_desktop_fullscreen( unsigned int width, unsigned int height)
     Display *display = thread_display();
     XEvent xev;
 
-    if (!display || root_window == DefaultRootWindow( display )) return;
+    if (!display || !is_virtual_desktop()) return;
 
     xev.xclient.type = ClientMessage;
     xev.xclient.window = root_window;
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index 25730192d3..dd8837c11d 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -827,7 +827,7 @@ static void focus_out( Display *display , HWND hwnd )
     x11drv_thread_data()->last_focus = hwnd;
     if ((xic = X11DRV_get_ic( hwnd ))) XUnsetICFocus( xic );
 
-    if (root_window != DefaultRootWindow(display))
+    if (is_virtual_desktop())
     {
         if (hwnd == GetDesktopWindow()) reset_clipping_window();
         return;
diff --git a/dlls/winex11.drv/mouse.c b/dlls/winex11.drv/mouse.c
index 15e5c04a41..290732fa93 100644
--- a/dlls/winex11.drv/mouse.c
+++ b/dlls/winex11.drv/mouse.c
@@ -572,7 +572,7 @@ BOOL clip_fullscreen_window( HWND hwnd, BOOL reset )
     {
         RECT virtual_rect = get_virtual_screen_rect();
         if (!EqualRect( &rect, &virtual_rect )) return FALSE;
-        if (root_window != DefaultRootWindow( gdi_display )) return FALSE;
+        if (is_virtual_desktop()) return FALSE;
     }
     TRACE( "win %p clipping fullscreen\n", hwnd );
     return grab_clipping_window( &rect );
diff --git a/dlls/winex11.drv/palette.c b/dlls/winex11.drv/palette.c
index bba2253264..9974ce7ecc 100644
--- a/dlls/winex11.drv/palette.c
+++ b/dlls/winex11.drv/palette.c
@@ -217,7 +217,7 @@ int X11DRV_PALETTE_Init(void)
 	    {
 	        X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_PRIVATE;
 
-	        if( root_window != DefaultRootWindow(gdi_display) )
+	        if (is_virtual_desktop())
 	        {
 		    win_attr.colormap = default_colormap;
 		    XChangeWindowAttributes( gdi_display, root_window, CWColormap, &win_attr );
diff --git a/dlls/winex11.drv/systray.c b/dlls/winex11.drv/systray.c
index d4262c43cf..3be4bd6534 100644
--- a/dlls/winex11.drv/systray.c
+++ b/dlls/winex11.drv/systray.c
@@ -587,7 +587,7 @@ static BOOL init_systray(void)
     WNDCLASSEXW class;
     Display *display;
 
-    if (root_window != DefaultRootWindow( gdi_display )) return FALSE;
+    if (is_virtual_desktop()) return FALSE;
     if (init_done) return TRUE;
 
     icon_cx = GetSystemMetrics( SM_CXSMICON ) + 2 * ICON_BORDER;
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 4e01eb201c..f0d6fe64ad 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -2473,7 +2473,7 @@ static BOOL hide_icon( struct x11drv_win_data *data )
 
     if (data->managed) return TRUE;
     /* hide icons in desktop mode when the taskbar is active */
-    if (root_window == DefaultRootWindow( gdi_display )) return FALSE;
+    if (!is_virtual_desktop()) return FALSE;
     return IsWindowVisible( FindWindowW( trayW, NULL ));
 }
 
@@ -2780,7 +2780,7 @@ static BOOL is_netwm_supported( Display *display, Atom atom )
  */
 static LRESULT start_screensaver(void)
 {
-    if (root_window == DefaultRootWindow(gdi_display))
+    if (!is_virtual_desktop())
     {
         const char *argv[3] = { "xdg-screensaver", "activate", NULL };
         int pid = _spawnvp( _P_DETACH, argv[0], argv );
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 135faa8989..cd2450e4b1 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -652,6 +652,7 @@ struct x11drv_mode_info
     unsigned int refresh_rate;
 };
 
+extern BOOL is_virtual_desktop(void) DECLSPEC_HIDDEN;
 extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ) DECLSPEC_HIDDEN;
 extern void X11DRV_resize_desktop(unsigned int width, unsigned int height) DECLSPEC_HIDDEN;
 extern BOOL is_desktop_fullscreen(void) DECLSPEC_HIDDEN;
diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c
index 61c422e835..ed5ec22315 100644
--- a/dlls/winex11.drv/xinerama.c
+++ b/dlls/winex11.drv/xinerama.c
@@ -310,10 +310,10 @@ void xinerama_init( unsigned int width, unsigned int height )
 
     SetRect( &rect, 0, 0, width, height );
 
-    if (root_window != DefaultRootWindow( gdi_display ) || !query_screens())
+    if (is_virtual_desktop() || !query_screens())
     {
         default_monitor.rcWork = default_monitor.rcMonitor = rect;
-        if (root_window == DefaultRootWindow( gdi_display ))
+        if (!is_virtual_desktop())
             query_work_area( &default_monitor.rcWork );
         else
             query_desktop_work_area( &default_monitor.rcWork );
diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c
index 6bb2b18ce7..06cf371353 100644
--- a/dlls/winex11.drv/xrandr.c
+++ b/dlls/winex11.drv/xrandr.c
@@ -1078,7 +1078,7 @@ void X11DRV_XRandR_Init(void)
 
     if (major) return; /* already initialized? */
     if (!usexrandr) return; /* disabled in config */
-    if (root_window != DefaultRootWindow( gdi_display )) return;
+    if (is_virtual_desktop()) return;
     if (!(ret = load_xrandr())) return;  /* can't load the Xrandr library */
 
     /* see if Xrandr is available */
diff --git a/dlls/winex11.drv/xvidmode.c b/dlls/winex11.drv/xvidmode.c
index 9c0c97f1eb..7d8835a052 100644
--- a/dlls/winex11.drv/xvidmode.c
+++ b/dlls/winex11.drv/xvidmode.c
@@ -210,7 +210,7 @@ void X11DRV_XF86VM_Init(void)
 #endif /* X_XF86VidModeSetGammaRamp */
 
   /* retrieve modes */
-  if (usexvidmode && root_window == DefaultRootWindow( gdi_display ))
+  if (usexvidmode && !is_virtual_desktop())
   {
       X11DRV_expect_error(gdi_display, XVidModeErrorHandler, NULL);
       ok = pXF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &real_xf86vm_modes);
-- 
2.23.0





More information about the wine-devel mailing list