X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=openbox%2Fmenuframe.c;h=8ffd27ad8b7618f33f6ccbcc8201fa8f73e5325d;hb=2c263fc8236afdd4dcf0a89d4defb1736cc3700b;hp=832f49af0ff63fbafc9ab75f90e815a647780e78;hpb=ffba11aeb059bef0b4876eb6aad2a8a24e2db6f1;p=chaz%2Fopenbox diff --git a/openbox/menuframe.c b/openbox/menuframe.c index 832f49af..8ffd27ad 100644 --- a/openbox/menuframe.c +++ b/openbox/menuframe.c @@ -170,6 +170,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) { RrAppearance *item_a, *text_a; gint th; /* temp */ + ObMenu *sub; item_a = ((self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && !self->entry->data.normal.enabled) ? @@ -205,8 +206,8 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self) text_a->texture[0].data.text.string = self->entry->data.normal.label; break; case OB_MENU_ENTRY_TYPE_SUBMENU: - text_a->texture[0].data.text.string = - self->entry->data.submenu.submenu->title; + sub = self->entry->data.submenu.submenu; + text_a->texture[0].data.text.string = sub ? sub->title : ""; break; case OB_MENU_ENTRY_TYPE_SEPARATOR: break; @@ -265,6 +266,7 @@ static void menu_frame_render(ObMenuFrame *self) gint tw, th; /* temps */ GList *it; gboolean has_icon = FALSE, has_bullet = FALSE; + ObMenu *sub; XSetWindowBorderWidth(ob_display, self->window, ob_rr_theme->bwidth); XSetWindowBorder(ob_display, self->window, @@ -315,8 +317,8 @@ static void menu_frame_render(ObMenuFrame *self) /* XXX has_icon = TRUE; */ break; case OB_MENU_ENTRY_TYPE_SUBMENU: - text_a->texture[0].data.text.string = - e->entry->data.submenu.submenu->title; + sub = e->entry->data.submenu.submenu; + text_a->texture[0].data.text.string = sub ? sub->title : ""; RrMinsize(text_a, &tw, &th); has_bullet = TRUE; @@ -344,8 +346,10 @@ static void menu_frame_render(ObMenuFrame *self) } if (!w) w = 10; - if (!allitems_h) allitems_h = 3; - if (!h) h = 3; + if (!allitems_h) { + allitems_h = 3; + h += 3; + } XResizeWindow(ob_display, self->window, w, h); XResizeWindow(ob_display, self->items, w, allitems_h); @@ -376,6 +380,8 @@ static void menu_frame_update(ObMenuFrame *self) { GList *mit, *fit; + menu_find_submenus(self->menu); + self->selected = NULL; for (mit = self->menu->entries, fit = self->entries; mit && fit; @@ -536,6 +542,8 @@ void menu_entry_frame_show_submenu(ObMenuEntryFrame *self) { ObMenuFrame *f; + if (!self->entry->data.submenu.submenu) return; + f = menu_frame_new(self->entry->data.submenu.submenu, self->frame->client); menu_frame_move(f, @@ -546,20 +554,24 @@ void menu_entry_frame_show_submenu(ObMenuEntryFrame *self) menu_frame_show(f, self->frame); } -void menu_entry_frame_execute(ObMenuEntryFrame *self) +void menu_entry_frame_execute(ObMenuEntryFrame *self, gboolean hide) { if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) { - GSList *it; - /* release grabs before executing the shit */ menu_frame_hide_all(); - for (it = self->entry->data.normal.actions; it; - it = g_slist_next(it)) - { - ObAction *act = it->data; - act->data.any.c = self->frame->client; - act->func(&act->data); + if (self->frame->menu->execute_func) + self->frame->menu->execute_func(self, self->frame->menu->data); + else { + GSList *it; + + for (it = self->entry->data.normal.actions; it; + it = g_slist_next(it)) + { + ObAction *act = it->data; + act->data.any.c = self->frame->client; + act->func(&act->data); + } } } }