X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fmenu.c;h=c66a1b0d711bc644a190a57e05dba4a42a77da52;hb=c0c06e3828981cacc96b27a87d7803f603241d15;hp=b29594d75434c2ac0c2c67acab579008691c8571;hpb=1045079482453424f8320de99639390e3020eb72;p=chaz%2Fopenbox diff --git a/openbox/menu.c b/openbox/menu.c index b29594d7..c66a1b0d 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -20,6 +20,8 @@ GList *menu_visible = NULL; #define ENTRY_EVENTMASK (EnterWindowMask | LeaveWindowMask | \ ButtonPressMask | ButtonReleaseMask) +void menu_control_show(ObMenu *self, int x, int y, ObClient *client); + static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, gpointer data) { @@ -35,7 +37,7 @@ void parse_menu_full(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, xmlNodePtr nact; gchar *id = NULL, *title = NULL, *label = NULL, *plugin; - ObMenu *menu = NULL, *parent; + ObMenu *menu = NULL, *parent = NULL; if (newmenu == TRUE) { if (!parse_attr_string("id", node, &id)) @@ -52,12 +54,12 @@ void parse_menu_full(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, data.parent = menu; if (plugin_open_reopen(plugin, i)) - parent = plugin_create(plugin, &data); + menu = plugin_create(plugin, &data); g_free(plugin); } else menu = menu_new(title, id, data ? *((ObMenu**)data) : NULL); - if (data) + if (data && menu) *((ObMenu**)data) = menu; } else { menu = (ObMenu *)data; @@ -78,9 +80,11 @@ void parse_menu_full(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, } else { parent = menu; parse_menu(i, doc, node, &parent); + } + + if (parent) menu_add_entry(menu, menu_entry_new_submenu(parent->label, parent)); - } } else if (!xmlStrcasecmp(node->name, (const xmlChar*) "item")) { @@ -104,8 +108,6 @@ parse_menu_fail: g_free(title); } -void menu_control_show(ObMenu *self, int x, int y, ObClient *client); - void menu_destroy_hash_key(ObMenu *menu) { g_free(menu); @@ -115,6 +117,8 @@ void menu_destroy_hash_value(ObMenu *self) { GList *it; + if (self->destroy) self->destroy(self); + for (it = self->entries; it; it = it->next) menu_entry_free(it->data); g_list_free(self->entries); @@ -215,7 +219,8 @@ ObMenu *menu_new_full(char *label, char *name, ObMenu *parent, menu_controller_show show, menu_controller_update update, menu_controller_selected selected, menu_controller_hide hide, - menu_controller_mouseover mouseover) + menu_controller_mouseover mouseover, + menu_controller_destroy destroy) { XSetWindowAttributes attrib; ObMenu *self; @@ -233,6 +238,7 @@ ObMenu *menu_new_full(char *label, char *name, ObMenu *parent, self->invalid = TRUE; /* default controllers */ + self->destroy = destroy; self->show = (show != NULL ? show : menu_show_full); self->hide = (hide != NULL ? hide : menu_hide); self->update = (update != NULL ? update : menu_render); @@ -513,15 +519,16 @@ void menu_control_mouseover(ObMenuEntry *self, gboolean enter) ob_rr_theme->bwidth - ob_rr_theme->menu_overlap; /* need to get the width. is this bad?*/ - self->parent->update(self->submenu); + self->submenu->update(self->submenu); a = screen_physical_area_monitor(self->parent->xin_area); - if (self->submenu->size.width + x >= a->x + a->width) { + if (self->submenu->size.width + x + ob_rr_theme->bwidth >= + 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->bwidth * 2 - ob_rr_theme->menu_overlap; x = a->x + a->width - self->submenu->size.width @@ -534,7 +541,8 @@ void menu_control_mouseover(ObMenuEntry *self, gboolean enter) } menu_show_full(self->submenu, x, - self->parent->location.y + self->y, + self->parent->location.y + self->y + + self->parent->title_h + ob_rr_theme->bwidth, self->parent->client); } self->hilite = TRUE;