[0.4.14][NTUSER][USER32] Workaround tracking menu on CORE-17338 (#4048)
authorJoachim Henze <Joachim.Henze@reactos.org>
Sat, 23 Oct 2021 21:38:54 +0000 (23:38 +0200)
committerJoachim Henze <Joachim.Henze@reactos.org>
Sat, 23 Oct 2021 21:38:54 +0000 (23:38 +0200)
This prevents the tracking menu from erroneously closing itself right after it was opened in some cases.
Fixes CORE-17338 which got unhidden by 0.4.15-dev-1126-g 58b0558f94abee52ce1c261063d4f4b884e96310
And fixes CORE-15760 which got unhidden by SVN r74972 == git 19dd22d42218da03ab748879aa3c3e288f41697e

Since both symptoms look very similar but the unhiding revisions did differ,
that could mean we do have some kind of race condition here.
I guess this fix is more like a workaround.

Fix picked from 0.4.15-dev-3313-g 6417b2323d7ef74dc4c7b8319d48e8932c50d588

win32ss/user/ntuser/menu.c
win32ss/user/user32/windows/defwnd.c

index 71a52b9..3c006fc 100644 (file)
@@ -4118,7 +4118,7 @@ static INT FASTCALL MENU_TrackMenu(PMENU pmenu, UINT wFlags, INT x, INT y,
                 /* ReactOS Checks */
                 if (!VerifyWnd(mt.OwnerWnd)                            ||
                     !ValidateHwndNoErr(mt.CurrentMenu->hWnd)           ||
-                     pti->MessageQueue->QF_flags & QF_ACTIVATIONCHANGE ||
+                     //pti->MessageQueue->QF_flags & QF_ACTIVATIONCHANGE || // See CORE-17338
                      capture_win != IntGetCapture() ) // Should not happen, but this is ReactOS...
                 {
                    ErrorExit = TRUE; // Do not wait on dead windows, now win test_capture_4 works.
index 9171d0f..85e91b5 100644 (file)
@@ -338,8 +338,11 @@ User32DefWindowProc(HWND hWnd,
             HMENU menu = GetSystemMenu(hWnd, FALSE);
             ERR("WM_POPUPSYSTEMMENU\n");
             if (menu)
+            {
+                SetForegroundWindow(hWnd);
                 TrackPopupMenu(menu, TPM_LEFTBUTTON|TPM_RIGHTBUTTON|TPM_SYSTEM_MENU,
                                LOWORD(lParam), HIWORD(lParam), 0, hWnd, NULL);
+            }
             return 0;
         }