]> Dogcows Code - chaz/openbox/blobdiff - openbox/menu.c
make key grabbing per window instead of always root
[chaz/openbox] / openbox / menu.c
index 611a53bc897d1fddb0aadd0929a96b59122e1d87..2af1a01f2f791e78f91ae273c84939193109ebed 100644 (file)
@@ -7,8 +7,7 @@
 #include "geom.h"
 #include "plugin.h"
 
-static GHashTable *menu_hash = NULL;
-GHashTable *menu_map = NULL;
+GHashTable *menu_hash = NULL;
 
 #define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask | \
                         LeaveWindowMask)
@@ -18,9 +17,9 @@ GHashTable *menu_map = NULL;
 
 void menu_control_show(Menu *self, int x, int y, Client *client);
 
-void menu_destroy_hash_key(gpointer data)
+void menu_destroy_hash_key(Menu *menu)
 {
-    g_free(data);
+    g_free(menu);
 }
 
 void menu_destroy_hash_value(Menu *self)
@@ -34,9 +33,9 @@ void menu_destroy_hash_value(Menu *self)
     g_free(self->label);
     g_free(self->name);
 
-    g_hash_table_remove(menu_map, &self->title);
-    g_hash_table_remove(menu_map, &self->frame);
-    g_hash_table_remove(menu_map, &self->items);
+    g_hash_table_remove(window_map, &self->title);
+    g_hash_table_remove(window_map, &self->frame);
+    g_hash_table_remove(window_map, &self->items);
 
     stacking_remove(self);
 
@@ -53,7 +52,7 @@ void menu_entry_free(MenuEntry *self)
     g_free(self->label);
     action_free(self->action);
 
-    g_hash_table_remove(menu_map, &self->item);
+    g_hash_table_remove(window_map, &self->item);
 
     appearance_free(self->a_item);
     appearance_free(self->a_disabled);
@@ -73,9 +72,8 @@ void menu_startup()
     menu_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
                                       menu_destroy_hash_key,
                                       (GDestroyNotify)menu_destroy_hash_value);
-    menu_map = g_hash_table_new(g_int_hash, g_int_equal);
 
-    m = menu_new(NULL, "root", NULL);
+    m = menu_new("sex menu", "root", NULL);
  
     a = action_from_string("execute");
     a->data.execute.path = g_strdup("xterm");
@@ -85,6 +83,8 @@ void menu_startup()
     menu_add_entry(m, menu_entry_new_separator("--"));
     a = action_from_string("exit");
     menu_add_entry(m, menu_entry_new("exit", a));
+
+    /*
     s = menu_new("subsex menu", "submenu", m);
     a = action_from_string("execute");
     a->data.execute.path = g_strdup("xclock");
@@ -92,14 +92,6 @@ void menu_startup()
 
     menu_add_entry(m, menu_entry_new_submenu("subz", s));
 
-    /*
-    t = (Menu *)plugin_create("timed_menu");
-    a = action_from_string("execute");
-    a->data.execute.path = g_strdup("xeyes");
-    menu_add_entry(t, menu_entry_new("xeyes", a));
-    menu_add_entry(m, menu_entry_new_submenu("timed", t));
-    */
-    
     s = menu_new("empty", "chub", m);
     menu_add_entry(m, menu_entry_new_submenu("empty", s));
 
@@ -121,23 +113,12 @@ void menu_startup()
     menu_add_entry(s, menu_entry_new("exit", a));
 
     menu_add_entry(m, menu_entry_new_submenu("long", s));
-
-    m = menu_new(NULL, "client", NULL);
-    a = action_from_string("iconify");
-    menu_add_entry(m, menu_entry_new("iconify", a));
-    a = action_from_string("toggleshade");
-    menu_add_entry(m, menu_entry_new("(un)shade", a));
-    a = action_from_string("togglemaximizefull");
-    menu_add_entry(m, menu_entry_new("(un)maximize", a));
-    a = action_from_string("close");
-    menu_add_entry(m, menu_entry_new("close", a));
-
+    */
 }
 
 void menu_shutdown()
 {
     g_hash_table_destroy(menu_hash);
-    g_hash_table_destroy(menu_map);
 }
 
 static Window createWindow(Window parent, unsigned long mask,
@@ -195,12 +176,13 @@ Menu *menu_new_full(char *label, char *name, Menu *parent,
     self->a_title = appearance_copy(theme_a_menu_title);
     self->a_items = appearance_copy(theme_a_menu);
 
-    g_hash_table_insert(menu_map, &self->frame, self);
-    g_hash_table_insert(menu_map, &self->title, self);
-    g_hash_table_insert(menu_map, &self->items, self);
+    g_hash_table_insert(window_map, &self->frame, self);
+    g_hash_table_insert(window_map, &self->title, self);
+    g_hash_table_insert(window_map, &self->items, self);
     g_hash_table_insert(menu_hash, g_strdup(name), self);
 
-    stacking_add(self);
+    stacking_add(MENU_AS_WINDOW(self));
+    stacking_raise(MENU_AS_WINDOW(self));
 
     return self;
 }
@@ -258,7 +240,7 @@ void menu_add_entry(Menu *menu, MenuEntry *entry)
 
     menu->invalid = TRUE;
 
-    g_hash_table_insert(menu_map, &entry->item, menu);
+    g_hash_table_insert(window_map, &entry->item, menu);
 }
 
 void menu_show(char *name, int x, int y, Client *client)
@@ -290,7 +272,6 @@ void menu_show_full(Menu *self, int x, int y, Client *client)
     }
 }
 
-
 void menu_hide(Menu *self) {
     if (self->shown) {
         XUnmapWindow(ob_display, self->frame);
@@ -311,6 +292,7 @@ void menu_clear(Menu *self) {
        menu_entry_free(entry);
     }
     self->entries = NULL;
+    self->invalid = TRUE;
 }
 
 
@@ -356,9 +338,6 @@ void menu_control_show(Menu *self, int x, int y, Client *client) {
              MIN(y, screen_physical_size.height - self->size.height));
 
     if (!self->shown) {
-        /* XXX gotta add to the stacking list first!
-           stacking_raise(MENU_AS_WINDOW(self));
-        */
        XMapWindow(ob_display, self->frame);
         stacking_raise(MENU_AS_WINDOW(self));
        self->shown = TRUE;
@@ -394,7 +373,8 @@ void menu_control_mouseover(MenuEntry *self, gboolean enter) {
                    theme_bevel;
            
            menu_show_full(self->submenu, x,
-                          self->parent->location.y + self->y, NULL);
+                          self->parent->location.y + self->y,
+                           self->parent->client);
        } 
     }
 }
This page took 0.026643 seconds and 4 git commands to generate.