Thomas Kho : user: Fix behavior when selecting disabled menu items.

Alexandre Julliard julliard at wine.codeweavers.com
Mon May 8 09:05:45 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: b8338605794c357eb7c1d319f3eec62a2efff3ea
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=b8338605794c357eb7c1d319f3eec62a2efff3ea

Author: Thomas Kho <tkho at ucla.edu>
Date:   Wed Apr 26 17:44:56 2006 -0700

user: Fix behavior when selecting disabled menu items.

---

 dlls/user/menu.c       |   16 +++++++++++-----
 dlls/user/tests/menu.c |    6 +++---
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/dlls/user/menu.c b/dlls/user/menu.c
index 11a02d8..8c6c315 100644
--- a/dlls/user/menu.c
+++ b/dlls/user/menu.c
@@ -2407,7 +2407,7 @@ static HMENU MENU_PtMenu( HMENU hMenu, P
  *
  * Execute a menu item (for instance when user pressed Enter).
  * Return the wID of the executed item. Otherwise, -1 indicating
- * that no menu item was executed;
+ * that no menu item was executed, -2 if a popup is shown;
  * Have to receive the flags for the TrackPopupMenu options to avoid
  * sending unwanted message.
  *
@@ -2444,7 +2444,10 @@ static INT MENU_ExecFocusedItem( MTRACKE
 	}
     }
     else
+    {
 	pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hMenu, TRUE, wFlags);
+	return -2;
+    }
 
     return -1;
 }
@@ -2538,7 +2541,10 @@ static INT MENU_ButtonUp( MTRACKER* pmt,
 	if( item && (ptmenu->FocusedItem == id ))
 	{
 	    if( !(item->fType & MF_POPUP) )
-		return MENU_ExecFocusedItem( pmt, hPtMenu, wFlags);
+	    {
+	        INT executedMenuId = MENU_ExecFocusedItem( pmt, hPtMenu, wFlags);
+	        return (executedMenuId < 0) ? -1 : executedMenuId;
+	    }
 
 	    /* If we are dealing with the top-level menu            */
 	    /* and this is a click on an already "popped" item:     */
@@ -3113,7 +3119,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu,
 		    if (msg.wParam == '\r' || msg.wParam == ' ')
 		    {
                         executedMenuId = MENU_ExecFocusedItem(&mt,mt.hCurrentMenu, wFlags);
-                        fEndMenu = (executedMenuId != -1);
+                        fEndMenu = (executedMenuId != -2);
 
 			break;
 		    }
@@ -3131,7 +3137,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu,
 			MENU_SelectItem( mt.hOwnerWnd, mt.hCurrentMenu, pos,
                                 TRUE, 0 );
                         executedMenuId = MENU_ExecFocusedItem(&mt,mt.hCurrentMenu, wFlags);
-                        fEndMenu = (executedMenuId != -1);
+                        fEndMenu = (executedMenuId != -2);
 		    }
 		}
 		break;
@@ -3182,7 +3188,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu,
 
     /* The return value is only used by TrackPopupMenu */
     if (!(wFlags & TPM_RETURNCMD)) return TRUE;
-    if (executedMenuId == -1) executedMenuId = 0;
+    if (executedMenuId < 0) executedMenuId = 0;
     return executedMenuId;
 }
 
diff --git a/dlls/user/tests/menu.c b/dlls/user/tests/menu.c
index faa5892..07ad324 100644
--- a/dlls/user/tests/menu.c
+++ b/dlls/user/tests/menu.c
@@ -1509,7 +1509,7 @@ static struct menu_mouse_tests_s {
     { INPUT_KEYBOARD, {{0}}, {VK_LMENU, 0}, TRUE, FALSE }, /* test 0 */
     { INPUT_KEYBOARD, {{0}}, {VK_ESCAPE, 0}, FALSE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {VK_LMENU, 0}, TRUE, FALSE },
-    { INPUT_KEYBOARD, {{0}}, {'D', 0}, FALSE, TRUE },
+    { INPUT_KEYBOARD, {{0}}, {'D', 0}, FALSE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {VK_LMENU, 0}, TRUE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {'E', 0}, FALSE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {VK_LMENU, 'M', 0}, TRUE, FALSE },
@@ -1517,11 +1517,11 @@ static struct menu_mouse_tests_s {
     { INPUT_KEYBOARD, {{0}}, {VK_LMENU, 'M', VK_ESCAPE, 0}, TRUE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {VK_ESCAPE, 0}, FALSE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {VK_LMENU, 'M', 0}, TRUE, FALSE },
-    { INPUT_KEYBOARD, {{0}}, {'D', 0}, FALSE, TRUE },
+    { INPUT_KEYBOARD, {{0}}, {'D', 0}, FALSE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {VK_LMENU, 'M', 0}, TRUE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {'E', 0}, FALSE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {VK_LMENU, 'M', 'P', 0}, TRUE, FALSE },
-    { INPUT_KEYBOARD, {{0}}, {'D', 0}, FALSE, TRUE },
+    { INPUT_KEYBOARD, {{0}}, {'D', 0}, FALSE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {VK_LMENU, 'M', 'P', 0}, TRUE, FALSE },
     { INPUT_KEYBOARD, {{0}}, {'E', 0}, FALSE, FALSE },
 




More information about the wine-cvs mailing list