[PATCH] user32: Do not call SendMessage() to show a window that is already visible.
Kimmo Myllyvirta
kimmo.myllyvirta at gmail.com
Mon May 1 11:10:44 CDT 2017
On 04/30/2017 07:38 AM, Dmitry Timoshkov wrote:
> Kimmo Myllyvirta <kimmo.myllyvirta at gmail.com> wrote:
>
>> diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
>> index c2b35ec..64fdfe0 100644
>> --- a/dlls/user32/winpos.c
>> +++ b/dlls/user32/winpos.c
>> @@ -1239,6 +1239,9 @@ BOOL WINAPI ShowWindow( HWND hwnd, INT cmd )
>> if ((cmd == SW_HIDE) && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
>> return FALSE;
>>
>> + if ((cmd == SW_SHOW) && (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
>> + return TRUE;
>> +
>> return SendMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 );
>> }
> Please have a look at the show_window() implementation and try to cover
> all cases that trigger SWP_SHOWWINDOW flag passed to SetWindowPos() in
> order to actually show a window. In fact it's only SW_HIDE that leads
> to that, so perhaps just adding an 'else' to the SW_HIDE case is enough?
>
Yeah, it would be better to fix all the cases at once instead of
one-by-one. Probably something similar to the attached diff. I'll take a
look at it later, this is already fixed in staging it seems.
-------------- next part --------------
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index c2b35ec..d49be31 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -1227,6 +1227,8 @@ BOOL WINAPI ShowWindowAsync( HWND hwnd, INT cmd )
BOOL WINAPI ShowWindow( HWND hwnd, INT cmd )
{
HWND full_handle;
+ LONG style;
+ BOOL wasVisible;
if (is_broadcast(hwnd))
{
@@ -1236,8 +1238,37 @@ BOOL WINAPI ShowWindow( HWND hwnd, INT cmd )
if ((full_handle = WIN_IsCurrentThread( hwnd )))
return show_window( full_handle, cmd );
- if ((cmd == SW_HIDE) && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
- return FALSE;
+ style = GetWindowLongW( hwnd, GWL_STYLE );
+ wasVisible = (style & WS_VISIBLE) != 0;
+
+ switch(cmd)
+ {
+ case SW_HIDE:
+ if (!wasVisible) return FALSE;
+ break;
+ case SW_SHOWMINNOACTIVE:
+ case SW_MINIMIZE:
+ case SW_FORCEMINIMIZE:
+ case SW_SHOWMINIMIZED:
+ if ((style & WS_MINIMIZE) && wasVisible) return TRUE;
+ break;
+ case SW_SHOWMAXIMIZED:
+ if ((style & WS_MAXIMIZE) && wasVisible) return TRUE;
+ break;
+ case SW_SHOWNA:
+ break;
+ case SW_SHOW:
+ if (wasVisible) return TRUE;
+ break;
+ case SW_SHOWNOACTIVATE:
+ case SW_RESTORE:
+ case SW_SHOWNORMAL:
+ case SW_SHOWDEFAULT:
+ if (!(style & (WS_MINIMIZE | WS_MAXIMIZE)) && wasVisible) return TRUE;
+ break;
+ default:
+ return wasVisible;
+ }
return SendMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 );
}
More information about the wine-devel
mailing list