user: Fix behavior when selecting disabled menu items

tkho at ucla.edu tkho at ucla.edu
Wed Apr 26 19:44:56 CDT 2006


Hello,

This is patch #2 of 3 of menu bug fixes. This patch changes the behavior of
selecting disabled menu items. The menu should close if a disabled menu item is
selected via keyboard and stay open if the menu item is selected via mouse.
Wine currently keeps the menu open in both cases.

Thanks,

Thomas Kho

2006-04-26 Thomas Kho <tkho at ucla.edu>

	* dlls/user/tests/menu.c:
	user: Fix behavior when selecting disabled menu items

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

Signed-off-by: Thomas Kho <tkho at ucla.edu>
diff -aur ../2/dlls/user/menu.c ./dlls/user/menu.c
--- ../2/dlls/user/menu.c	2006-04-26 17:16:26.000000000 -0700
+++ ./dlls/user/menu.c	2006-04-26 17:16:48.000000000 -0700
@@ -2407,7 +2407,7 @@
  *
  * 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 @@
 	}
     }
     else
+    {
 	pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hMenu, TRUE, wFlags);
+	return -2;
+    }
 
     return -1;
 }
@@ -2538,7 +2541,10 @@
 	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 @@
 		    if (msg.wParam == '\r' || msg.wParam == ' ')
 		    {
                         executedMenuId = MENU_ExecFocusedItem(&mt,mt.hCurrentMenu, wFlags);
-                        fEndMenu = (executedMenuId != -1);
+                        fEndMenu = (executedMenuId != -2);
 
 			break;
 		    }
@@ -3131,7 +3137,7 @@
 			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 @@
 
     /* 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 -aur ../2/dlls/user/tests/menu.c ./dlls/user/tests/menu.c
--- ../2/dlls/user/tests/menu.c	2006-04-26 17:16:36.000000000 -0700
+++ ./dlls/user/tests/menu.c	2006-04-26 17:16:49.000000000 -0700
@@ -1509,7 +1509,7 @@
     { 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 @@
     { 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-patches mailing list