From ae6366b33c7a6a40802034bc4d12eaf31103e05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 13 Nov 2024 12:33:42 +0100 Subject: [PATCH] winex11: Introduce a new window_update_client_config helper. --- dlls/winex11.drv/event.c | 67 ++------------------------------------- dlls/winex11.drv/window.c | 39 +++++++++++++++++++++++ dlls/winex11.drv/x11drv.h | 1 + 3 files changed, 43 insertions(+), 64 deletions(-) diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index bd180b32117..82e82e6bc71 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1104,8 +1104,7 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev ) struct x11drv_win_data *data; RECT rect; POINT pos = {event->x, event->y}; - UINT style, flags = 0, config_cmd = 0; - int cx, cy, x, y; + UINT config_cmd; if (!hwnd) return FALSE; if (!(data = get_win_data( hwnd ))) return FALSE; @@ -1124,68 +1123,8 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev ) SetRect( &rect, pos.x, pos.y, pos.x + event->width, pos.y + event->height ); window_configure_notify( data, event->serial, &rect ); - if (!data->mapped || data->iconic) goto done; - if (!data->whole_window || !data->managed) goto done; - if (data->configure_serial && (long)(data->configure_serial - event->serial) > 0) - { - TRACE( "win %p/%lx event %d,%d,%dx%d ignoring old serial %lu/%lu\n", - hwnd, data->whole_window, event->x, event->y, event->width, event->height, - event->serial, data->configure_serial ); - goto done; - } - - rect = window_rect_from_visible( &data->rects, rect ); - - TRACE( "win %p/%lx new X rect %d,%d,%dx%d (event %d,%d,%dx%d)\n", - hwnd, data->whole_window, (int)rect.left, (int)rect.top, - (int)(rect.right-rect.left), (int)(rect.bottom-rect.top), - event->x, event->y, event->width, event->height ); - - /* Compare what has changed */ - - x = rect.left; - y = rect.top; - cx = rect.right - rect.left; - cy = rect.bottom - rect.top; - flags = SWP_NOACTIVATE | SWP_NOZORDER; - - if (!data->whole_window) flags |= SWP_NOCOPYBITS; /* we can't copy bits of foreign windows */ - - if (data->rects.window.left == x && data->rects.window.top == y) flags |= SWP_NOMOVE; - else - TRACE( "%p moving from (%d,%d) to (%d,%d)\n", - hwnd, (int)data->rects.window.left, (int)data->rects.window.top, x, y ); - - if ((data->rects.window.right - data->rects.window.left == cx && - data->rects.window.bottom - data->rects.window.top == cy) || - IsRectEmpty( &data->rects.window )) - flags |= SWP_NOSIZE; - else - TRACE( "%p resizing from (%dx%d) to (%dx%d)\n", - hwnd, (int)(data->rects.window.right - data->rects.window.left), - (int)(data->rects.window.bottom - data->rects.window.top), cx, cy ); - - style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ); - if ((style & WS_CAPTION) == WS_CAPTION || !data->is_fullscreen) - { - if ((data->current_state.net_wm_state & (1 << NET_WM_STATE_MAXIMIZED)) && !(style & WS_MAXIMIZE)) - { - TRACE( "window %p/%lx is maximized\n", data->hwnd, data->whole_window ); - config_cmd = SC_MAXIMIZE; - } - else if (!(data->current_state.net_wm_state & (1 << NET_WM_STATE_MAXIMIZED)) && (style & WS_MAXIMIZE)) - { - TRACE( "window %p/%lx is no longer maximized\n", data->hwnd, data->whole_window ); - config_cmd = SC_RESTORE; - } - } - if (!config_cmd && (flags & (SWP_NOSIZE | SWP_NOMOVE)) != (SWP_NOSIZE | SWP_NOMOVE)) - { - TRACE( "window %p/%lx config changed %s -> %s, flags %#x\n", data->hwnd, data->whole_window, - wine_dbgstr_rect(&data->rects.window), wine_dbgstr_rect(&rect), flags ); - config_cmd = MAKELONG(SC_MOVE, flags); - } -done: + config_cmd = window_update_client_config( data ); + rect = window_rect_from_visible( &data->rects, data->current_state.rect ); release_win_data( data ); if (config_cmd) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index e5d6426cfa2..bd13761aff4 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1531,6 +1531,45 @@ UINT window_update_client_state( struct x11drv_win_data *data ) return 0; } +UINT window_update_client_config( struct x11drv_win_data *data ) +{ + UINT old_style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ), flags; + RECT rect, old_rect = data->rects.window, new_rect; + + if (!data->managed) return 0; /* unmanaged windows are managed by the Win32 side */ + if (!data->mapped) return 0; /* ignore config changes on invisible windows */ + if (data->iconic) return 0; /* ignore config changes on minimized windows */ + + if (data->configure_serial) return 0; /* another config update is pending, wait for it to complete */ + + if ((old_style & WS_CAPTION) == WS_CAPTION || !data->is_fullscreen) + { + if ((data->current_state.net_wm_state & (1 << NET_WM_STATE_MAXIMIZED)) && !(old_style & WS_MAXIMIZE)) + { + TRACE( "window %p/%lx is maximized\n", data->hwnd, data->whole_window ); + return SC_MAXIMIZE; + } + if (!(data->current_state.net_wm_state & (1 << NET_WM_STATE_MAXIMIZED)) && (old_style & WS_MAXIMIZE)) + { + TRACE( "window %p/%lx is no longer maximized\n", data->hwnd, data->whole_window ); + return SC_RESTORE; + } + } + + flags = SWP_NOACTIVATE | SWP_NOZORDER; + rect = new_rect = window_rect_from_visible( &data->rects, data->current_state.rect ); + if (new_rect.left == old_rect.left && new_rect.top == old_rect.top) flags |= SWP_NOMOVE; + else OffsetRect( &rect, old_rect.left - new_rect.left, old_rect.top - new_rect.top ); + if (rect.right == old_rect.right && rect.bottom == old_rect.bottom) flags |= SWP_NOSIZE; + else if (IsRectEmpty( &rect )) flags |= SWP_NOSIZE; + + if ((flags & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE)) return 0; + + TRACE( "window %p/%lx config changed %s -> %s, flags %#x\n", data->hwnd, data->whole_window, + wine_dbgstr_rect(&old_rect), wine_dbgstr_rect(&new_rect), flags ); + return MAKELONG(SC_MOVE, flags); +} + void window_wm_state_notify( struct x11drv_win_data *data, unsigned long serial, UINT value ) { UINT *pending = &data->pending_state.wm_state, *current = &data->current_state.wm_state; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 0519d06d027..fbaa416c617 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -663,6 +663,7 @@ extern void window_wm_state_notify( struct x11drv_win_data *data, unsigned long extern void window_net_wm_state_notify( struct x11drv_win_data *data, unsigned long serial, UINT value ); extern void window_configure_notify( struct x11drv_win_data *data, unsigned long serial, const RECT *rect ); extern UINT window_update_client_state( struct x11drv_win_data *data ); +extern UINT window_update_client_config( struct x11drv_win_data *data ); extern void wait_for_withdrawn_state( HWND hwnd, BOOL set ); extern Window init_clip_window(void);