X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fmenu.c;h=98f5fed14f44c04248d4c0742a4bbf6bbfc57fa5;hb=32390c6b6dceeb72e4e4ceb0e79ba4d8c8ede9a3;hp=74c234827ad945ffb0b28b979ac1a23a11b0e8b7;hpb=03d42b5d8253ad2de94df20b12b9fb22ce51eb3d;p=chaz%2Fopenbox diff --git a/openbox/menu.c b/openbox/menu.c index 74c23482..98f5fed1 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -8,7 +8,6 @@ #include "plugin.h" static GHashTable *menu_hash = NULL; -GHashTable *menu_map = NULL; #define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask | \ LeaveWindowMask) @@ -34,9 +33,11 @@ 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); appearance_free(self->a_title); XDestroyWindow(ob_display, self->title); @@ -51,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); @@ -71,7 +72,6 @@ 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); @@ -91,11 +91,18 @@ 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)); + if (t) { + 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)); + } + t = (Menu *)plugin_create("fifo_menu"); + if (t) { + menu_add_entry(m, menu_entry_new_submenu("fifo", t)); + } + s = menu_new("empty", "chub", m); menu_add_entry(m, menu_entry_new_submenu("empty", s)); @@ -117,8 +124,8 @@ 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("client menu", "client", NULL); + + 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"); @@ -133,7 +140,6 @@ void menu_startup() void menu_shutdown() { g_hash_table_destroy(menu_hash); - g_hash_table_destroy(menu_map); } static Window createWindow(Window parent, unsigned long mask, @@ -152,6 +158,7 @@ Menu *menu_new_full(char *label, char *name, Menu *parent, Menu *self; self = g_new0(Menu, 1); + self->obwin.type = Window_Menu; self->label = g_strdup(label); self->name = g_strdup(name); self->parent = parent; @@ -190,10 +197,14 @@ 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(MENU_AS_WINDOW(self)); + stacking_raise(MENU_AS_WINDOW(self)); + return self; } @@ -234,7 +245,9 @@ void menu_add_entry(Menu *menu, MenuEntry *entry) { XSetWindowAttributes attrib; - g_assert(menu != NULL && entry != NULL && entry->item == None); + g_assert(menu != NULL); + g_assert(entry != NULL); + g_assert(entry->item == None); menu->entries = g_list_append(menu->entries, entry); entry->parent = menu; @@ -248,7 +261,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) @@ -301,6 +314,7 @@ void menu_clear(Menu *self) { menu_entry_free(entry); } self->entries = NULL; + self->invalid = TRUE; } @@ -346,8 +360,8 @@ void menu_control_show(Menu *self, int x, int y, Client *client) { MIN(y, screen_physical_size.height - self->size.height)); if (!self->shown) { - stacking_raise_internal(self->frame); XMapWindow(ob_display, self->frame); + stacking_raise(MENU_AS_WINDOW(self)); self->shown = TRUE; } else if (self->shown && self->open_submenu) { menu_hide(self->open_submenu);