[PATCH] [Bug2520] Skip system menu entries when using keyboard

Jason Edmeades jason.edmeades at googlemail.com
Mon Aug 6 16:51:01 CDT 2007


If you press alt, then left or right, under wine we walk through the
menu items as per windows. If there is a maximized MDI child, then
appended to the normal menu, right justified are the normal minimize
restore and close buttons. Under wine, we highlight them when
pressing left or right as if they were menu items. Under windows these
are skipped.

This can be seen with winefile for example
---
 dlls/user32/menu.c |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 1660c20..2f57779 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -2668,9 +2668,39 @@ static void MENU_SetCapture( HWND hwnd )
 static LRESULT MENU_DoNextMenu( MTRACKER* pmt, UINT vk )
 {
     POPUPMENU *menu = MENU_GetMenu( pmt->hTopMenu );
+    BOOL atEnd = FALSE;
 
-    if( (vk == VK_LEFT &&  menu->FocusedItem == 0 ) ||
-        (vk == VK_RIGHT && menu->FocusedItem == menu->nItems - 1))
+    /* When skipping left, we need to do something special after the
+       first menu.                                                  */
+    if (vk == VK_LEFT && menu->FocusedItem == 0)
+    {
+        atEnd = TRUE;
+    }
+    /* When skipping right, for the non-system menu, we need to
+       handle the last non-special menu item (ie skip any window
+       icons such as MDI maximize, restore or close)             */
+    else if ((vk == VK_RIGHT) && !IS_SYSTEM_MENU(menu))
+    {
+        int i = menu->FocusedItem + 1;
+        while (i < (menu->nItems - 1)) {
+            if ((menu->items[i].wID >= SC_SIZE &&
+                 menu->items[i].wID <= SC_RESTORE)) {
+                i++;
+            } else break;
+        }
+        if (i == (menu->nItems - 1)) {
+            atEnd = TRUE;
+        }
+    }
+    /* When skipping right, we need to cater for the system menu */
+    else if ((vk == VK_RIGHT) && IS_SYSTEM_MENU(menu))
+    {
+        if (menu->FocusedItem == (menu->nItems - 1)) {
+            atEnd = TRUE;
+        }
+    }
+
+    if( atEnd )
     {
         MDINEXTMENU next_menu;
 	HMENU hNewMenu;
@@ -2699,6 +2729,12 @@ static LRESULT MENU_DoNextMenu( MTRACKER* pmt, UINT vk )
 	        {
 		    menu = MENU_GetMenu( hNewMenu );
 		    id = menu->nItems - 1;
+
+                    /* Skip backwards over any system predefined icons,
+                       eg. MDI close, restore etc icons                 */
+                    while ((id > 0) &&
+                           (menu->items[id].wID >= SC_SIZE &&
+                            menu->items[id].wID <= SC_RESTORE)) id--;
 	        }
 	    }
 	    else if (style & WS_SYSMENU )
-- 
1.5.0




More information about the wine-patches mailing list