user32: Make sure we set menu capture to a window that is visible.
authorAlexandre Julliard <julliard@winehq.org>
Mon, 24 Mar 2008 16:59:58 +0000 (17:59 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Mon, 24 Mar 2008 16:59:58 +0000 (17:59 +0100)
dlls/user32/menu.c

index 17b2179c0347e24ab51a0e8d2865a3aca69f2e21..2efc415bb45af243c5e3d274d1025934f4853c22 100644 (file)
@@ -2963,6 +2963,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y,
     INT executedMenuId = -1;
     MTRACKER mt;
     BOOL enterIdleSent = FALSE;
+    HWND capture_win;
 
     mt.trackFlags = 0;
     mt.hCurrentMenu = hmenu;
@@ -2991,7 +2992,9 @@ static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y,
 
     if (wFlags & TF_ENDMENU) fEndMenu = TRUE;
 
-    set_capture_window( mt.hOwnerWnd, GUI_INMENUMODE, NULL );
+    /* owner may not be visible when tracking a popup, so use the menu itself */
+    capture_win = (wFlags & TPM_POPUPMENU) ? menu->hWnd : mt.hOwnerWnd;
+    set_capture_window( capture_win, GUI_INMENUMODE, NULL );
 
     while (!fEndMenu)
     {