From: Rémi Bernon rbernon@codeweavers.com
Making the changes computation more readable, matching styles between the current Win32 style and the current X11 (current_state) style. --- dlls/winex11.drv/event.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 2a95552b8d6..088a124654e 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -1226,12 +1226,21 @@ 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; + UINT old_style, new_style, value = 0;
if (!(data = get_win_data( hwnd ))) return; if (event->state == PropertyNewValue) value = get_window_wm_state( event->display, event->window ); if (update_window) window_wm_state_notify( data, event->serial, value );
+ /* Compute the necessary changes to transition from the current Win32 + * window state (old_style), to the current X11 window state (new_style). + */ + old_style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ); + new_style = old_style & ~(WS_VISIBLE | WS_MINIMIZE | WS_MAXIMIZE); + if (data->current_state.wm_state == IconicState) new_style |= WS_MINIMIZE; + if (data->current_state.wm_state != WithdrawnState) new_style |= WS_VISIBLE; + if (data->current_state.net_wm_state & (1 << NET_WM_STATE_MAXIMIZED)) new_style |= WS_MAXIMIZE; + switch(event->state) { case PropertyDelete: @@ -1257,48 +1266,46 @@ static void handle_wm_state_notify( HWND hwnd, XPropertyEvent *event, BOOL updat
if (!update_window || !data->managed || !data->mapped) goto done;
- style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE ); - - if (data->iconic && data->wm_state == NormalState) /* restore window */ + if ((old_style & WS_MINIMIZE) && !(new_style & WS_MINIMIZE)) /* restore window */ { data->iconic = FALSE; data->net_wm_state = get_window_net_wm_state( event->display, data->whole_window ); - if ((style & WS_CAPTION) == WS_CAPTION && (data->net_wm_state & (1 << NET_WM_STATE_MAXIMIZED))) + if ((old_style & WS_CAPTION) == WS_CAPTION && (new_style & WS_MAXIMIZE)) { - if ((style & WS_MAXIMIZEBOX) && !(style & WS_DISABLED)) + if ((old_style & WS_MAXIMIZEBOX) && !(old_style & WS_DISABLED)) { TRACE( "restoring to max %p/%lx\n", data->hwnd, data->whole_window ); release_win_data( data ); send_message( hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0 ); return; } - TRACE( "not restoring to max win %p/%lx style %08x\n", data->hwnd, data->whole_window, style ); + TRACE( "window %p/%lx style %#x not restoring to max\n", data->hwnd, data->whole_window, old_style ); } else { - if (style & (WS_MINIMIZE | WS_MAXIMIZE)) + if (old_style & (WS_MINIMIZE | WS_MAXIMIZE)) { TRACE( "restoring win %p/%lx\n", data->hwnd, data->whole_window ); release_win_data( data ); - if ((style & (WS_MINIMIZE | WS_VISIBLE)) == (WS_MINIMIZE | WS_VISIBLE)) + if ((old_style & (WS_MINIMIZE | WS_VISIBLE)) == (WS_MINIMIZE | WS_VISIBLE)) NtUserSetActiveWindow( hwnd ); send_message( hwnd, WM_SYSCOMMAND, SC_RESTORE, 0 ); return; } - TRACE( "not restoring win %p/%lx style %08x\n", data->hwnd, data->whole_window, style ); + TRACE( "window %p/%lx style %#x not restoring\n", data->hwnd, data->whole_window, old_style ); } } - else if (!data->iconic && data->wm_state == IconicState) + else if (!(old_style & WS_MINIMIZE) && (new_style & WS_MINIMIZE)) { data->iconic = TRUE; - if ((style & WS_MINIMIZEBOX) && !(style & WS_DISABLED)) + if ((old_style & WS_MINIMIZEBOX) && !(old_style & WS_DISABLED)) { TRACE( "minimizing win %p/%lx\n", data->hwnd, data->whole_window ); release_win_data( data ); send_message( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0 ); return; } - TRACE( "not minimizing win %p/%lx style %08x\n", data->hwnd, data->whole_window, style ); + TRACE( "window %p/%lx style %#x not minimizing\n", data->hwnd, data->whole_window, old_style ); } done: release_win_data( data );