1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 menuframe.c for the Openbox window manager
4 Copyright (c) 2003 Ben Jansens
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 See the COPYING file for a copy of the GNU General Public License.
19 #include "menuframe.h"
25 #include "render/theme.h"
28 #define SEPARATOR_HEIGHT 3
29 #define MAX_MENU_WIDTH 400
31 #define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask |\
33 #define TITLE_EVENTMASK (ButtonPressMask | ButtonMotionMask)
34 #define ENTRY_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
35 ButtonPressMask | ButtonReleaseMask)
37 GList *menu_frame_visible;
39 static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
41 static void menu_entry_frame_free(ObMenuEntryFrame *self);
42 static void menu_frame_render(ObMenuFrame *self);
43 static void menu_frame_update(ObMenuFrame *self);
45 static Window createWindow(Window parent, gulong mask,
46 XSetWindowAttributes *attrib)
48 return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0,
49 RrDepth(ob_rr_inst), InputOutput,
50 RrVisual(ob_rr_inst), mask, attrib);
53 ObMenuFrame* menu_frame_new(ObMenu *menu, ObClient *client)
56 XSetWindowAttributes attr;
58 self = g_new0(ObMenuFrame, 1);
59 self->type = Window_Menu;
61 self->selected = NULL;
62 self->show_title = TRUE;
63 self->client = client;
65 attr.event_mask = FRAME_EVENTMASK;
66 self->window = createWindow(RootWindow(ob_display, ob_screen),
68 attr.event_mask = TITLE_EVENTMASK;
69 self->title = createWindow(self->window, CWEventMask, &attr);
70 self->items = createWindow(self->window, 0, NULL);
72 XMapWindow(ob_display, self->items);
74 self->a_title = RrAppearanceCopy(ob_rr_theme->a_menu_title);
75 self->a_items = RrAppearanceCopy(ob_rr_theme->a_menu);
77 stacking_add(MENU_AS_WINDOW(self));
82 void menu_frame_free(ObMenuFrame *self)
85 while (self->entries) {
86 menu_entry_frame_free(self->entries->data);
87 self->entries = g_list_delete_link(self->entries, self->entries);
90 stacking_remove(MENU_AS_WINDOW(self));
92 XDestroyWindow(ob_display, self->items);
93 XDestroyWindow(ob_display, self->title);
94 XDestroyWindow(ob_display, self->window);
96 RrAppearanceFree(self->a_items);
97 RrAppearanceFree(self->a_title);
103 static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
106 ObMenuEntryFrame *self;
107 XSetWindowAttributes attr;
109 self = g_new0(ObMenuEntryFrame, 1);
113 attr.event_mask = ENTRY_EVENTMASK;
114 self->window = createWindow(self->frame->items, CWEventMask, &attr);
115 self->text = createWindow(self->window, 0, NULL);
116 if (entry->type != OB_MENU_ENTRY_TYPE_SEPARATOR) {
117 self->icon = createWindow(self->window, 0, NULL);
118 self->bullet = createWindow(self->window, 0, NULL);
121 XMapWindow(ob_display, self->window);
122 XMapWindow(ob_display, self->text);
124 self->a_normal = RrAppearanceCopy(ob_rr_theme->a_menu_normal);
125 self->a_disabled = RrAppearanceCopy(ob_rr_theme->a_menu_disabled);
126 self->a_selected = RrAppearanceCopy(ob_rr_theme->a_menu_selected);
128 if (entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR) {
129 self->a_separator = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
130 self->a_separator->texture[0].type = RR_TEXTURE_LINE_ART;
132 self->a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
133 self->a_icon->texture[0].type = RR_TEXTURE_RGBA;
134 self->a_mask = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
135 self->a_mask->texture[0].type = RR_TEXTURE_MASK;
136 self->a_bullet_normal =
137 RrAppearanceCopy(ob_rr_theme->a_menu_bullet_normal);
138 self->a_bullet_selected =
139 RrAppearanceCopy(ob_rr_theme->a_menu_bullet_selected);
142 self->a_text_normal =
143 RrAppearanceCopy(ob_rr_theme->a_menu_text_normal);
144 self->a_text_disabled =
145 RrAppearanceCopy(ob_rr_theme->a_menu_text_disabled);
146 self->a_text_selected =
147 RrAppearanceCopy(ob_rr_theme->a_menu_text_selected);
152 static void menu_entry_frame_free(ObMenuEntryFrame *self)
155 XDestroyWindow(ob_display, self->text);
156 XDestroyWindow(ob_display, self->window);
157 if (self->entry->type != OB_MENU_ENTRY_TYPE_SEPARATOR) {
158 XDestroyWindow(ob_display, self->icon);
159 XDestroyWindow(ob_display, self->bullet);
162 RrAppearanceFree(self->a_normal);
163 RrAppearanceFree(self->a_disabled);
164 RrAppearanceFree(self->a_selected);
166 RrAppearanceFree(self->a_separator);
167 RrAppearanceFree(self->a_icon);
168 RrAppearanceFree(self->a_mask);
169 RrAppearanceFree(self->a_text_normal);
170 RrAppearanceFree(self->a_text_disabled);
171 RrAppearanceFree(self->a_text_selected);
172 RrAppearanceFree(self->a_bullet_normal);
173 RrAppearanceFree(self->a_bullet_selected);
179 void menu_frame_move(ObMenuFrame *self, gint x, gint y)
181 RECT_SET_POINT(self->area, x, y);
182 XMoveWindow(ob_display, self->window, self->area.x, self->area.y);
185 void menu_frame_move_on_screen(ObMenuFrame *self)
192 for (i = 0; i < screen_num_monitors; ++i) {
193 a = screen_physical_area_monitor(i);
194 if (RECT_INTERSECTS_RECT(*a, self->area))
197 if (!a) a = screen_physical_area_monitor(0);
199 half = g_list_length(self->entries) / 2;
200 pos = g_list_index(self->entries, self->selected);
202 /* if in the bottom half then check this shit first, will keep the bottom
203 edge of the menu visible */
205 dx = MAX(dx, a->x - self->area.x);
206 dy = MAX(dy, a->y - self->area.y);
208 dx = MIN(dx, (a->x + a->width) - (self->area.x + self->area.width));
209 dy = MIN(dy, (a->y + a->height) - (self->area.y + self->area.height));
210 /* if in the top half then check this shit last, will keep the top
211 edge of the menu visible */
213 dx = MAX(dx, a->x - self->area.x);
214 dy = MAX(dy, a->y - self->area.y);
220 /* move the current menu frame to fit, but dont touch parents yet */
221 menu_frame_move(self, self->area.x + dx, self->area.y + dy);
222 if (!config_menu_xorstyle)
223 dy = 0; /* if we want to be like xor, move parents in y- *
224 * and x-direction, otherwise just in x-dir */
225 for (f = self->parent; f; f = f->parent)
226 menu_frame_move(f, f->area.x + dx, f->area.y + dy);
227 for (f = self->child; f; f = f->child)
228 menu_frame_move(f, f->area.x + dx, f->area.y + dy);
229 if (config_menu_warppointer)
230 XWarpPointer(ob_display, None, None, 0, 0, 0, 0, dx, dy);
234 static void menu_entry_frame_render(ObMenuEntryFrame *self)
236 RrAppearance *item_a, *text_a;
239 ObMenuFrame *frame = self->frame;
241 item_a = ((self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
242 !self->entry->data.normal.enabled) ?
244 (self == self->frame->selected ?
247 switch (self->entry->type) {
248 case OB_MENU_ENTRY_TYPE_NORMAL:
249 case OB_MENU_ENTRY_TYPE_SUBMENU:
250 th = self->frame->item_h;
252 case OB_MENU_ENTRY_TYPE_SEPARATOR:
253 th = SEPARATOR_HEIGHT + 2*PADDING;
256 RECT_SET_SIZE(self->area, self->frame->inner_w, th);
257 XResizeWindow(ob_display, self->window,
258 self->area.width, self->area.height);
259 item_a->surface.parent = self->frame->a_items;
260 item_a->surface.parentx = self->area.x;
261 item_a->surface.parenty = self->area.y;
262 RrPaint(item_a, self->window, self->area.width, self->area.height);
264 text_a = ((self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
265 !self->entry->data.normal.enabled) ?
266 self->a_text_disabled :
267 (self == self->frame->selected ?
268 self->a_text_selected :
269 self->a_text_normal));
270 switch (self->entry->type) {
271 case OB_MENU_ENTRY_TYPE_NORMAL:
272 text_a->texture[0].data.text.string = self->entry->data.normal.label;
274 case OB_MENU_ENTRY_TYPE_SUBMENU:
275 sub = self->entry->data.submenu.submenu;
276 text_a->texture[0].data.text.string = sub ? sub->title : "";
278 case OB_MENU_ENTRY_TYPE_SEPARATOR:
282 switch (self->entry->type) {
283 case OB_MENU_ENTRY_TYPE_NORMAL:
284 XMoveResizeWindow(ob_display, self->text,
285 self->frame->text_x, PADDING,
287 self->frame->item_h - 2*PADDING);
288 text_a->surface.parent = item_a;
289 text_a->surface.parentx = self->frame->text_x;
290 text_a->surface.parenty = PADDING;
291 RrPaint(text_a, self->text, self->frame->text_w,
292 self->frame->item_h - 2*PADDING);
294 case OB_MENU_ENTRY_TYPE_SUBMENU:
295 XMoveResizeWindow(ob_display, self->text,
296 self->frame->text_x, PADDING,
297 self->frame->text_w - self->frame->item_h,
298 self->frame->item_h - 2*PADDING);
299 text_a->surface.parent = item_a;
300 text_a->surface.parentx = self->frame->text_x;
301 text_a->surface.parenty = PADDING;
302 RrPaint(text_a, self->text, self->frame->text_w - self->frame->item_h,
303 self->frame->item_h - 2*PADDING);
305 case OB_MENU_ENTRY_TYPE_SEPARATOR:
306 XMoveResizeWindow(ob_display, self->text, PADDING, PADDING,
307 self->area.width - 2*PADDING, SEPARATOR_HEIGHT);
308 self->a_separator->surface.parent = item_a;
309 self->a_separator->surface.parentx = PADDING;
310 self->a_separator->surface.parenty = PADDING;
311 self->a_separator->texture[0].data.lineart.color =
312 text_a->texture[0].data.text.color;
313 self->a_separator->texture[0].data.lineart.x1 = 2*PADDING;
314 self->a_separator->texture[0].data.lineart.y1 = SEPARATOR_HEIGHT / 2;
315 self->a_separator->texture[0].data.lineart.x2 =
316 self->area.width - 4*PADDING;
317 self->a_separator->texture[0].data.lineart.y2 = SEPARATOR_HEIGHT / 2;
318 RrPaint(self->a_separator, self->text,
319 self->area.width - 2*PADDING, SEPARATOR_HEIGHT);
323 if (self->entry->type != OB_MENU_ENTRY_TYPE_SEPARATOR &&
324 self->entry->data.normal.icon_data)
326 XMoveResizeWindow(ob_display, self->icon,
327 PADDING, frame->item_margin.top,
328 self->frame->item_h - frame->item_margin.top
329 - frame->item_margin.bottom,
330 self->frame->item_h - frame->item_margin.top
331 - frame->item_margin.bottom);
332 self->a_icon->texture[0].data.rgba.width =
333 self->entry->data.normal.icon_width;
334 self->a_icon->texture[0].data.rgba.height =
335 self->entry->data.normal.icon_height;
336 self->a_icon->texture[0].data.rgba.data =
337 self->entry->data.normal.icon_data;
338 self->a_icon->surface.parent = item_a;
339 self->a_icon->surface.parentx = PADDING;
340 self->a_icon->surface.parenty = frame->item_margin.top;
341 RrPaint(self->a_icon, self->icon,
342 self->frame->item_h - frame->item_margin.top
343 - frame->item_margin.bottom,
344 self->frame->item_h - frame->item_margin.top
345 - frame->item_margin.bottom);
346 XMapWindow(ob_display, self->icon);
347 } else if (self->entry->type != OB_MENU_ENTRY_TYPE_SEPARATOR &&
348 self->entry->data.normal.mask)
352 XMoveResizeWindow(ob_display, self->icon,
353 PADDING, frame->item_margin.top,
354 self->frame->item_h - frame->item_margin.top
355 - frame->item_margin.bottom,
356 self->frame->item_h - frame->item_margin.top
357 - frame->item_margin.bottom);
358 self->a_mask->texture[0].data.mask.mask =
359 self->entry->data.normal.mask;
361 c = ((self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
362 !self->entry->data.normal.enabled) ?
363 self->entry->data.normal.mask_disabled_color :
364 (self == self->frame->selected ?
365 self->entry->data.normal.mask_selected_color :
366 self->entry->data.normal.mask_normal_color));
367 self->a_mask->texture[0].data.mask.color = c;
369 self->a_mask->surface.parent = item_a;
370 self->a_mask->surface.parentx = PADDING;
371 self->a_mask->surface.parenty = frame->item_margin.top;
372 RrPaint(self->a_mask, self->icon,
373 self->frame->item_h - frame->item_margin.top
374 - frame->item_margin.bottom,
375 self->frame->item_h - frame->item_margin.top
376 - frame->item_margin.bottom);
377 XMapWindow(ob_display, self->icon);
379 XUnmapWindow(ob_display, self->icon);
381 if (self->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) {
382 RrAppearance *bullet_a;
383 XMoveResizeWindow(ob_display, self->bullet,
384 self->frame->text_x + self->frame->text_w
385 - self->frame->item_h + PADDING, PADDING,
386 self->frame->item_h - 2*PADDING,
387 self->frame->item_h - 2*PADDING);
388 bullet_a = (self == self->frame->selected ?
389 self->a_bullet_selected :
390 self->a_bullet_normal);
391 bullet_a->surface.parent = item_a;
392 bullet_a->surface.parentx =
393 self->frame->text_x + self->frame->text_w - self->frame->item_h
395 bullet_a->surface.parenty = PADDING;
396 RrPaint(bullet_a, self->bullet,
397 self->frame->item_h - 2*PADDING,
398 self->frame->item_h - 2*PADDING);
399 XMapWindow(ob_display, self->bullet);
401 XUnmapWindow(ob_display, self->bullet);
406 static void menu_frame_render(ObMenuFrame *self)
410 gint tw, th; /* temps */
412 gboolean has_icon = FALSE;
415 XSetWindowBorderWidth(ob_display, self->window, ob_rr_theme->bwidth);
416 XSetWindowBorder(ob_display, self->window,
417 RrColorPixel(ob_rr_theme->b_color));
419 if (!self->parent && self->show_title) {
420 XMoveWindow(ob_display, self->title,
421 -ob_rr_theme->bwidth, h - ob_rr_theme->bwidth);
423 self->a_title->texture[0].data.text.string = self->menu->title;
424 RrMinsize(self->a_title, &tw, &th);
425 tw = MIN(tw, MAX_MENU_WIDTH) + ob_rr_theme->padding * 2;
428 th = ob_rr_theme->menu_title_height;
429 h += (self->title_h = th + ob_rr_theme->bwidth);
431 XSetWindowBorderWidth(ob_display, self->title, ob_rr_theme->bwidth);
432 XSetWindowBorder(ob_display, self->title,
433 RrColorPixel(ob_rr_theme->b_color));
436 XMoveWindow(ob_display, self->items, 0, h);
438 STRUT_SET(self->item_margin, 0, 0, 0, 0);
441 ObMenuEntryFrame *e = self->entries->data;
444 e->a_text_normal->texture[0].data.text.string = "";
445 RrMinsize(e->a_text_normal, &tw, &th);
450 RrMargins(e->a_normal, &l, &t, &r, &b);
451 STRUT_SET(self->item_margin,
452 MAX(self->item_margin.left, l),
453 MAX(self->item_margin.top, t),
454 MAX(self->item_margin.right, r),
455 MAX(self->item_margin.bottom, b));
456 RrMargins(e->a_selected, &l, &t, &r, &b);
457 STRUT_SET(self->item_margin,
458 MAX(self->item_margin.left, l),
459 MAX(self->item_margin.top, t),
460 MAX(self->item_margin.right, r),
461 MAX(self->item_margin.bottom, b));
462 RrMargins(e->a_disabled, &l, &t, &r, &b);
463 STRUT_SET(self->item_margin,
464 MAX(self->item_margin.left, l),
465 MAX(self->item_margin.top, t),
466 MAX(self->item_margin.right, r),
467 MAX(self->item_margin.bottom, b));
471 for (it = self->entries; it; it = g_list_next(it)) {
472 RrAppearance *text_a;
473 ObMenuEntryFrame *e = it->data;
475 RECT_SET_POINT(e->area, 0, allitems_h);
476 XMoveWindow(ob_display, e->window, 0, e->area.y);
478 text_a = ((e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
479 !e->entry->data.normal.enabled) ?
481 (e == self->selected ?
484 switch (e->entry->type) {
485 case OB_MENU_ENTRY_TYPE_NORMAL:
486 text_a->texture[0].data.text.string = e->entry->data.normal.label;
487 RrMinsize(text_a, &tw, &th);
488 tw = MIN(tw, MAX_MENU_WIDTH);
490 if (e->entry->data.normal.icon_data ||
491 e->entry->data.normal.mask)
494 case OB_MENU_ENTRY_TYPE_SUBMENU:
495 sub = e->entry->data.submenu.submenu;
496 text_a->texture[0].data.text.string = sub ? sub->title : "";
497 RrMinsize(text_a, &tw, &th);
498 tw = MIN(tw, MAX_MENU_WIDTH);
500 if (e->entry->data.normal.icon_data ||
501 e->entry->data.normal.mask)
504 tw += self->item_h - PADDING;
506 case OB_MENU_ENTRY_TYPE_SEPARATOR:
508 th = SEPARATOR_HEIGHT;
518 self->text_x = PADDING;
523 w += self->item_h + PADDING;
524 self->text_x += self->item_h + PADDING;
534 XResizeWindow(ob_display, self->window, w, h);
535 XResizeWindow(ob_display, self->items, w, allitems_h);
539 if (!self->parent && self->show_title) {
540 XResizeWindow(ob_display, self->title,
541 w, self->title_h - ob_rr_theme->bwidth);
542 RrPaint(self->a_title, self->title,
543 w, self->title_h - ob_rr_theme->bwidth);
544 XMapWindow(ob_display, self->title);
546 XUnmapWindow(ob_display, self->title);
548 RrPaint(self->a_items, self->items, w, allitems_h);
550 for (it = self->entries; it; it = g_list_next(it))
551 menu_entry_frame_render(it->data);
553 w += ob_rr_theme->bwidth * 2;
554 h += ob_rr_theme->bwidth * 2;
556 RECT_SET_SIZE(self->area, w, h);
561 static void menu_frame_update(ObMenuFrame *self)
565 menu_pipe_execute(self->menu);
566 menu_find_submenus(self->menu);
568 self->selected = NULL;
570 for (mit = self->menu->entries, fit = self->entries; mit && fit;
571 mit = g_list_next(mit), fit = g_list_next(fit))
573 ObMenuEntryFrame *f = fit->data;
574 f->entry = mit->data;
578 ObMenuEntryFrame *e = menu_entry_frame_new(mit->data, self);
579 self->entries = g_list_append(self->entries, e);
580 mit = g_list_next(mit);
584 GList *n = g_list_next(fit);
585 menu_entry_frame_free(fit->data);
586 self->entries = g_list_delete_link(self->entries, fit);
590 menu_frame_render(self);
593 gboolean menu_frame_show(ObMenuFrame *self, ObMenuFrame *parent)
597 if (g_list_find(menu_frame_visible, self))
600 if (menu_frame_visible == NULL) {
601 /* no menus shown yet */
602 if (!grab_pointer(TRUE, OB_CURSOR_NONE))
604 if (!grab_keyboard(TRUE)) {
605 grab_pointer(FALSE, OB_CURSOR_NONE);
612 menu_frame_hide(parent->child);
613 parent->child = self;
615 self->parent = parent;
617 /* determine if the underlying menu is already visible */
618 for (it = menu_frame_visible; it; it = g_list_next(it)) {
619 ObMenuFrame *f = it->data;
620 if (f->menu == self->menu)
624 if (self->menu->update_func)
625 self->menu->update_func(self, self->menu->data);
628 menu_frame_update(self);
630 menu_frame_visible = g_list_prepend(menu_frame_visible, self);
632 menu_frame_move_on_screen(self);
634 XMapWindow(ob_display, self->window);
639 void menu_frame_hide(ObMenuFrame *self)
641 GList *it = g_list_find(menu_frame_visible, self);
647 menu_frame_hide(self->child);
650 self->parent->child = NULL;
653 menu_frame_visible = g_list_delete_link(menu_frame_visible, it);
655 if (menu_frame_visible == NULL) {
656 /* last menu shown */
657 grab_pointer(FALSE, OB_CURSOR_NONE);
658 grab_keyboard(FALSE);
661 XUnmapWindow(ob_display, self->window);
663 menu_frame_free(self);
666 void menu_frame_hide_all()
668 GList *it = g_list_last(menu_frame_visible);
670 menu_frame_hide(it->data);
673 void menu_frame_hide_all_client(ObClient *client)
675 GList *it = g_list_last(menu_frame_visible);
677 ObMenuFrame *f = it->data;
678 if (f->client == client)
684 ObMenuFrame* menu_frame_under(gint x, gint y)
686 ObMenuFrame *ret = NULL;
689 for (it = menu_frame_visible; it; it = g_list_next(it)) {
690 ObMenuFrame *f = it->data;
692 if (RECT_CONTAINS(f->area, x, y)) {
700 ObMenuEntryFrame* menu_entry_frame_under(gint x, gint y)
703 ObMenuEntryFrame *ret = NULL;
706 if ((frame = menu_frame_under(x, y))) {
707 x -= ob_rr_theme->bwidth + frame->area.x;
708 y -= frame->title_h + ob_rr_theme->bwidth + frame->area.y;
710 for (it = frame->entries; it; it = g_list_next(it)) {
711 ObMenuEntryFrame *e = it->data;
713 if (RECT_CONTAINS(e->area, x, y)) {
722 void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry)
724 ObMenuEntryFrame *old = self->selected;
725 ObMenuFrame *oldchild = self->child;
727 if (entry && entry->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR)
730 if (old == entry) return;
732 self->selected = entry;
735 menu_entry_frame_render(old);
737 menu_frame_hide(oldchild);
739 if (self->selected) {
740 menu_entry_frame_render(self->selected);
742 if (self->selected->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
743 menu_entry_frame_show_submenu(self->selected);
747 void menu_entry_frame_show_submenu(ObMenuEntryFrame *self)
751 if (!self->entry->data.submenu.submenu) return;
753 f = menu_frame_new(self->entry->data.submenu.submenu,
754 self->frame->client);
756 self->frame->area.x + self->frame->area.width
757 - ob_rr_theme->menu_overlap - ob_rr_theme->bwidth,
758 self->frame->area.y + self->frame->title_h +
759 self->area.y + ob_rr_theme->menu_overlap);
760 menu_frame_show(f, self->frame);
763 void menu_entry_frame_execute(ObMenuEntryFrame *self, guint state)
765 if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
766 self->entry->data.normal.enabled)
768 /* grab all this shizzle, cuz when the menu gets hidden, 'self'
770 ObMenuEntry *entry = self->entry;
771 ObMenuExecuteFunc func = self->frame->menu->execute_func;
772 gpointer data = self->frame->menu->data;
773 GSList *acts = self->entry->data.normal.actions;
774 ObClient *client = self->frame->client;
776 /* release grabs before executing the shit */
777 if (!(state & ControlMask))
778 menu_frame_hide_all();
781 func(entry, state, data);
783 action_run(acts, client, state);
787 void menu_frame_select_previous(ObMenuFrame *self)
789 GList *it = NULL, *start;
792 start = it = g_list_find(self->entries, self->selected);
796 it = it ? g_list_previous(it) : g_list_last(self->entries);
802 if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
804 if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
805 e->entry->data.normal.enabled)
810 menu_frame_select(self, it ? it->data : NULL);
813 void menu_frame_select_next(ObMenuFrame *self)
815 GList *it = NULL, *start;
818 start = it = g_list_find(self->entries, self->selected);
822 it = it ? g_list_next(it) : self->entries;
828 if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
830 if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
831 e->entry->data.normal.enabled)
836 menu_frame_select(self, it ? it->data : NULL);