From d9cf4678a1e4bb27a753c242d9aa0520e75e7163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Wed, 13 Nov 2024 12:30:13 +0100 Subject: [PATCH] winex11: Introduce a new window_update_client_state helper. --- dlls/winex11.drv/event.c | 40 ++------------------------------------- dlls/winex11.drv/window.c | 38 +++++++++++++++++++++++++++++++++++++ dlls/winex11.drv/x11drv.h | 2 ++ 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 29c10a913e3..bd180b32117 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1257,7 +1257,7 @@ static int get_window_xembed_info( Display *display, Window window ) static void handle_wm_state_notify( HWND hwnd, XPropertyEvent *event, BOOL update_window ) { struct x11drv_win_data *data; - UINT style, value = 0, state_cmd = 0; + UINT value = 0, state_cmd = 0; if (!(data = get_win_data( hwnd ))) return; if (event->state == PropertyNewValue) value = get_window_wm_state( event->display, event->window ); @@ -1278,49 +1278,13 @@ static void handle_wm_state_notify( HWND hwnd, XPropertyEvent *event, BOOL updat TRACE( "%p/%lx: new WM_STATE %d from %d\n", data->hwnd, data->whole_window, new_state, old_state ); data->wm_state = new_state; - /* ignore the initial state transition out of withdrawn state */ - /* metacity does Withdrawn->NormalState->IconicState when mapping an iconic window */ - if (!old_state) goto done; } } break; } - if (!update_window || !data->managed || !data->mapped) goto done; + if (update_window) state_cmd = window_update_client_state( data ); - style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ); - - if (data->iconic && data->current_state.wm_state == NormalState) /* restore window */ - { - data->iconic = FALSE; - if ((style & WS_CAPTION) == WS_CAPTION && (data->current_state.net_wm_state & (1 << NET_WM_STATE_MAXIMIZED))) - { - if ((style & WS_MAXIMIZEBOX) && !(style & WS_DISABLED)) - { - TRACE( "restoring to max %p/%lx\n", data->hwnd, data->whole_window ); - state_cmd = SC_MAXIMIZE; - } - } - else - { - if (style & (WS_MINIMIZE | WS_MAXIMIZE)) - { - BOOL activate = (style & (WS_MINIMIZE | WS_VISIBLE)) == (WS_MINIMIZE | WS_VISIBLE); - TRACE( "restoring win %p/%lx\n", data->hwnd, data->whole_window ); - state_cmd = MAKELONG(SC_RESTORE, activate); - } - } - } - else if (!data->iconic && data->current_state.wm_state == IconicState) - { - data->iconic = TRUE; - if ((style & WS_MINIMIZEBOX) && !(style & WS_DISABLED)) - { - TRACE( "minimizing win %p/%lx\n", data->hwnd, data->whole_window ); - state_cmd = SC_MINIMIZE; - } - } -done: release_win_data( data ); if (state_cmd) diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 878bf3ca157..e5d6426cfa2 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -1493,6 +1493,44 @@ static void unmap_window( HWND hwnd ) release_win_data( data ); } +UINT window_update_client_state( struct x11drv_win_data *data ) +{ + UINT old_style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ); + + if (!data->managed) return 0; /* unmanaged windows are managed by the Win32 side */ + if (!data->mapped) return 0; /* ignore state changes on invisible windows */ + + if (data->iconic && data->current_state.wm_state == NormalState) /* restore window */ + { + data->iconic = FALSE; + if ((old_style & WS_CAPTION) == WS_CAPTION && (data->current_state.net_wm_state & (1 << NET_WM_STATE_MAXIMIZED))) + { + if ((old_style & WS_MAXIMIZEBOX) && !(old_style & WS_DISABLED)) + { + TRACE( "restoring to max %p/%lx\n", data->hwnd, data->whole_window ); + return SC_MAXIMIZE; + } + } + else if (old_style & (WS_MINIMIZE | WS_MAXIMIZE)) + { + BOOL activate = (old_style & (WS_MINIMIZE | WS_VISIBLE)) == (WS_MINIMIZE | WS_VISIBLE); + TRACE( "restoring win %p/%lx\n", data->hwnd, data->whole_window ); + return MAKELONG(SC_RESTORE, activate); + } + } + else if (!data->iconic && data->current_state.wm_state == IconicState) + { + data->iconic = TRUE; + if ((old_style & WS_MINIMIZEBOX) && !(old_style & WS_DISABLED)) + { + TRACE( "minimizing win %p/%lx\n", data->hwnd, data->whole_window ); + return SC_MINIMIZE; + } + } + + return 0; +} + 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 4147e5a0337..0519d06d027 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -662,6 +662,8 @@ extern BOOL window_has_pending_wm_state( HWND hwnd, UINT state ); extern void window_wm_state_notify( struct x11drv_win_data *data, unsigned long serial, UINT value ); 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 void wait_for_withdrawn_state( HWND hwnd, BOOL set ); extern Window init_clip_window(void); extern void update_user_time( Time time );