Rémi Bernon : user32: Return TRUE from ShowWindow(SW_SHOW) if already visible.
Alexandre Julliard
julliard at winehq.org
Tue Mar 23 15:07:43 CDT 2021
Module: wine
Branch: oldstable
Commit: 7b8cf3ad4ef35595cc1f67202ccf5368f5d8a6a3
URL: https://source.winehq.org/git/wine.git/?a=commit;h=7b8cf3ad4ef35595cc1f67202ccf5368f5d8a6a3
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Fri Sep 11 11:52:01 2020 +0200
user32: Return TRUE from ShowWindow(SW_SHOW) if already visible.
Instead of calling SendMessage, similarly to the SW_HIDE case.
Based on a patch by Kimmo Myllyvirta <kimmo.myllyvirta at gmail.com>.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=39731
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit d50c310da96565dec98977e96a2d887097a6c1cf)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/user32/tests/msg.c | 22 ++++++++++++++++++++--
dlls/user32/winpos.c | 3 +++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 935e4379e97..7607059d090 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -5059,7 +5059,7 @@ static void test_WM_DEVICECHANGE(HWND hwnd)
}
}
-static DWORD CALLBACK show_window_thread(LPVOID arg)
+static DWORD CALLBACK hide_window_thread( LPVOID arg )
{
HWND hwnd = arg;
@@ -5069,6 +5069,16 @@ static DWORD CALLBACK show_window_thread(LPVOID arg)
return 0;
}
+static DWORD CALLBACK show_window_thread( LPVOID arg )
+{
+ HWND hwnd = arg;
+
+ /* function will not return if ShowWindow(SW_SHOW) calls SendMessage() */
+ ok( ShowWindow( hwnd, SW_SHOW ), "ShowWindow(SW_SHOW) expected TRUE\n" ); /* actually it's 24... */
+
+ return 0;
+}
+
/* Helper function to easier test SetWindowPos messages */
#define test_msg_setpos( expected_list, flags, todo ) \
test_msg_setpos_( (expected_list), (flags), (todo), __FILE__, __LINE__)
@@ -5130,7 +5140,7 @@ static void test_messages(void)
ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
/* test ShowWindow(SW_HIDE) on a hidden window - multi-threaded */
- hthread = CreateThread(NULL, 0, show_window_thread, hwnd, 0, &tid);
+ hthread = CreateThread( NULL, 0, hide_window_thread, hwnd, 0, &tid );
ok(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
CloseHandle(hthread);
@@ -5141,6 +5151,14 @@ static void test_messages(void)
flush_events();
ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE);
+ /* test ShowWindow(SW_SHOW) on a visible window - multi-threaded */
+ hthread = CreateThread( NULL, 0, show_window_thread, hwnd, 0, &tid );
+ ok( hthread != NULL, "CreateThread failed, error %d\n", GetLastError() );
+ ok( WaitForSingleObject( hthread, INFINITE ) == WAIT_OBJECT_0, "WaitForSingleObject failed\n" );
+ CloseHandle( hthread );
+ flush_events();
+ ok_sequence( WmEmptySeq, "ShowWindow(SW_SHOW):overlapped", FALSE );
+
ShowWindow(hwnd, SW_HIDE);
flush_events();
ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index f759bd10f94..968f519478c 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -1231,6 +1231,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 );
}
More information about the wine-cvs
mailing list