From e3258e7620ac30f5570bd939ea0d3e690d8ea616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 13 Nov 2024 11:46:58 +0100 Subject: [PATCH] winex11: Simplify the control flow in ConfigureNotify handlers. --- dlls/winex11.drv/event.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 75d61d4d84f..22c15b50274 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1073,9 +1073,8 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev ) struct x11drv_win_data *data; RECT rect; POINT pos = {event->x, event->y}; - UINT flags; + UINT style, flags = 0, config_cmd = 0; int cx, cy, x, y; - DWORD style; if (!hwnd) return FALSE; if (!(data = get_win_data( hwnd ))) return FALSE; @@ -1139,35 +1138,33 @@ static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev ) if ((style & WS_CAPTION) == WS_CAPTION || !data->is_fullscreen) { data->net_wm_state = get_window_net_wm_state( event->display, data->whole_window ); - if ((data->net_wm_state & (1 << NET_WM_STATE_MAXIMIZED))) + if ((data->net_wm_state & (1 << NET_WM_STATE_MAXIMIZED)) && !(style & WS_MAXIMIZE)) { - if (!(style & WS_MAXIMIZE)) - { - TRACE( "win %p/%lx is maximized\n", data->hwnd, data->whole_window ); - release_win_data( data ); - send_message( data->hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0 ); - return TRUE; - } + TRACE( "window %p/%lx is maximized\n", data->hwnd, data->whole_window ); + config_cmd = SC_MAXIMIZE; } - else if (style & WS_MAXIMIZE) + else if (!(data->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 ); - release_win_data( data ); - send_message( data->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0 ); - return TRUE; + config_cmd = SC_RESTORE; } } - - if ((flags & (SWP_NOSIZE | SWP_NOMOVE)) != (SWP_NOSIZE | SWP_NOMOVE)) + if (!config_cmd && (flags & (SWP_NOSIZE | SWP_NOMOVE)) != (SWP_NOSIZE | SWP_NOMOVE)) { - release_win_data( data ); - NtUserSetRawWindowPos( hwnd, rect, flags, FALSE ); - return TRUE; + 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: release_win_data( data ); - return FALSE; + + if (config_cmd) + { + if (LOWORD(config_cmd) == SC_MOVE) NtUserSetRawWindowPos( hwnd, rect, HIWORD(config_cmd), FALSE ); + else send_message( hwnd, WM_SYSCOMMAND, LOWORD(config_cmd), 0 ); + } + + return !!config_cmd; }