]> Dogcows Code - chaz/openbox/blobdiff - openbox/menuframe.c
Use submenuShowDelay when navigating menus with the keyboard
[chaz/openbox] / openbox / menuframe.c
index 9e8c8918c83da20e94c2432cba22a2efa3d7fc60..3d2b4302c67efbec266bbe35202dcb890218d255 100644 (file)
@@ -1153,14 +1153,15 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
     ObMenuEntryFrame *old = self->selected;
     ObMenuFrame *oldchild = self->child;
     ObMenuEntryFrame *oldchild_entry = self->child_entry;
-    ObMenuEntryFrame *temp;
 
     /* if the user selected a separator, ignore it and reselect what we had
        selected before */
     if (entry && entry->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR)
         entry = old;
 
-    if (old == entry) return;
+    if (old == entry &&
+        (!old || old->entry->type != OB_MENU_ENTRY_TYPE_SUBMENU))
+        return;
 
     /* if the user left this menu but we have a submenu open, move the
        selection back to that submenu */
@@ -1187,34 +1188,38 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
         else if (oldchild_entry == old) {
             /* The open submenu was selected and is no longer, so hide the
                submenu */
-            if (!immediate && config_submenu_hide_delay) {
+            if (immediate || config_submenu_hide_delay == 0)
+                menu_frame_hide(oldchild);
+            else if (config_submenu_hide_delay > 0)
                 ob_main_loop_timeout_add(ob_main_loop,
                                          config_submenu_hide_delay * 1000,
                                          submenu_hide_timeout,
                                          oldchild, g_direct_equal,
                                          NULL);
-            }
-            else
-                menu_frame_hide(oldchild);
         }
     }
 
     if (self->selected) {
         menu_entry_frame_render(self->selected);
 
-        /* only show if the submenu isn't already showing */
-        if (oldchild_entry != self->selected &&
-            self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
-        {
-            if (config_submenu_show_delay && !immediate) {
-                /* initiate a new submenu open request */
-                ob_main_loop_timeout_add(ob_main_loop,
-                                         config_submenu_show_delay * 1000,
-                                         submenu_show_timeout,
-                                         self->selected, g_direct_equal,
-                                         NULL);
-            } else
-                menu_entry_frame_show_submenu(self->selected);
+        if (self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) {
+            /* only show if the submenu isn't already showing */
+            if (oldchild_entry != self->selected) {
+                if (immediate || config_submenu_hide_delay == 0)
+                    menu_entry_frame_show_submenu(self->selected);
+                else if (config_submenu_hide_delay > 0)
+                    ob_main_loop_timeout_add(ob_main_loop,
+                                             config_submenu_show_delay * 1000,
+                                             submenu_show_timeout,
+                                             self->selected, g_direct_equal,
+                                             NULL);
+            }
+            /* hide the grandchildren of this menu. and move the cursor to
+               the current menu */
+            else if (immediate && self->child && self->child->child) {
+                menu_frame_hide(self->child->child);
+                menu_frame_select(self->child, NULL, TRUE);
+            }
         }
     }
 }
@@ -1284,7 +1289,7 @@ void menu_frame_select_previous(ObMenuFrame *self)
             }
         }
     }
-    menu_frame_select(self, it ? it->data : NULL, TRUE);
+    menu_frame_select(self, it ? it->data : NULL, FALSE);
 }
 
 void menu_frame_select_next(ObMenuFrame *self)
@@ -1309,5 +1314,5 @@ void menu_frame_select_next(ObMenuFrame *self)
             }
         }
     }
-    menu_frame_select(self, it ? it->data : NULL, TRUE);
+    menu_frame_select(self, it ? it->data : NULL, FALSE);
 }
This page took 0.023449 seconds and 4 git commands to generate.