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

Dmitry Timoshkov dmitry at codeweavers.com
Thu Jun 29 03:44:53 CDT 2006


Hello,

this version of the patch takes into account visibility of a window and
correctly calculates old fullscreen state.

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-29 17:34:56.000000000 +0900
@@ -530,13 +530,19 @@ 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;
     BOOL old_fs_state = FALSE, new_fs_state = FALSE;
 
-    if (old_client_rect->left <= 0 && old_client_rect->right >= screen_width &&
-        old_client_rect->top <= 0 && old_client_rect->bottom >= screen_height)
+#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 >= old_screen_rect->right &&
+        old_client_rect->top <= 0 && old_client_rect->bottom >= old_screen_rect->bottom)
         old_fs_state = TRUE;
 
     if (data->client_rect.left <= 0 && data->client_rect.right >= screen_width &&
@@ -575,7 +581,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 +725,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 +1228,36 @@ 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 )) &&
+        (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
+    {
+        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 +1267,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