Rémi Bernon : user32: Return TRUE from ShowWindow(SW_SHOW) if already visible.

Alexandre Julliard julliard at winehq.org
Fri Sep 11 14:51:45 CDT 2020


Module: wine
Branch: master
Commit: d50c310da96565dec98977e96a2d887097a6c1cf
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d50c310da96565dec98977e96a2d887097a6c1cf

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>

---

 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 f84525a0bf..bf20c5c7f2 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -5085,7 +5085,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;
 
@@ -5095,6 +5095,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__)
@@ -5156,7 +5166,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);
@@ -5167,6 +5177,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 b45b74ce82..e3c3f5c5c6 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