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=39731
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2020-09-11 11:52:01 +02:00 committed by Alexandre Julliard
parent 0b56461f35
commit d50c310da9
2 changed files with 23 additions and 2 deletions

View File

@ -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);

View File

@ -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 );
}