From b89c9c60d50cf21650331d1528ff965c319a1217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Mon, 3 Jun 2024 12:56:27 +0200 Subject: [PATCH] win32u: Move desktop resize on WM_DISPLAYCHANGE out of the drivers. --- dlls/win32u/defwnd.c | 27 ++++++++++++++++++++++++++- dlls/wineandroid.drv/window.c | 5 ----- dlls/winemac.drv/macdrv.h | 2 -- dlls/winemac.drv/window.c | 24 +----------------------- dlls/winewayland.drv/window.c | 17 ----------------- dlls/winex11.drv/desktop.c | 22 ---------------------- dlls/winex11.drv/window.c | 5 +---- dlls/winex11.drv/x11drv.h | 2 -- include/ntuser.h | 1 + 9 files changed, 29 insertions(+), 76 deletions(-) diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c index 43d31bc4f54..b0a5af26d2b 100644 --- a/dlls/win32u/defwnd.c +++ b/dlls/win32u/defwnd.c @@ -2979,7 +2979,32 @@ LRESULT desktop_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) case WM_NCCALCSIZE: return 0; case WM_DISPLAYCHANGE: - return user_driver->pDesktopWindowProc( hwnd, msg, wparam, lparam ); + { + static RECT virtual_rect; + + RECT new_rect = NtUserGetVirtualScreenRect(), old_rect = virtual_rect; + UINT context, flags = 0; + + if (EqualRect( &new_rect, &old_rect )) return TRUE; + virtual_rect = new_rect; + + TRACE( "desktop %p change from %s to %s\n", hwnd, wine_dbgstr_rect( &old_rect ), wine_dbgstr_rect( &new_rect ) ); + + if (new_rect.right - new_rect.left == old_rect.right - old_rect.left && + new_rect.bottom - new_rect.top == old_rect.bottom - old_rect.top) + flags |= SWP_NOSIZE; + if (new_rect.left == old_rect.left && new_rect.top == old_rect.top) + flags |= SWP_NOMOVE; + + context = NtUserSetThreadDpiAwarenessContext( NTUSER_DPI_PER_MONITOR_AWARE ); + NtUserSetWindowPos( hwnd, 0, new_rect.left, new_rect.top, + new_rect.right - new_rect.left, new_rect.bottom - new_rect.top, + flags | SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE ); + NtUserSetThreadDpiAwarenessContext( context ); + + return send_message_timeout( HWND_BROADCAST, WM_WINE_DESKTOP_RESIZED, old_rect.left, + old_rect.top, SMTO_ABORTIFHUNG, 2000, FALSE ); + } default: if (msg >= WM_USER && hwnd == get_desktop_window()) return user_driver->pDesktopWindowProc( hwnd, msg, wparam, lparam ); diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 7b7d680fe2e..19900c7e509 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -416,7 +416,6 @@ static void pull_events(void) */ static int process_events( DWORD mask ) { - UINT context; struct java_event *event, *next, *previous; unsigned int count = 0; @@ -457,13 +456,9 @@ static int process_events( DWORD mask ) { case DESKTOP_CHANGED: TRACE( "DESKTOP_CHANGED %ux%u\n", event->data.desktop.width, event->data.desktop.height ); - context = NtUserSetThreadDpiAwarenessContext( NTUSER_DPI_PER_MONITOR_AWARE ); screen_width = event->data.desktop.width; screen_height = event->data.desktop.height; init_monitors( screen_width, screen_height ); - NtUserSetWindowPos( NtUserGetDesktopWindow(), 0, 0, 0, screen_width, screen_height, - SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW ); - NtUserSetThreadDpiAwarenessContext( context ); break; case CONFIG_CHANGED: diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index ab5b9a2667b..68e20bbf5db 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -95,7 +95,6 @@ static inline RECT rect_from_cgrect(CGRect cgrect) enum macdrv_window_messages { WM_MACDRV_SET_WIN_REGION = WM_WINE_FIRST_DRIVER_MSG, - WM_MACDRV_DISPLAYCHANGE, WM_MACDRV_ACTIVATE_ON_FOLLOWING_FOCUS, }; @@ -268,7 +267,6 @@ extern CGImageRef create_cgimage_from_icon_bitmaps(HDC hdc, HANDLE icon, HBITMAP extern void macdrv_status_item_mouse_move(const macdrv_event *event); extern void check_retina_status(void); -extern void macdrv_resize_desktop(void); extern void init_user_driver(void); /* unixlib interface */ diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 35cf9255279..0bc3bf62add 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1575,25 +1575,6 @@ void macdrv_SetDesktopWindow(HWND hwnd) set_app_icon(); } -void macdrv_resize_desktop(void) -{ - HWND hwnd = NtUserGetDesktopWindow(); - CGRect new_desktop_rect; - RECT current_desktop_rect; - - macdrv_reset_device_metrics(); - new_desktop_rect = macdrv_get_desktop_rect(); - if (!NtUserGetWindowRect(hwnd, ¤t_desktop_rect) || - !CGRectEqualToRect(cgrect_from_rect(current_desktop_rect), new_desktop_rect)) - { - NtUserSetWindowPos(hwnd, 0, CGRectGetMinX(new_desktop_rect), CGRectGetMinY(new_desktop_rect), - CGRectGetWidth(new_desktop_rect), CGRectGetHeight(new_desktop_rect), - SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE); - send_message_timeout(HWND_BROADCAST, WM_MACDRV_DISPLAYCHANGE, 0, 0, - SMTO_ABORTIFHUNG, 2000, NULL); - } -} - #define WM_WINE_NOTIFY_ACTIVITY WM_USER LRESULT macdrv_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) @@ -1614,9 +1595,6 @@ LRESULT macdrv_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) #pragma clang diagnostic pop break; } - case WM_DISPLAYCHANGE: - macdrv_resize_desktop(); - break; } return NtUserMessageCall(hwnd, msg, wp, lp, 0, NtUserDefWindowProc, FALSE); } @@ -2018,7 +1996,7 @@ LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) release_win_data(data); } return 0; - case WM_MACDRV_DISPLAYCHANGE: + case WM_WINE_DESKTOP_RESIZED: macdrv_reset_device_metrics(); macdrv_reassert_window_position(hwnd); return 0; diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index dd023fc96a7..906dcbc42df 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -502,16 +502,6 @@ void WAYLAND_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags, wayland_win_data_release(data); } -static void wayland_resize_desktop(void) -{ - RECT virtual_rect = NtUserGetVirtualScreenRect(); - NtUserSetWindowPos(NtUserGetDesktopWindow(), 0, - virtual_rect.left, virtual_rect.top, - virtual_rect.right - virtual_rect.left, - virtual_rect.bottom - virtual_rect.top, - SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE); -} - static void wayland_configure_window(HWND hwnd) { struct wayland_surface *surface; @@ -652,13 +642,6 @@ LRESULT WAYLAND_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) */ LRESULT WAYLAND_DesktopWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { - switch (msg) - { - case WM_DISPLAYCHANGE: - wayland_resize_desktop(); - break; - } - return NtUserMessageCall(hwnd, msg, wp, lp, 0, NtUserDefWindowProc, FALSE); } diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c index cb119c9a7be..dae0d652737 100644 --- a/dlls/winex11.drv/desktop.c +++ b/dlls/winex11.drv/desktop.c @@ -100,25 +100,3 @@ BOOL is_desktop_fullscreen(void) return (primary_rect.right - primary_rect.left == host_primary_rect.right - host_primary_rect.left && primary_rect.bottom - primary_rect.top == host_primary_rect.bottom - host_primary_rect.top); } - -/*********************************************************************** - * X11DRV_resize_desktop - */ -void X11DRV_resize_desktop(void) -{ - static RECT old_virtual_rect; - - RECT virtual_rect = NtUserGetVirtualScreenRect(); - HWND hwnd = NtUserGetDesktopWindow(); - INT width = virtual_rect.right - virtual_rect.left, height = virtual_rect.bottom - virtual_rect.top; - - TRACE( "desktop %p change to (%dx%d)\n", hwnd, width, height ); - NtUserSetWindowPos( hwnd, 0, virtual_rect.left, virtual_rect.top, width, height, - SWP_NOZORDER | SWP_NOACTIVATE | SWP_DEFERERASE ); - - if (old_virtual_rect.left != virtual_rect.left || old_virtual_rect.top != virtual_rect.top) - send_message_timeout( HWND_BROADCAST, WM_X11DRV_DESKTOP_RESIZED, old_virtual_rect.left, - old_virtual_rect.top, SMTO_ABORTIFHUNG, 2000, FALSE ); - - old_virtual_rect = virtual_rect; -} diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index f975986a9d9..f2ffbebcc7c 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2063,9 +2063,6 @@ LRESULT X11DRV_DesktopWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) case WM_WINE_ADD_TAB: send_notify_message( (HWND)wp, WM_X11DRV_ADD_TAB, 0, 0 ); break; - case WM_DISPLAYCHANGE: - X11DRV_resize_desktop(); - break; } return NtUserMessageCall( hwnd, msg, wp, lp, 0, NtUserDefWindowProc, FALSE ); } @@ -3111,7 +3108,7 @@ LRESULT X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) release_win_data( data ); } return 0; - case WM_X11DRV_DESKTOP_RESIZED: + case WM_WINE_DESKTOP_RESIZED: if ((data = get_win_data( hwnd ))) { /* update the full screen state */ diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 2a326b07a4c..06d76499db7 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -580,7 +580,6 @@ enum x11drv_window_messages { WM_X11DRV_UPDATE_CLIPBOARD = WM_WINE_FIRST_DRIVER_MSG, WM_X11DRV_SET_WIN_REGION, - WM_X11DRV_DESKTOP_RESIZED, WM_X11DRV_DELETE_TAB, WM_X11DRV_ADD_TAB }; @@ -751,7 +750,6 @@ struct x11drv_settings_handler extern void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *handler); extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ); -extern void X11DRV_resize_desktop(void); extern BOOL is_virtual_desktop(void); extern BOOL is_desktop_fullscreen(void); extern BOOL is_detached_mode(const DEVMODEW *); diff --git a/include/ntuser.h b/include/ntuser.h index e22de3023d3..1d2f32b5ea6 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -504,6 +504,7 @@ enum wine_internal_message WM_WINE_KEYBOARD_LL_HOOK, WM_WINE_MOUSE_LL_HOOK, WM_WINE_UPDATEWINDOWSTATE, + WM_WINE_DESKTOP_RESIZED, WM_WINE_FIRST_DRIVER_MSG = 0x80001000, /* range of messages reserved for the USER driver */ WM_WINE_CLIPCURSOR = 0x80001ff0, /* internal driver notification messages */ WM_WINE_SETCURSOR,