]> Dogcows Code - chaz/openbox/blobdiff - openbox/menu.c
Some fixes and new bugs. Someone else can do the menus because it is
[chaz/openbox] / openbox / menu.c
index 1970984a9214f456bd132d102a146b7a5f567af4..00a2bc2b221ab4b44dda1d9e5a26772c9acd1fda 100644 (file)
@@ -142,8 +142,9 @@ void menu_entry_free(ObMenuEntry *self)
     RrAppearanceFree(self->a_item);
     RrAppearanceFree(self->a_disabled);
     RrAppearanceFree(self->a_hilite);
+    RrAppearanceFree(self->a_submenu);
     XDestroyWindow(ob_display, self->item);
-
+    XDestroyWindow(ob_display, self->submenu_pic);
     g_free(self);
 }
     
@@ -273,13 +274,17 @@ void menu_add_entry(ObMenu *menu, ObMenuEntry *entry)
 
     attrib.event_mask = ENTRY_EVENTMASK;
     entry->item = createWindow(menu->items, CWEventMask, &attrib);
+    entry->submenu_pic = createWindow(menu->items, CWEventMask, &attrib);
     XMapWindow(ob_display, entry->item);
+    XMapWindow(ob_display, entry->submenu_pic);
 
-    entry->a_item = entry->a_disabled = entry->a_hilite = NULL;
+    entry->a_item = entry->a_disabled = entry->a_hilite = entry->a_submenu
+        = NULL;
 
     menu->invalid = TRUE;
 
     g_hash_table_insert(window_map, &entry->item, menu);
+    g_hash_table_insert(window_map, &entry->submenu_pic, menu);
 }
 
 void menu_show(char *name, int x, int y, ObClient *client)
@@ -320,7 +325,7 @@ void menu_hide(ObMenu *self) {
         XUnmapWindow(ob_display, self->frame);
         self->shown = FALSE;
        if (self->open_submenu)
-           menu_hide(self->open_submenu);
+           self->open_submenu->hide(self->open_submenu);
        if (self->parent && self->parent->open_submenu == self) {
            self->parent->open_submenu = NULL;
         }
@@ -392,7 +397,8 @@ void menu_entry_fire(ObMenuEntry *self, unsigned int button, unsigned int x,
 {
     ObMenu *m;
 
-    if (button != 1) return;
+    /* ignore wheel scrolling */
+    if (button == 4 || button == 5) return;
 
     if (self->action) {
         self->action->data.any.c = self->parent->client;
@@ -401,7 +407,7 @@ void menu_entry_fire(ObMenuEntry *self, unsigned int button, unsigned int x,
         /* hide the whole thing */
         m = self->parent;
         while (m->parent) m = m->parent;
-        menu_hide(m);
+        m->hide(m);
     }
 }
 
@@ -434,7 +440,7 @@ void menu_control_show(ObMenu *self, int x, int y, ObClient *client)
         stacking_raise(MENU_AS_WINDOW(self));
        self->shown = TRUE;
     } else if (self->shown && self->open_submenu) {
-       menu_hide(self->open_submenu);
+       self->open_submenu->hide(self->open_submenu);
     }
 }
 
@@ -454,7 +460,7 @@ void menu_control_mouseover(ObMenuEntry *self, gboolean enter)
             e = (ObMenuEntry *) self->parent->over->data;
             e->hilite = FALSE;
             menu_entry_render(e);
-           menu_hide(self->parent->open_submenu);
+           self->parent->open_submenu->hide(self->parent->open_submenu);
         }
        
        if (self->submenu && self->parent->open_submenu != self->submenu) {
@@ -472,9 +478,21 @@ void menu_control_mouseover(ObMenuEntry *self, gboolean enter)
 
             a = screen_physical_area_monitor(self->parent->xin_area);
 
-           if (self->submenu->size.width + x >= a->x + a->width)
-               x = self->parent->location.x - self->submenu->size.width - 
-                   ob_rr_theme->bwidth + ob_rr_theme->menu_overlap;
+           if (self->submenu->size.width + x >= a->x + a->width) {
+                int newparentx = a->x + a->width
+                    - self->submenu->size.width
+                    - self->parent->size.width
+                    - ob_rr_theme->bwidth
+                    - ob_rr_theme->menu_overlap;
+                
+                x = a->x + a->width - self->submenu->size.width
+                    - ob_rr_theme->menu_overlap;
+                XWarpPointer(ob_display, None, None, 0, 0, 0, 0,
+                             newparentx - self->parent->location.x, 0);
+
+                menu_show_full(self->parent, newparentx,
+                               self->parent->location.y, self->parent->client);
+            }
            
            menu_show_full(self->submenu, x,
                           self->parent->location.y + self->y,
@@ -505,6 +523,9 @@ void menu_control_keyboard_nav(unsigned int key)
         obkey = OB_KEY_RIGHT;
     else if (key == ob_keycode(OB_KEY_LEFT)) /* users */
         obkey = OB_KEY_LEFT;
+    else if (key == ob_keycode(OB_KEY_RETURN))
+        obkey = OB_KEY_RETURN;
+
     
     if (current_menu == NULL)
         current_menu = menu_visible->data;
@@ -544,6 +565,7 @@ void menu_control_keyboard_nav(unsigned int key)
             return;
         e = (ObMenuEntry *)current_menu->over->data;
         if (e->submenu) {
+            current_menu->mouseover(e, TRUE);
             current_menu = e->submenu;
             current_menu->over = current_menu->entries;
             if (current_menu->over)
@@ -561,15 +583,15 @@ void menu_control_keyboard_nav(unsigned int key)
         current_menu->over = NULL;
         /* zero is enter */
         menu_entry_fire(e, 0, 0, 0);
-
     }
+        
     case OB_KEY_LEFT: {
         if (current_menu->over != NULL) {
             current_menu->mouseover(current_menu->over->data, FALSE);
             current_menu->over = NULL;
         }
         
-        menu_hide(current_menu);
+        current_menu->hide(current_menu);
 
         if (current_menu->parent)
             current_menu = current_menu->parent;
@@ -577,8 +599,8 @@ void menu_control_keyboard_nav(unsigned int key)
         break;
     }
     default:
-        if (current_menu)
-            menu_hide(current_menu);
+        ((ObMenu *)menu_visible->data)->hide(menu_visible->data);
+        current_menu = NULL;
     }
     return;
 }
This page took 0.024555 seconds and 4 git commands to generate.