winex11.drv: Unmaximize restored windows when necessary.

Vincent Povirk madewokherd at gmail.com
Thu Jul 30 12:20:46 CDT 2015


Some window managers (including xfwm and gnome shell) can unmaximize a
window while it's minimized. This makes no sense in win32 because
minimized windows cannot have the maximized state. Instead, minimized
windows that had been maximized restore to the maximized state.

This can cause the win32 state to get out of sync with the x11 state
when a window is minimized while maximized but restores to an
unmaximized state.

To see this:
1. Uncheck "Allow the window manager to decorate the windows" in winecfg.
2. Run notepad.
3. Maximize notepad.
4. Minimize notepad.
5. Unmaximize notepad.
6. Unminimize notepad.

The window has its original, unmaxmized size, but it has an
"unmaximize" button instead of a "maximize" button. This resolves
itself quickly in notepad, but other programs that draw their own
window decorations have more trouble.

I don't think it's possible to restore the window without maximizing
it on the win32 side, so we have to restore the window twice in this
case.
-------------- next part --------------
From 7fd4d7a6ba5e1b031b141b4fc29015dc11577c80 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Thu, 30 Jul 2015 12:00:21 -0500
Subject: [PATCH] winex11.drv: Unmaximize restored windows when necessary.

---
 dlls/winex11.drv/event.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index ee30259..bdad764 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -1258,6 +1258,11 @@ static void handle_wm_state_notify( HWND hwnd, XPropertyEvent *event, BOOL updat
                 TRACE( "restoring win %p/%lx\n", data->hwnd, data->whole_window );
                 release_win_data( data );
                 SendMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, 0 );
+                if ((style & WS_MINIMIZE) && (GetWindowLongW( hwnd, GWL_STYLE ) & WS_MAXIMIZE))
+                {
+                    TRACE( "unmaximizing win %p\n", hwnd );
+                    SendMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, 0 );
+                }
                 return;
             }
             TRACE( "not restoring win %p/%lx style %08x\n", data->hwnd, data->whole_window, style );
-- 
2.1.4



More information about the wine-patches mailing list