[PATCH 1/2] user32: Do not call SendMessage() to show a window that is already visible.
From: Kimmo Myllyvirta <kimmo.myllyvirta(a)gmail.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=39731 Signed-off-by: Alexey Prokhin <alexey(a)prokhin.ru> --- dlls/user32/winpos.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index 5837c179e4..8e09455e99 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 ); } -- 2.17.2 (Apple Git-113)
Signed-off-by: Alexey Prokhin <alexey(a)prokhin.ru> --- dlls/user32/tests/msg.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 6d0f0637ee..5bbe273792 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -5041,7 +5041,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; @@ -5051,6 +5051,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) != FALSE, "ShowWindow(SW_SHOW) expected nonzero\n"); + + 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__) @@ -5112,7 +5122,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); @@ -5153,10 +5163,19 @@ static void test_messages(void) flush_sequence(); } + /* test ShowWindow(SW_SHOW) on a visible window - single threaded */ ShowWindow(hwnd, SW_SHOW); flush_events(); ok_sequence(WmOptionalPaint, "ShowWindow(SW_SHOW):overlapped already visible", FALSE); + /* 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(WmOptionalPaint, "ShowWindow(SW_SHOW):overlapped already visible", FALSE); + SetWindowPos(hwnd, 0,0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE); ok_sequence(WmSWP_HideOverlappedSeq, "SetWindowPos:SWP_HIDEWINDOW:overlapped", FALSE); ok(!IsWindowVisible(hwnd), "window should not be visible at this point\n"); -- 2.17.2 (Apple Git-113)
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53375 Your paranoid android. === wvistau64_zh_CN (32 bit report) === user32: msg.c:5162: Test failed: ShowWindow(SW_RESTORE):overlapped: 44: the msg sequence is not complete: expected 0000 - actual 0088 === debian9 (64 bit WoW report) === user32: clipboard.c:833: Test failed: 2: gle 5 clipboard.c:838: Test failed: 2.0: got 0000 instead of 000d clipboard.c:868: Test failed: 2: gle 1418 clipboard.c:717: Test failed: 3: gle 5 clipboard.c:719: Test failed: 3: gle 1418 clipboard.c:746: Test failed: 3: count 5 clipboard.c:749: Test failed: 3: gle 1418 clipboard.c:755: Test failed: 3: 0003 not available clipboard.c:757: Test failed: 3: count 5 instead of 2 clipboard.c:760: Test failed: 3: gle 5 clipboard.c:765: Test failed: 3.0: got 0000 instead of 000e clipboard.c:805: Test failed: 3: gle 1418 clipboard.c:815: Test failed: 3: count 5 clipboard.c:818: Test failed: 3: gle 1418 clipboard.c:826: Test failed: 3: 0003 not available clipboard.c:828: Test failed: 3: count 5 instead of 2 clipboard.c:833: Test failed: 3: gle 5 clipboard.c:838: Test failed: 3.0: got 0000 instead of 000e clipboard.c:868: Test failed: 3: gle 1418 clipboard.c:717: Test failed: 4: gle 5 clipboard.c:719: Test failed: 4: gle 1418 clipboard.c:746: Test failed: 4: count 6 clipboard.c:749: Test failed: 4: gle 1418 clipboard.c:757: Test failed: 4: count 6 instead of 2 clipboard.c:760: Test failed: 4: gle 5 clipboard.c:765: Test failed: 4.0: got 0000 instead of 0003 clipboard.c:805: Test failed: 4: gle 1418 clipboard.c:815: Test failed: 4: count 6 clipboard.c:818: Test failed: 4: gle 1418 clipboard.c:828: Test failed: 4: count 6 instead of 2 clipboard.c:833: Test failed: 4: gle 5 clipboard.c:838: Test failed: 4.0: got 0000 instead of 0003 clipboard.c:868: Test failed: 4: gle 1418 clipboard.c:717: Test failed: 5: gle 5 clipboard.c:719: Test failed: 5: gle 1418 clipboard.c:746: Test failed: 5: count 7 clipboard.c:749: Test failed: 5: gle 1418 clipboard.c:755: Test failed: 5: 0008 not available clipboard.c:755: Test failed: 5: 0011 not available clipboard.c:757: Test failed: 5: count 7 instead of 3 clipboard.c:760: Test failed: 5: gle 5 clipboard.c:765: Test failed: 5.0: got 0000 instead of 0002 clipboard.c:805: Test failed: 5: gle 1418 clipboard.c:815: Test failed: 5: count 7 clipboard.c:818: Test failed: 5: gle 1418 clipboard.c:826: Test failed: 5: 0008 not available clipboard.c:826: Test failed: 5: 0011 not available clipboard.c:828: Test failed: 5: count 7 instead of 3 clipboard.c:833: Test failed: 5: gle 5 clipboard.c:838: Test failed: 5.0: got 0000 instead of 0002 clipboard.c:868: Test failed: 5: gle 1418 clipboard.c:717: Test failed: 6: gle 5 clipboard.c:719: Test failed: 6: gle 1418 clipboard.c:746: Test failed: 6: count 8 clipboard.c:749: Test failed: 6: gle 1418 clipboard.c:755: Test failed: 6: 0011 not available clipboard.c:757: Test failed: 6: count 8 instead of 3 clipboard.c:760: Test failed: 6: gle 5 clipboard.c:765: Test failed: 6.0: got 0000 instead of 0008 clipboard.c:805: Test failed: 6: gle 1418 clipboard.c:815: Test failed: 6: count 8 clipboard.c:818: Test failed: 6: gle 1418 clipboard.c:826: Test failed: 6: 0011 not available clipboard.c:828: Test failed: 6: count 8 instead of 3 clipboard.c:833: Test failed: 6: gle 5 clipboard.c:838: Test failed: 6.0: got 0000 instead of 0008 clipboard.c:868: Test failed: 6: gle 1418 clipboard.c:717: Test failed: 7: gle 5 clipboard.c:719: Test failed: 7: gle 1418 clipboard.c:746: Test failed: 7: count 9 clipboard.c:749: Test failed: 7: gle 1418 clipboard.c:757: Test failed: 7: count 9 instead of 3 clipboard.c:760: Test failed: 7: gle 5 clipboard.c:765: Test failed: 7.0: got 0000 instead of 0011 clipboard.c:805: Test failed: 7: gle 1418 clipboard.c:815: Test failed: 7: count 9 clipboard.c:818: Test failed: 7: gle 1418 clipboard.c:828: Test failed: 7: count 9 instead of 3 clipboard.c:833: Test failed: 7: gle 5 clipboard.c:838: Test failed: 7.0: got 0000 instead of 0011 clipboard.c:868: Test failed: 7: gle 1418 clipboard.c:874: Test failed: gle 5 clipboard.c:876: Test failed: gle 1418 clipboard.c:878: Test failed: gle 1418
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53374 Your paranoid android. === debian9 (64 bit WoW report) === user32: msg.c:8713: Test failed: WaitForSingleObject failed 102 msg.c:8719: Test failed: destroy child on thread exit: 0: the msg 0x0082 was expected, but got msg 0x000f instead msg.c:8719: Test failed: destroy child on thread exit: 1: the msg 0x000f was expected, but got msg 0x0014 instead msg.c:8719: Test failed: destroy child on thread exit: 2: the msg sequence is not complete: expected 0014 - actual 0000
Alexey Prokhin <alexey(a)prokhin.ru> wrote:
+ if ((cmd == SW_SHOW) && (GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) + return TRUE; + return SendMessageW( hwnd, WM_WINE_SHOWWINDOW, cmd, 0 ); }
It's not useful to resend a patch without investigating first why it wasn't accepted previously. -- Dmitry.
It's not useful to resend a patch without investigating first why it wasn't accepted previously.
Sorry, I completely missed the fact the patch had already sent. I assumed nobody had done it yet, because it was missing a test case. (Google search turned out to be completely useless for the use case.) I will try to clean it up and resend. Dmitry, may I send you the new patch for a "pre-review" before sending it to the list, so I do not embarrass myself in public even more?
Alexey Prokhin <alexey(a)prokhin.ru> wrote:
It's not useful to resend a patch without investigating first why it wasn't accepted previously.
Sorry, I completely missed the fact the patch had already sent. I assumed nobody had done it yet, because it was missing a test case. (Google search turned out to be completely useless for the use case.) I will try to clean it up and resend.
Dmitry, may I send you the new patch for a "pre-review" before sending it to the list, so I do not embarrass myself in public even more?
Sure. -- Dmitry.
participants (3)
-
Alexey Prokhin -
Dmitry Timoshkov -
Marvin