Update window's full screen state on the resolution change as well as on the window resize event

Dmitry Timoshkov dmitry at codeweavers.com
Wed Jun 28 07:31:48 CDT 2006


Hello,

current code which switches a window to a fullscreen state doesn't handle
a case when a window is not being resized but screen resolution being changed
instead.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Update window's full screen state on the resolution change as well
    as on the window resize event.

--- cvs/hq/wine/dlls/winex11.drv/winpos.c	2006-06-24 13:27:12.000000000 +0900
+++ wine/dlls/winex11.drv/winpos.c	2006-06-28 20:57:19.000000000 +0900
@@ -530,11 +530,18 @@ void X11DRV_SetWindowStyle( HWND hwnd, D
  * This only works for mapped windows.
  */
 static void update_fullscreen_state( Display *display, struct x11drv_win_data *data,
-                                     const RECT *old_client_rect )
+                                     const RECT *old_client_rect, const RECT *old_screen_rect )
 {
     XEvent xev;
+    RECT new_screen_rect;
     BOOL old_fs_state = FALSE, new_fs_state = FALSE;
 
+#if 0
+    TRACE("old client_rect %s, new client_rect %s, new screen %d x %d, old screen %ld x %ld\n",
+        wine_dbgstr_rect(old_client_rect), wine_dbgstr_rect(&data->client_rect),
+        screen_width, screen_height, old_screen_rect->right, old_screen_rect->bottom);
+#endif
+
     if (old_client_rect->left <= 0 && old_client_rect->right >= screen_width &&
         old_client_rect->top <= 0 && old_client_rect->bottom >= screen_height)
         old_fs_state = TRUE;
@@ -543,7 +550,9 @@ static void update_fullscreen_state( Dis
         data->client_rect.top <= 0 && data->client_rect.bottom >= screen_height)
         new_fs_state = TRUE;
 
-    if (new_fs_state == old_fs_state) return;
+    SetRect( &new_screen_rect, 0, 0, screen_width, screen_height );
+    if (new_fs_state == old_fs_state && EqualRect( old_screen_rect, &new_screen_rect ))
+        return;
 
     TRACE("setting fullscreen state for hwnd %p to %s\n", data->hwnd, new_fs_state ? "true" : "false");
 
@@ -575,7 +584,7 @@ BOOL X11DRV_set_window_pos( HWND hwnd, H
                             const RECT *rectClient, UINT swp_flags, const RECT *valid_rects )
 {
     struct x11drv_win_data *data;
-    RECT new_whole_rect, old_client_rect;
+    RECT new_whole_rect, old_client_rect, old_screen_rect;
     WND *win;
     DWORD old_style, new_style;
     BOOL ret;
@@ -719,7 +728,8 @@ BOOL X11DRV_set_window_pos( HWND hwnd, H
                     XMapWindow( display, data->whole_window );
                     wine_tsx11_unlock();
                 }
-                update_fullscreen_state( display, data, &old_client_rect );
+                SetRect( &old_screen_rect, 0, 0, screen_width, screen_height );
+                update_fullscreen_state( display, data, &old_client_rect, &old_screen_rect );
             }
         }
     }
@@ -1221,16 +1231,35 @@ void X11DRV_UnmapNotify( HWND hwnd, XEve
 }
 
 
+static BOOL CALLBACK update_windows_fullscreen_state( HWND hwnd, LPARAM lparam )
+{
+    struct x11drv_win_data *data;
+    Display *display = thread_display();
+    RECT *old_screen_rect = (RECT *)lparam;
+
+    if ((data = X11DRV_get_win_data( hwnd )))
+    {
+        update_fullscreen_state( display, data, &data->client_rect, old_screen_rect );
+    }
+    return TRUE;
+}
+
+
 /***********************************************************************
  *		X11DRV_handle_desktop_resize
  */
 void X11DRV_handle_desktop_resize( unsigned int width, unsigned int height )
 {
+    unsigned int old_screen_width, old_screen_height;
     RECT rect;
     HWND hwnd = GetDesktopWindow();
     struct x11drv_win_data *data;
 
     if (!(data = X11DRV_get_win_data( hwnd ))) return;
+
+    old_screen_width = screen_width;
+    old_screen_height = screen_height;
+
     screen_width  = width;
     screen_height = height;
     TRACE("desktop %p change to (%dx%d)\n", hwnd, width, height);
@@ -1240,6 +1269,9 @@ void X11DRV_handle_desktop_resize( unsig
     data->lock_changes--;
     SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_depth,
                          MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL );
+
+    SetRect( &rect, 0, 0, old_screen_width, old_screen_height );
+    EnumWindows( update_windows_fullscreen_state, (LPARAM)&rect );
 }
 
 






More information about the wine-patches mailing list