Commit d50c310d authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

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@gmail.com>. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=39731Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 0b56461f
...@@ -5085,7 +5085,7 @@ static void test_WM_DEVICECHANGE(HWND hwnd) ...@@ -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; HWND hwnd = arg;
...@@ -5095,6 +5095,16 @@ static DWORD CALLBACK show_window_thread(LPVOID arg) ...@@ -5095,6 +5095,16 @@ static DWORD CALLBACK show_window_thread(LPVOID arg)
return 0; 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 */ /* Helper function to easier test SetWindowPos messages */
#define test_msg_setpos( expected_list, flags, todo ) \ #define test_msg_setpos( expected_list, flags, todo ) \
test_msg_setpos_( (expected_list), (flags), (todo), __FILE__, __LINE__) test_msg_setpos_( (expected_list), (flags), (todo), __FILE__, __LINE__)
...@@ -5156,7 +5166,7 @@ static void test_messages(void) ...@@ -5156,7 +5166,7 @@ static void test_messages(void)
ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped", FALSE); ok_sequence(WmEmptySeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
/* test ShowWindow(SW_HIDE) on a hidden window - multi-threaded */ /* 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(hthread != NULL, "CreateThread failed, error %d\n", GetLastError());
ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n"); ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
CloseHandle(hthread); CloseHandle(hthread);
...@@ -5167,6 +5177,14 @@ static void test_messages(void) ...@@ -5167,6 +5177,14 @@ static void test_messages(void)
flush_events(); flush_events();
ok_sequence(WmShowOverlappedSeq, "ShowWindow(SW_SHOW):overlapped", TRUE); 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); ShowWindow(hwnd, SW_HIDE);
flush_events(); flush_events();
ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE); ok_sequence(WmHideOverlappedSeq, "ShowWindow(SW_HIDE):overlapped", FALSE);
......
...@@ -1231,6 +1231,9 @@ BOOL WINAPI ShowWindow( HWND hwnd, INT cmd ) ...@@ -1231,6 +1231,9 @@ BOOL WINAPI ShowWindow( HWND hwnd, INT cmd )
if ((cmd == SW_HIDE) && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) if ((cmd == SW_HIDE) && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
return FALSE; return FALSE;
if ((cmd == SW_SHOW) && (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE))
return TRUE;
return SendMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 ); return SendMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment