]> Dogcows Code - chaz/openbox/commitdiff
add a func to find a menu entry from a submenu.
authorDana Jansens <danakj@orodu.net>
Tue, 22 Jul 2003 16:41:08 +0000 (16:41 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 22 Jul 2003 16:41:08 +0000 (16:41 +0000)
keep menu entries highlighted while they have their submenu open

openbox/menu.c

index ccf9df9238b1798b33780511cf32742825d90cf8..cd27e1fb3e54ec6d506ef01ea358e0f57f97fb07 100644 (file)
@@ -51,11 +51,10 @@ void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data,
     while (node) {
         if (!xmlStrcasecmp(node->name, (const xmlChar*) "menu")) {
             if (parse_attr_string("plugin", node, &plugin)) {
-                PluginMenuCreateData data = {
-                    .doc = doc,
-                    .node = node,
-                    .parent = menu
-                };
+                PluginMenuCreateData data;
+                data.doc = doc;
+                data.node = node;
+                data.parent = menu;
                 parent = plugin_create(plugin, &data);
                 g_free(plugin);
             } else {
@@ -393,6 +392,18 @@ ObMenuEntry *menu_find_entry(ObMenu *menu, Window win)
     return NULL;
 }
 
+ObMenuEntry *menu_find_entry_by_submenu(ObMenu *menu, ObMenu *submenu)
+{
+    GList *it;
+
+    for (it = menu->entries; it; it = it->next) {
+        ObMenuEntry *entry = it->data;
+        if (entry->submenu == submenu)
+            return entry;
+    }
+    return NULL;
+}
+
 ObMenuEntry *menu_find_entry_by_pos(ObMenu *menu, int x, int y)
 {
     if (x < 0 || x >= menu->size.width || y < 0 || y >= menu->size.height)
@@ -457,13 +468,18 @@ void menu_control_mouseover(ObMenuEntry *self, gboolean enter)
 {
     int x;
     Rect *a;
+    ObMenuEntry *e;
 
-    self->hilite = enter;
-  
     if (enter) {
        if (self->parent->open_submenu && self->submenu 
            != self->parent->open_submenu)
+        {
+            e = menu_find_entry_by_submenu(self->parent,
+                                           self->parent->open_submenu);
+            e->hilite = FALSE;
+            menu_entry_render(e);
            menu_hide(self->parent->open_submenu);
+        }
        
        if (self->submenu && self->parent->open_submenu != self->submenu) {
            self->parent->open_submenu = self->submenu;
@@ -489,6 +505,11 @@ void menu_control_mouseover(ObMenuEntry *self, gboolean enter)
                            self->parent->client);
        } 
     }
+
+    if (enter || !self->submenu ||
+        menu_find_entry_by_submenu(self->parent,
+                                   self->parent->open_submenu) != self)
+        self->hilite = enter;
 }
 
 ObMenuEntry *menu_control_keyboard_nav(ObMenuEntry *over, ObKey key)
This page took 0.026672 seconds and 4 git commands to generate.