static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
ObMenuFrame *frame);
static void menu_entry_frame_free(ObMenuEntryFrame *self);
-static void menu_frame_render(ObMenuFrame *self);
static void menu_frame_update(ObMenuFrame *self);
static gboolean menu_entry_frame_submenu_timeout(gpointer data);
return h;
}
-static void menu_frame_render(ObMenuFrame *self)
+void menu_frame_render(ObMenuFrame *self)
{
gint w = 0, h = 0;
gint tw, th; /* temps */
if (e->entry->data.separator.label != NULL) {
e->a_text_title->texture[0].data.text.string =
e->entry->data.separator.label;
- tw = RrMinWidth(text_a);
+ tw = RrMinWidth(e->a_text_title);
tw = MIN(tw, MAX_MENU_WIDTH);
th = ob_rr_theme->menu_title_height +
(ob_rr_theme->mbwidth - PADDING) *2;
fit = n;
}
- menu_frame_render(self);
+ /* * make the menu fit on the screen */
- /* make the menu fit on the screen. at most we call render twice, at least
- not like n times or sometime */
+ /* calculate the height of the menu */
+ h = 0;
+ for (fit = self->entries; fit; fit = g_list_next(fit))
+ h += menu_entry_frame_get_height(fit->data,
+ fit == self->entries,
+ g_list_next(fit) == NULL);
+ /* add the border at the top and bottom */
+ h += ob_rr_theme->mbwidth * 2;
a = screen_physical_area_monitor(self->monitor);
- h = self->area.height;
if (h > a->height) {
GList *flast, *tmp;
menu_entry_frame_free(tmp->data);
self->entries = g_list_delete_link(self->entries, tmp);
- menu_frame_render(self);
-
/* only the first one that we see is the last entry in the menu */
last_entry = FALSE;
};
/* add our More... entry to the frame */
self->entries = g_list_append(self->entries, more_frame);
}
-
- /* render again */
- menu_frame_render(self);
}
+
+ menu_frame_render(self);
}
static gboolean menu_frame_is_visible(ObMenuFrame *self)
menu_frame_visible = g_list_prepend(menu_frame_visible, self);
+ if (self->menu->show_func)
+ self->menu->show_func(self, self->menu->data);
+
return TRUE;
}
if (!it)
return;
+ if (self->menu->hide_func)
+ self->menu->hide_func(self, self->menu->data);
+
if (self->child)
menu_frame_hide(self->child);
gpointer data = self->frame->menu->data;
GSList *acts = self->entry->data.normal.actions;
ObClient *client = self->frame->client;
+ ObMenuFrame *frame = self->frame;
/* release grabs before executing the shit */
- if (!(state & ControlMask))
+ if (!(state & ControlMask)) {
menu_frame_hide_all();
+ frame = NULL;
+ }
if (func)
- func(entry, state, data, time);
+ func(entry, frame, client, state, data, time);
else
action_run(acts, client, state, time);
}