From: Zebediah Figura z.figura12@gmail.com
The ShowWindow(SW_SHOWMINIMIZED):overlapped test shows that the message should not be sent in general.
The additional test -which doesn't pass yet on wine for other reasons- shows that we should still send the message if a menu is active.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
This supersedes https://source.winehq.org/patches/data/172893. The other user32/tests patches in the series should still apply.
Notes: While testing I could see some cases when WM_CANCELMODE is not sent on some Windows versions although a menu is open -and it then stays open- but it also depends on the cursor location and the previous keyboard events that have been sent, so it's not reliable at all. Moving the cursor on top of a window beforehand seems to give consistent results.
dlls/user32/tests/msg.c | 71 ++++++++++++++++++++++++++++++++++++++- dlls/winemac.drv/window.c | 7 +++- dlls/winex11.drv/event.c | 8 ++++- 3 files changed, 83 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 477661ab623..59721056acd 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -1927,6 +1927,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 }, @@ -5163,7 +5198,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) @@ -17279,6 +17314,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; @@ -17361,6 +17415,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); 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()); } diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index dd8837c11da..c18b97f5360 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 */ -- 2.24.0.rc2
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=59333
Your paranoid android.
=== w8adm (32 bit report) ===
user32: msg.c:12963: Test failed: WmMouseHoverSeq: 3: the msg 0x0118 was expected, but got msg 0x001a instead msg.c:12963: Test failed: WmMouseHoverSeq: 4: the msg 0x02a1 was expected, but got msg 0x001a instead msg.c:12963: Test failed: WmMouseHoverSeq: 5: the msg sequence is not complete: expected 0000 - actual 0118
=== w1064v1809_ar (32 bit report) ===
user32: msg.c:4773: Test failed: ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup: 2: in msg 0x0046 expecting wParam 0x60 got 0x8060 msg.c:4796: Test failed: ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup: 2: in msg 0x0046 expecting wParam 0x60 got 0x8060 msg.c:4796: Test failed: ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup: 26: in msg 0x0047 expecting wParam 0x1863 got 0x9863 msg.c:4254: Test failed: ShowWindow(SW_MAXIMIZE):invisible maximized MDI child: 2: in msg 0x0046 expecting wParam 0x60 got 0x8060 msg.c:4254: Test failed: ShowWindow(SW_MAXIMIZE):invisible maximized MDI child: 20: in msg 0x0047 expecting wParam 0x1863 got 0x9863 msg.c:9249: Test failed: VK_N press/release: 3: in msg 0x0102 expecting wParam 0x6e got 0xec msg.c:9249: Test failed: VK_N press/release: 4: the msg 0x0111 was expected, but got msg 0x0102 instead msg.c:9258: Test failed: Shift+VK_N press/release: 6: in msg 0x0102 expecting wParam 0x4e got 0xc2 msg.c:9258: Test failed: Shift+VK_N press/release: 7: the msg 0x0111 was expected, but got msg 0x0102 instead msg.c:9276: Test failed: Alt+VK_N press/release: 6: in msg 0x0106 expecting wParam 0x6e got 0xec msg.c:9276: Test failed: Alt+VK_N press/release: 7: in msg 0x0106 expecting wParam 0x6e got 0xec msg.c:9276: Test failed: Alt+VK_N press/release: 8: in msg 0x0112 expecting lParam 0x6e got 0x649 msg.c:9276: Test failed: Alt+VK_N press/release: 16: in msg 0x0120 expecting wParam 0x2000006e got 0x200000ec msg.c:9300: Test failed: VK_N press/release: 3: in msg 0x0102 expecting wParam 0x6e got 0xec msg.c:9300: Test failed: VK_N press/release: 4: the msg 0x0111 was expected, but got msg 0x0102 instead msg.c:9309: Test failed: Shift+VK_N press/release: 6: in msg 0x0102 expecting wParam 0x4e got 0xc2 msg.c:9309: Test failed: Shift+VK_N press/release: 7: the msg 0x0111 was expected, but got msg 0x0102 instead msg.c:10373: Test failed: did not get expected count for minimum timeout (50 != ~100). msg.c:14256: Test failed: Failed to SetActiveWindow(0) msg.c:14257: Test failed: SetActiveWindow(0): 0: the msg sequence is not complete: expected 0086 - actual 0000 msg.c:15356: Test failed: popup menu command: 4: in msg 0x0106 expecting wParam 0x65 got 0xcb msg.c:15356: Test failed: popup menu command: 5: in msg 0x0008 expecting lParam 0x65 got 0x62b msg.c:15356: Test failed: popup menu command: 8: in msg 0x011f expecting wParam 0x900001 got 0xffff0000 msg.c:15356: Test failed: popup menu command: 9: the msg 0x0117 was expected, but got msg 0x0212 instead msg.c:15356: Test failed: popup menu command: 11: the msg 0x011f was expected, but got msg 0x0007 instead msg.c:15356: Test failed: popup menu command: 16: the msg 0x0125 was expected, but got msg 0x0105 instead msg.c:15356: Test failed: popup menu command: 17: the msg 0x011f was expected, but got msg 0x0007 instead msg.c:15356: Test failed: popup menu command: 18: the msg 0x0212 was expected, but got msg 0x0101 instead msg.c:15356: Test failed: popup menu command: 19: the msg 0x0126 was expected, but got msg 0x0007 instead msg.c:15356: Test failed: popup menu command: 21: the msg 0x0101 was expected, but got msg 0x0100 instead msg.c:15356: Test failed: popup menu command: 22: the msg sequence is not complete: expected 0000 - actual 0102 msg.c:15374: Test failed: submenu of a popup menu command: 4: in msg 0x0106 expecting wParam 0x66 got 0xc8 msg.c:15374: Test failed: submenu of a popup menu command: 5: in msg 0x0008 expecting lParam 0x66 got 0x628 msg.c:15374: Test failed: submenu of a popup menu command: 8: in msg 0x011f expecting wParam 0x900000 got 0xffff0000 msg.c:15374: Test failed: submenu of a popup menu command: 9: the msg 0x0117 was expected, but got msg 0x0212 instead msg.c:15374: Test failed: submenu of a popup menu command: 12: the msg 0x0003 was expected, but got msg 0x0007 instead msg.c:15374: Test failed: submenu of a popup menu command: 13: the msg 0x011f was expected, but got msg 0x0105 instead msg.c:15374: Test failed: submenu of a popup menu command: 14: in msg 0x0007 expecting wParam 0x46 got 0x12 msg.c:15374: Test failed: submenu of a popup menu command: 14: in msg 0x0007 expecting lParam 0xf0000001 got 0xc0000001 msg.c:15374: Test failed: submenu of a popup menu command: 22: the msg 0x0004 was expected, but got msg 0x0101 instead msg.c:15374: Test failed: submenu of a popup menu command: 23: the msg 0x0125 was expected, but got msg 0x0007 instead msg.c:15374: Test failed: submenu of a popup menu command: 25: the msg 0x0125 was expected, but got msg 0x0100 instead msg.c:15374: Test failed: submenu of a popup menu command: 26: the msg 0x011f was expected, but got msg 0x0007 instead msg.c:15374: Test failed: submenu of a popup menu command: 27: the msg 0x0212 was expected, but got msg 0x0101 instead msg.c:15374: Test failed: submenu of a popup menu command: 28: the msg 0x0126 was expected, but got msg 0x0007 instead msg.c:15374: Test failed: submenu of a popup menu command: 30: the msg 0x0101 was expected, but got msg 0x0100 instead msg.c:15374: Test failed: submenu of a popup menu command: 31: the msg sequence is not complete: expected 0000 - actual 0102 msg.c:15389: Test failed: single menu item command: 4: in msg 0x0106 expecting wParam 0x71 got 0xd6 msg.c:15389: Test failed: single menu item command: 5: in msg 0x0008 expecting lParam 0x71 got 0x636 msg.c:15389: Test failed: single menu item command: 8: in msg 0x011f expecting wParam 0x80012c got 0xffff0000 msg.c:15389: Test failed: single menu item command: 9: the msg 0x011f was expected, but got msg 0x0212 instead msg.c:15389: Test failed: single menu item command: 10: the msg 0x0212 was expected, but got msg 0x0007 instead msg.c:15389: Test failed: single menu item command: 11: the msg 0x0126 was expected, but got msg 0x0105 instead msg.c:15389: Test failed: single menu item command: 12: in msg 0x0007 expecting wParam 0x51 got 0x12 msg.c:15389: Test failed: single menu item command: 12: in msg 0x0007 expecting lParam 0xe0000001 got 0xc0000001 msg.c:15389: Test failed: single menu item command: 13: the msg 0x0105 was expected, but got msg 0x0101 instead msg.c:15389: Test failed: single menu item command: 14: in msg 0x0007 expecting wParam 0x12 got 0x1b msg.c:15389: Test failed: single menu item command: 14: in msg 0x0007 expecting lParam 0xc0000001 got 0x1 msg.c:15389: Test failed: single menu item command: 15: the msg 0x0101 was expected, but got msg 0x0100 instead msg.c:15389: Test failed: single menu item command: 17: the msg 0x0100 was expected, but got msg 0x0102 instead msg.c:15389: Test failed: single menu item command: 18: the msg 0x0102 was expected, but got msg 0x0007 instead msg.c:15422: Test failed: submenu of a popup menu command: 4: in msg 0x0106 expecting wParam 0x66 got 0xc8 msg.c:15422: Test failed: submenu of a popup menu command: 5: in msg 0x0008 expecting lParam 0x66 got 0x628 msg.c:15422: Test failed: submenu of a popup menu command: 8: in msg 0x011f expecting wParam 0x900000 got 0xffff0000 msg.c:15422: Test failed: submenu of a popup menu command: 9: the msg 0x0117 was expected, but got msg 0x0212 instead msg.c:15422: Test failed: submenu of a popup menu command: 12: the msg 0x0003 was expected, but got msg 0x0007 instead msg.c:15422: Test failed: submenu of a popup menu command: 13: the msg 0x011f was expected, but got msg 0x0105 instead msg.c:15422: Test failed: submenu of a popup menu command: 14: in msg 0x0007 expecting wParam 0x46 got 0x12 msg.c:15422: Test failed: submenu of a popup menu command: 14: in msg 0x0007 expecting lParam 0xf0000001 got 0xc0000001 msg.c:15422: Test failed: submenu of a popup menu command: 22: the msg 0x0004 was expected, but got msg 0x0101 instead msg.c:15422: Test failed: submenu of a popup menu command: 23: the msg 0x0125 was expected, but got msg 0x0007 instead msg.c:15422: Test failed: submenu of a popup menu command: 25: the msg 0x0125 was expected, but got msg 0x0100 instead msg.c:15422: Test failed: submenu of a popup menu command: 26: the msg 0x011f was expected, but got msg 0x0007 instead msg.c:15422: Test failed: submenu of a popup menu command: 27: the msg 0x0212 was expected, but got msg 0x0101 instead msg.c:15422: Test failed: submenu of a popup menu command: 28: the msg 0x0111 was expected, but got msg 0x0007 instead msg.c:15422: Test failed: submenu of a popup menu command: 30: the msg 0x0101 was expected, but got msg 0x0100 instead msg.c:15422: Test failed: submenu of a popup menu command: 31: the msg sequence is not complete: expected 0000 - actual 0102
Report errors: user32:msg prints too much data (57333 bytes)
=== w1064v1809_he (32 bit report) ===
user32: msg.c:16294: Test failed: 3: WaitForSingleObject failed msg.c:10373: Test failed: did not get expected count for minimum timeout (52 != ~100).
=== w1064v1809_ja (32 bit report) ===
user32: msg.c:10303: Test failed: did not get expected count for minimum timeout (54 != ~100). msg.c:14634: Test failed: unexpected hwnd 000902E0 msg.c:14639: Test failed: unexpected hwnd 000902E0
=== w1064v1809_zh_CN (32 bit report) ===
user32: msg.c:16294: Test failed: 1: WaitForSingleObject failed msg.c:4773: Test failed: ShowWindow(SW_SHOWMAXIMIZED):invisible maximized and resized popup: 2: in msg 0x0046 expecting wParam 0x60 got 0x8060 msg.c:4796: Test failed: ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup: 2: in msg 0x0046 expecting wParam 0x60 got 0x8060 msg.c:4796: Test failed: ShowWindow(SW_SHOWMAXIMIZED):invisible maximized popup: 26: in msg 0x0047 expecting wParam 0x1863 got 0x9863 msg.c:4254: Test failed: ShowWindow(SW_MAXIMIZE):invisible maximized MDI child: 2: in msg 0x0046 expecting wParam 0x60 got 0x8060 msg.c:4254: Test failed: ShowWindow(SW_MAXIMIZE):invisible maximized MDI child: 20: in msg 0x0047 expecting wParam 0x1863 got 0x9863 msg.c:10373: Test failed: did not get expected count for minimum timeout (53 != ~100). msg.c:14256: Test failed: Failed to SetActiveWindow(0) msg.c:14257: Test failed: SetActiveWindow(0): 0: the msg sequence is not complete: expected 0086 - actual 0000 msg.c:14414: Test failed: got message 31f msg.c:14634: Test failed: unexpected hwnd 0026038E msg.c:14635: Test failed: unexpected message 31f msg.c:14636: Test failed: bad wparam 1/81 msg.c:14639: Test failed: unexpected hwnd 0026038E msg.c:14640: Test failed: unexpected message 31f msg.c:14641: Test failed: bad wparam 1/81 msg.c:14646: Test failed: bad wparam 81/81 msg.c:14651: Test failed: bad wparam 81/81 msg.c:14653: Test failed: got message 102
=== w1064v1809 (64 bit report) ===
user32: msg.c:9430: Test failed: Shift+MouseButton press/release: 7: the msg 0x0202 was expected, but got msg 0x0007 instead msg.c:9430: Test failed: Shift+MouseButton press/release: 8: the msg 0x0202 was expected, but got msg 0x0101 instead msg.c:9430: Test failed: Shift+MouseButton press/release: 10: the msg 0x0101 should have been sent msg.c:9430: Test failed: Shift+MouseButton press/release: 11: the msg 0x0101 was expected, but got msg 0x0202 instead msg.c:9430: Test failed: Shift+MouseButton press/release: 12: the msg sequence is not complete: expected 0000 - actual 0202 msg.c:10303: Test failed: did not get expected count for minimum timeout (54 != ~100).
On 11/6/19 11:44 AM, Rémi Bernon wrote:
From: Zebediah Figura z.figura12@gmail.com
The ShowWindow(SW_SHOWMINIMIZED):overlapped test shows that the message should not be sent in general.
The additional test -which doesn't pass yet on wine for other reasons- shows that we should still send the message if a menu is active.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
This supersedes https://source.winehq.org/patches/data/172893. The other user32/tests patches in the series should still apply.
Notes: While testing I could see some cases when WM_CANCELMODE is not sent on some Windows versions although a menu is open -and it then stays open- but it also depends on the cursor location and the previous keyboard events that have been sent, so it's not reliable at all. Moving the cursor on top of a window beforehand seems to give consistent results.
dlls/user32/tests/msg.c | 71 ++++++++++++++++++++++++++++++++++++++- dlls/winemac.drv/window.c | 7 +++- dlls/winex11.drv/event.c | 8 ++++- 3 files changed, 83 insertions(+), 3 deletions(-)
Interesting deduction. I remember testing even with a modal menu and finding that WM_CANCELMODE was not sent (and that the menu then stayed open), but I guess I was running into one of those corner cases.
I feel like this probably shouldn't have my name on it as author, given the quantity of added code over my original patch, but I don't care too strongly.
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 477661ab623..59721056acd 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -1927,6 +1927,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 },
@@ -5163,7 +5198,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)
@@ -17279,6 +17314,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;
@@ -17361,6 +17415,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);
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()); }
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index dd8837c11da..c18b97f5360 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 */
-- 2.24.0.rc2