The ShowWindow(SW_SHOWMINIMIZED):overlapped test shows that the message should not be sent in general.
This additional test shows that we should still the message if a menu is active.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/msg.c | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 423157b623d..aff4aeca24e 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -1926,6 +1926,41 @@ static const struct message WmSHOWNATopInvisible[] = { { 0 } };
+static const struct message WmTrackPopupMenuMinimizeWindow[] = { + { HCBT_CREATEWND, hook }, + { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 }, + { WM_INITMENU, sent|lparam, 0, 0 }, + { WM_INITMENUPOPUP, sent|lparam, 0, 0 }, + { 0x0093, sent|optional }, + { 0x0094, sent|optional }, + { 0x0094, sent|optional }, + { WM_ENTERIDLE, sent|wparam, 2 }, + { HCBT_MINMAX, hook }, + { HCBT_SETFOCUS, hook }, + { WM_KILLFOCUS, sent|wparam, 0 }, + { WM_GETTEXT, sent|optional }, + { WM_WINDOWPOSCHANGING, sent }, + { WM_GETMINMAXINFO, sent|defwinproc }, + { WM_NCCALCSIZE, sent|wparam|optional, 1 }, + { WM_WINDOWPOSCHANGED, sent }, + { WM_MOVE, sent|defwinproc }, + { WM_SIZE, sent|defwinproc }, + { WM_GETTEXT, sent|optional }, + { WM_NCCALCSIZE, sent|wparam|optional, 1 }, + { WM_CANCELMODE, sent }, + { WM_CAPTURECHANGED, sent|defwinproc }, + { HCBT_DESTROYWND, hook }, + { WM_UNINITMENUPOPUP, sent|defwinproc|lparam, 0, 0 }, + { WM_MENUSELECT, sent|defwinproc|wparam|lparam, 0xffff0000, 0 }, + { WM_EXITMENULOOP, sent|defwinproc|wparam|lparam, 1, 0 }, + { WM_NCACTIVATE, sent }, + { WM_GETTEXT, sent|defwinproc|optional }, + { WM_GETTEXT, sent|defwinproc|optional }, + { WM_ACTIVATE, sent }, + { WM_ACTIVATEAPP, sent|wparam, 0 }, + { 0 } +}; + static const struct message WmTrackPopupMenu[] = { { HCBT_CREATEWND, hook }, { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 }, @@ -17311,6 +17346,25 @@ static void test_layered_window(void)
static HMENU hpopupmenu;
+static LRESULT WINAPI minimize_popup_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + LRESULT ret; + + if (ignore_message( message )) return 0; + ret = MsgCheckProc( FALSE, hwnd, message, wParam, lParam ); + + switch (message) { + case WM_ENTERIDLE: + ShowWindow(hwnd, SW_MINIMIZE); + break; + case WM_TIMER: + EndMenu(); + break; + } + + return ret; +} + static LRESULT WINAPI cancel_popup_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { if (ignore_message( message )) return 0; @@ -17393,6 +17447,21 @@ static void test_TrackPopupMenu(void) ok_sequence(WmTrackPopupMenuAbort, "WmTrackPopupMenuAbort", TRUE); ok(ret == TRUE, "TrackPopupMenu failed\n");
+ SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)minimize_popup_proc); + + /* set cursor over the window, otherwise the WM_CANCELMODE message may not always be sent */ + SetCursorPos( 0, 0 ); + ShowWindow( hwnd, SW_SHOW ); + + flush_events(); + flush_sequence(); + SetTimer( hwnd, TIMER_ID, 500, NULL ); + ret = TrackPopupMenu( hpopupmenu, 0, 100,100, 0, hwnd, NULL ); + ok_sequence( WmTrackPopupMenuMinimizeWindow, "TrackPopupMenuMinimizeWindow", TRUE ); + ok( ret == 1, "TrackPopupMenu failed with error %i\n", GetLastError() ); + KillTimer( hwnd, TIMER_ID ); + ShowWindow( hwnd, SW_RESTORE ); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)cancel_popup_proc);
SetCapture(hwnd);
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/tests/msg.c | 2 +- dlls/winex11.drv/event.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index aff4aeca24e..0bf255c4b63 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -5188,7 +5188,7 @@ static void test_messages(void)
ShowWindow(hwnd, SW_MINIMIZE); flush_events(); - ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", TRUE); + ok_sequence(WmShowMinOverlappedSeq, "ShowWindow(SW_SHOWMINIMIZED):overlapped", FALSE); flush_sequence();
if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_MINIMIZE) diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 07f7a1ad502..b68a64bd30b 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -819,6 +819,7 @@ static void focus_out( Display *display , HWND hwnd ) { HWND hwnd_tmp; Window focus_win; + GUITHREADINFO threadinfo; int revert; XIC xic;
@@ -833,7 +834,12 @@ static void focus_out( Display *display , HWND hwnd ) return; } if (hwnd != GetForegroundWindow()) return; - SendMessageW( hwnd, WM_CANCELMODE, 0, 0 ); + + threadinfo.cbSize = sizeof(threadinfo); + GetGUIThreadInfo(0, &threadinfo); + + if (threadinfo.flags & (GUI_INMENUMODE|GUI_INMOVESIZE|GUI_POPUPMENUMODE|GUI_SYSTEMMENUMODE)) + SendMessageW( hwnd, WM_CANCELMODE, 0, 0 );
/* don't reset the foreground window, if the window which is getting the focus is a Wine window */
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=66336
Your paranoid android.
=== w2008s64 (32 bit report) ===
user32: msg.c:13509: Test failed: 54: ShowWindow(SW_MINIMIZE): 4: in msg 0x0047 expecting wParam 0x8170 got 0x1803 msg.c:13509: Test failed: 54: ShowWindow(SW_MINIMIZE): 5: the msg 0x0003 was expected, but got msg 0x0047 instead msg.c:13509: Test failed: 54: ShowWindow(SW_MINIMIZE): 6: the msg 0x0005 was expected, but got msg 0x0003 instead msg.c:13509: Test failed: 54: ShowWindow(SW_MINIMIZE): 7: the msg sequence is not complete: expected 0000 - actual 0005
=== w1064v1809_ar (32 bit report) ===
user32: msg.c:5185: Test failed: ShowWindow(SW_RESTORE):overlapped: 19: the msg sequence is not complete: expected 0000 - actual 0024
=== w1064v1809_zh_CN (32 bit report) ===
user32: msg.c:16325: Test failed: 7: WaitForSingleObject failed
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winemac.drv/window.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 605c0c87f16..8091f5249fe 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -2368,13 +2368,18 @@ void macdrv_window_got_focus(HWND hwnd, const macdrv_event *event) */ void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) { + GUITHREADINFO threadinfo; if (!hwnd) return;
TRACE("win %p/%p fg %p\n", hwnd, event->window, GetForegroundWindow());
if (hwnd == GetForegroundWindow()) { - SendMessageW(hwnd, WM_CANCELMODE, 0, 0); + threadinfo.cbSize = sizeof(threadinfo); + GetGUIThreadInfo(0, &threadinfo); + if (threadinfo.flags & (GUI_INMENUMODE|GUI_INMOVESIZE|GUI_POPUPMENUMODE|GUI_SYSTEMMENUMODE)) + SendMessageW(hwnd, WM_CANCELMODE, 0, 0); + if (hwnd == GetForegroundWindow()) SetForegroundWindow(GetDesktopWindow()); }
Hi Rémi,
On Mar 4, 2020, at 8:53 AM, Rémi Bernon rbernon@codeweavers.com wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
dlls/winemac.drv/window.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 605c0c87f16..8091f5249fe 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -2368,13 +2368,18 @@ void macdrv_window_got_focus(HWND hwnd, const macdrv_event *event) */ void macdrv_window_lost_focus(HWND hwnd, const macdrv_event *event) {
- GUITHREADINFO threadinfo;
Please add a blank line between variable declarations and code.
if (!hwnd) return; TRACE("win %p/%p fg %p\n", hwnd, event->window, GetForegroundWindow()); if (hwnd == GetForegroundWindow()) {
SendMessageW(hwnd, WM_CANCELMODE, 0, 0);
threadinfo.cbSize = sizeof(threadinfo);
GetGUIThreadInfo(0, &threadinfo);
if (threadinfo.flags & (GUI_INMENUMODE|GUI_INMOVESIZE|GUI_POPUPMENUMODE|GUI_SYSTEMMENUMODE))
Please put spaces around each "|" operator.
Thanks, Ken
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=66335
Your paranoid android.
=== w1064v1809_ja (32 bit report) ===
user32: msg.c:8792: Test failed: MsgWaitForMultipleObjects failed 102 msg.c:8806: Test failed: destroy child on thread exit: 1: the msg 0x000f was expected, but got msg 0x0024 instead msg.c:8806: Test failed: destroy child on thread exit: 2: the msg 0x0014 was expected, but got msg 0x000f instead msg.c:8806: Test failed: destroy child on thread exit: 3: the msg sequence is not complete: expected 0000 - actual 0014