7 #include "render/theme.h"
10 #define SEPARATOR_HEIGHT 3
12 #define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask |\
14 #define TITLE_EVENTMASK (ButtonPressMask | ButtonMotionMask)
15 #define ENTRY_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
16 ButtonPressMask | ButtonReleaseMask)
18 GList
*menu_frame_visible
;
20 static ObMenuEntryFrame
* menu_entry_frame_new(ObMenuEntry
*entry
,
22 static void menu_entry_frame_free(ObMenuEntryFrame
*self
);
23 static void menu_frame_render(ObMenuFrame
*self
);
24 static void menu_frame_update(ObMenuFrame
*self
);
26 static Window
createWindow(Window parent
, unsigned long mask
,
27 XSetWindowAttributes
*attrib
)
29 return XCreateWindow(ob_display
, parent
, 0, 0, 1, 1, 0,
30 RrDepth(ob_rr_inst
), InputOutput
,
31 RrVisual(ob_rr_inst
), mask
, attrib
);
35 ObMenuFrame
* menu_frame_new(ObMenu
*menu
, ObClient
*client
)
38 XSetWindowAttributes attr
;
40 self
= g_new0(ObMenuFrame
, 1);
41 self
->type
= Window_Menu
;
43 self
->selected
= NULL
;
44 self
->show_title
= TRUE
;
45 self
->client
= client
;
47 attr
.event_mask
= FRAME_EVENTMASK
;
48 self
->window
= createWindow(RootWindow(ob_display
, ob_screen
),
50 attr
.event_mask
= TITLE_EVENTMASK
;
51 self
->title
= createWindow(self
->window
, CWEventMask
, &attr
);
52 self
->items
= createWindow(self
->window
, 0, NULL
);
54 XMapWindow(ob_display
, self
->items
);
56 self
->a_title
= RrAppearanceCopy(ob_rr_theme
->a_menu_title
);
57 self
->a_items
= RrAppearanceCopy(ob_rr_theme
->a_menu
);
59 stacking_add(MENU_AS_WINDOW(self
));
64 void menu_frame_free(ObMenuFrame
*self
)
67 while (self
->entries
) {
68 menu_entry_frame_free(self
->entries
->data
);
69 self
->entries
= g_list_delete_link(self
->entries
, self
->entries
);
72 stacking_remove(MENU_AS_WINDOW(self
));
74 XDestroyWindow(ob_display
, self
->items
);
75 XDestroyWindow(ob_display
, self
->title
);
76 XDestroyWindow(ob_display
, self
->window
);
78 RrAppearanceFree(self
->a_items
);
79 RrAppearanceFree(self
->a_title
);
85 static ObMenuEntryFrame
* menu_entry_frame_new(ObMenuEntry
*entry
,
88 ObMenuEntryFrame
*self
;
89 XSetWindowAttributes attr
;
91 self
= g_new0(ObMenuEntryFrame
, 1);
95 attr
.event_mask
= ENTRY_EVENTMASK
;
96 self
->window
= createWindow(self
->frame
->items
, CWEventMask
, &attr
);
97 self
->text
= createWindow(self
->window
, 0, NULL
);
98 if (entry
->type
!= OB_MENU_ENTRY_TYPE_SEPARATOR
) {
99 self
->icon
= createWindow(self
->window
, 0, NULL
);
100 self
->bullet
= createWindow(self
->window
, 0, NULL
);
103 XMapWindow(ob_display
, self
->window
);
104 XMapWindow(ob_display
, self
->text
);
106 self
->a_normal
= RrAppearanceCopy(ob_rr_theme
->a_menu_normal
);
107 self
->a_disabled
= RrAppearanceCopy(ob_rr_theme
->a_menu_disabled
);
108 self
->a_selected
= RrAppearanceCopy(ob_rr_theme
->a_menu_selected
);
110 if (entry
->type
== OB_MENU_ENTRY_TYPE_SEPARATOR
) {
111 self
->a_separator
= RrAppearanceCopy(ob_rr_theme
->a_clear_tex
);
112 self
->a_separator
->texture
[0].type
= RR_TEXTURE_LINE_ART
;
114 self
->a_icon
= RrAppearanceCopy(ob_rr_theme
->a_clear_tex
);
115 self
->a_icon
->texture
[0].type
= RR_TEXTURE_RGBA
;
116 self
->a_mask
= RrAppearanceCopy(ob_rr_theme
->a_clear_tex
);
117 self
->a_mask
->texture
[0].type
= RR_TEXTURE_MASK
;
118 self
->a_bullet_normal
=
119 RrAppearanceCopy(ob_rr_theme
->a_menu_bullet_normal
);
120 self
->a_bullet_selected
=
121 RrAppearanceCopy(ob_rr_theme
->a_menu_bullet_selected
);
124 self
->a_text_normal
=
125 RrAppearanceCopy(ob_rr_theme
->a_menu_text_normal
);
126 self
->a_text_disabled
=
127 RrAppearanceCopy(ob_rr_theme
->a_menu_text_disabled
);
128 self
->a_text_selected
=
129 RrAppearanceCopy(ob_rr_theme
->a_menu_text_selected
);
134 static void menu_entry_frame_free(ObMenuEntryFrame
*self
)
137 XDestroyWindow(ob_display
, self
->text
);
138 XDestroyWindow(ob_display
, self
->window
);
139 if (self
->entry
->type
!= OB_MENU_ENTRY_TYPE_SEPARATOR
) {
140 XDestroyWindow(ob_display
, self
->icon
);
141 XDestroyWindow(ob_display
, self
->bullet
);
144 RrAppearanceFree(self
->a_normal
);
145 RrAppearanceFree(self
->a_disabled
);
146 RrAppearanceFree(self
->a_selected
);
148 RrAppearanceFree(self
->a_separator
);
149 RrAppearanceFree(self
->a_icon
);
150 RrAppearanceFree(self
->a_mask
);
151 RrAppearanceFree(self
->a_text_normal
);
152 RrAppearanceFree(self
->a_text_disabled
);
153 RrAppearanceFree(self
->a_text_selected
);
154 RrAppearanceFree(self
->a_bullet_normal
);
155 RrAppearanceFree(self
->a_bullet_selected
);
161 void menu_frame_move(ObMenuFrame
*self
, gint x
, gint y
)
163 RECT_SET_POINT(self
->area
, x
, y
);
164 XMoveWindow(ob_display
, self
->window
, self
->area
.x
, self
->area
.y
);
167 void menu_frame_move_on_screen(ObMenuFrame
*self
)
173 for (i
= 0; i
< screen_num_monitors
; ++i
) {
174 a
= screen_physical_area_monitor(i
);
175 if (RECT_INTERSECTS_RECT(*a
, self
->area
))
178 if (a
) a
= screen_physical_area_monitor(0);
180 dx
= MIN(0, (a
->x
+ a
->width
) - (self
->area
.x
+ self
->area
.width
));
181 dy
= MIN(0, (a
->y
+ a
->height
) - (self
->area
.y
+ self
->area
.height
));
182 if (!dx
) dx
= MAX(0, a
->x
- self
->area
.x
);
183 if (!dy
) dy
= MAX(0, a
->y
- self
->area
.y
);
188 for (f
= self
; f
; f
= f
->parent
)
189 menu_frame_move(f
, f
->area
.x
+ dx
, f
->area
.y
+ dy
);
190 for (f
= self
->child
; f
; f
= f
->child
)
191 menu_frame_move(f
, f
->area
.x
+ dx
, f
->area
.y
+ dy
);
192 XWarpPointer(ob_display
, None
, None
, 0, 0, 0, 0, dx
, dy
);
196 static void menu_entry_frame_render(ObMenuEntryFrame
*self
)
198 RrAppearance
*item_a
, *text_a
;
202 item_a
= ((self
->entry
->type
== OB_MENU_ENTRY_TYPE_NORMAL
&&
203 !self
->entry
->data
.normal
.enabled
) ?
205 (self
== self
->frame
->selected
?
208 switch (self
->entry
->type
) {
209 case OB_MENU_ENTRY_TYPE_NORMAL
:
210 case OB_MENU_ENTRY_TYPE_SUBMENU
:
211 th
= self
->frame
->item_h
;
213 case OB_MENU_ENTRY_TYPE_SEPARATOR
:
214 th
= SEPARATOR_HEIGHT
+ 2*PADDING
;
217 RECT_SET_SIZE(self
->area
, self
->frame
->inner_w
, th
);
218 XResizeWindow(ob_display
, self
->window
,
219 self
->area
.width
, self
->area
.height
);
220 item_a
->surface
.parent
= self
->frame
->a_items
;
221 item_a
->surface
.parentx
= self
->area
.x
;
222 item_a
->surface
.parenty
= self
->area
.y
;
223 RrPaint(item_a
, self
->window
, self
->area
.width
, self
->area
.height
);
225 text_a
= ((self
->entry
->type
== OB_MENU_ENTRY_TYPE_NORMAL
&&
226 !self
->entry
->data
.normal
.enabled
) ?
227 self
->a_text_disabled
:
228 (self
== self
->frame
->selected
?
229 self
->a_text_selected
:
230 self
->a_text_normal
));
231 switch (self
->entry
->type
) {
232 case OB_MENU_ENTRY_TYPE_NORMAL
:
233 text_a
->texture
[0].data
.text
.string
= self
->entry
->data
.normal
.label
;
235 case OB_MENU_ENTRY_TYPE_SUBMENU
:
236 sub
= self
->entry
->data
.submenu
.submenu
;
237 text_a
->texture
[0].data
.text
.string
= sub
? sub
->title
: "";
239 case OB_MENU_ENTRY_TYPE_SEPARATOR
:
243 switch (self
->entry
->type
) {
244 case OB_MENU_ENTRY_TYPE_NORMAL
:
245 XMoveResizeWindow(ob_display
, self
->text
,
246 self
->frame
->text_x
, PADDING
,
248 self
->frame
->item_h
- 2*PADDING
);
249 text_a
->surface
.parent
= item_a
;
250 text_a
->surface
.parentx
= self
->frame
->text_x
;
251 text_a
->surface
.parenty
= PADDING
;
252 RrPaint(text_a
, self
->text
, self
->frame
->text_w
,
253 self
->frame
->item_h
- 2*PADDING
);
255 case OB_MENU_ENTRY_TYPE_SUBMENU
:
256 XMoveResizeWindow(ob_display
, self
->text
,
257 self
->frame
->text_x
, PADDING
,
258 self
->frame
->text_w
- self
->frame
->item_h
,
259 self
->frame
->item_h
- 2*PADDING
);
260 text_a
->surface
.parent
= item_a
;
261 text_a
->surface
.parentx
= self
->frame
->text_x
;
262 text_a
->surface
.parenty
= PADDING
;
263 RrPaint(text_a
, self
->text
, self
->frame
->text_w
- self
->frame
->item_h
,
264 self
->frame
->item_h
- 2*PADDING
);
266 case OB_MENU_ENTRY_TYPE_SEPARATOR
:
267 XMoveResizeWindow(ob_display
, self
->text
, PADDING
, PADDING
,
268 self
->area
.width
- 2*PADDING
, SEPARATOR_HEIGHT
);
269 self
->a_separator
->surface
.parent
= item_a
;
270 self
->a_separator
->surface
.parentx
= PADDING
;
271 self
->a_separator
->surface
.parenty
= PADDING
;
272 self
->a_separator
->texture
[0].data
.lineart
.color
=
273 text_a
->texture
[0].data
.text
.color
;
274 self
->a_separator
->texture
[0].data
.lineart
.x1
= 2*PADDING
;
275 self
->a_separator
->texture
[0].data
.lineart
.y1
= SEPARATOR_HEIGHT
/ 2;
276 self
->a_separator
->texture
[0].data
.lineart
.x2
=
277 self
->area
.width
- 4*PADDING
;
278 self
->a_separator
->texture
[0].data
.lineart
.y2
= SEPARATOR_HEIGHT
/ 2;
279 RrPaint(self
->a_separator
, self
->text
,
280 self
->area
.width
- 2*PADDING
, SEPARATOR_HEIGHT
);
284 if (self
->entry
->type
!= OB_MENU_ENTRY_TYPE_SEPARATOR
&&
285 self
->entry
->data
.normal
.icon_data
)
287 XMoveResizeWindow(ob_display
, self
->icon
, PADDING
, 0,
289 self
->frame
->item_h
);
290 self
->a_icon
->texture
[0].data
.rgba
.width
=
291 self
->entry
->data
.normal
.icon_width
;
292 self
->a_icon
->texture
[0].data
.rgba
.height
=
293 self
->entry
->data
.normal
.icon_height
;
294 self
->a_icon
->texture
[0].data
.rgba
.data
=
295 self
->entry
->data
.normal
.icon_data
;
296 self
->a_icon
->surface
.parent
= item_a
;
297 self
->a_icon
->surface
.parentx
= PADDING
;
298 self
->a_icon
->surface
.parenty
= 0;
299 RrPaint(self
->a_icon
, self
->icon
,
300 self
->frame
->item_h
, self
->frame
->item_h
);
301 XMapWindow(ob_display
, self
->icon
);
302 } else if (self
->entry
->type
!= OB_MENU_ENTRY_TYPE_SEPARATOR
&&
303 self
->entry
->data
.normal
.mask
)
307 XMoveResizeWindow(ob_display
, self
->icon
, PADDING
, 0,
309 self
->frame
->item_h
);
310 self
->a_mask
->texture
[0].data
.mask
.mask
=
311 self
->entry
->data
.normal
.mask
;
313 c
= ((self
->entry
->type
== OB_MENU_ENTRY_TYPE_NORMAL
&&
314 !self
->entry
->data
.normal
.enabled
) ?
315 self
->entry
->data
.normal
.mask_disabled_color
:
316 (self
== self
->frame
->selected
?
317 self
->entry
->data
.normal
.mask_selected_color
:
318 self
->entry
->data
.normal
.mask_normal_color
));
319 self
->a_mask
->texture
[0].data
.mask
.color
= c
;
321 self
->a_mask
->surface
.parent
= item_a
;
322 self
->a_mask
->surface
.parentx
= PADDING
;
323 self
->a_mask
->surface
.parenty
= 0;
324 RrPaint(self
->a_mask
, self
->icon
,
325 self
->frame
->item_h
, self
->frame
->item_h
);
326 XMapWindow(ob_display
, self
->icon
);
328 XUnmapWindow(ob_display
, self
->icon
);
330 if (self
->entry
->type
== OB_MENU_ENTRY_TYPE_SUBMENU
) {
331 RrAppearance
*bullet_a
;
332 XMoveResizeWindow(ob_display
, self
->bullet
,
333 self
->frame
->text_x
+ self
->frame
->text_w
334 - self
->frame
->item_h
+ PADDING
, PADDING
,
335 self
->frame
->item_h
- 2*PADDING
,
336 self
->frame
->item_h
- 2*PADDING
);
337 bullet_a
= (self
== self
->frame
->selected
?
338 self
->a_bullet_selected
:
339 self
->a_bullet_normal
);
340 bullet_a
->surface
.parent
= item_a
;
341 bullet_a
->surface
.parentx
=
342 self
->frame
->text_x
+ self
->frame
->text_w
- self
->frame
->item_h
344 bullet_a
->surface
.parenty
= PADDING
;
345 RrPaint(bullet_a
, self
->bullet
,
346 self
->frame
->item_h
- 2*PADDING
,
347 self
->frame
->item_h
- 2*PADDING
);
348 XMapWindow(ob_display
, self
->bullet
);
350 XUnmapWindow(ob_display
, self
->bullet
);
353 static void menu_frame_render(ObMenuFrame
*self
)
357 gint tw
, th
; /* temps */
359 gboolean has_icon
= FALSE
;
362 XSetWindowBorderWidth(ob_display
, self
->window
, ob_rr_theme
->bwidth
);
363 XSetWindowBorder(ob_display
, self
->window
,
364 RrColorPixel(ob_rr_theme
->b_color
));
366 if (!self
->parent
&& self
->show_title
) {
367 XMoveWindow(ob_display
, self
->title
,
368 -ob_rr_theme
->bwidth
, h
- ob_rr_theme
->bwidth
);
370 self
->a_title
->texture
[0].data
.text
.string
= self
->menu
->title
;
371 RrMinsize(self
->a_title
, &tw
, &th
);
375 h
+= (self
->title_h
= th
+ ob_rr_theme
->bwidth
);
377 XSetWindowBorderWidth(ob_display
, self
->title
, ob_rr_theme
->bwidth
);
378 XSetWindowBorder(ob_display
, self
->title
,
379 RrColorPixel(ob_rr_theme
->b_color
));
382 XMoveWindow(ob_display
, self
->items
, 0, h
);
385 ObMenuEntryFrame
*e
= self
->entries
->data
;
386 e
->a_text_normal
->texture
[0].data
.text
.string
= "";
387 RrMinsize(e
->a_text_normal
, &tw
, &th
);
394 for (it
= self
->entries
; it
; it
= g_list_next(it
)) {
395 RrAppearance
*text_a
;
396 ObMenuEntryFrame
*e
= it
->data
;
398 RECT_SET_POINT(e
->area
, 0, allitems_h
);
399 XMoveWindow(ob_display
, e
->window
, 0, e
->area
.y
);
401 text_a
= ((e
->entry
->type
== OB_MENU_ENTRY_TYPE_NORMAL
&&
402 !e
->entry
->data
.normal
.enabled
) ?
404 (e
== self
->selected
?
407 switch (e
->entry
->type
) {
408 case OB_MENU_ENTRY_TYPE_NORMAL
:
409 text_a
->texture
[0].data
.text
.string
= e
->entry
->data
.normal
.label
;
410 RrMinsize(text_a
, &tw
, &th
);
412 if (e
->entry
->data
.normal
.icon_data
||
413 e
->entry
->data
.normal
.mask
)
416 case OB_MENU_ENTRY_TYPE_SUBMENU
:
417 sub
= e
->entry
->data
.submenu
.submenu
;
418 text_a
->texture
[0].data
.text
.string
= sub
? sub
->title
: "";
419 RrMinsize(text_a
, &tw
, &th
);
421 if (e
->entry
->data
.normal
.icon_data
||
422 e
->entry
->data
.normal
.mask
)
425 tw
+= self
->item_h
- PADDING
;
427 case OB_MENU_ENTRY_TYPE_SEPARATOR
:
429 th
= SEPARATOR_HEIGHT
;
439 self
->text_x
= PADDING
;
444 w
+= self
->item_h
+ PADDING
;
445 self
->text_x
+= self
->item_h
+ PADDING
;
455 XResizeWindow(ob_display
, self
->window
, w
, h
);
456 XResizeWindow(ob_display
, self
->items
, w
, allitems_h
);
460 if (!self
->parent
&& self
->show_title
) {
461 XResizeWindow(ob_display
, self
->title
,
462 w
, self
->title_h
- ob_rr_theme
->bwidth
);
463 RrPaint(self
->a_title
, self
->title
,
464 w
, self
->title_h
- ob_rr_theme
->bwidth
);
465 XMapWindow(ob_display
, self
->title
);
467 XUnmapWindow(ob_display
, self
->title
);
469 RrPaint(self
->a_items
, self
->items
, w
, allitems_h
);
471 for (it
= self
->entries
; it
; it
= g_list_next(it
))
472 menu_entry_frame_render(it
->data
);
474 w
+= ob_rr_theme
->bwidth
* 2;
475 h
+= ob_rr_theme
->bwidth
* 2;
477 RECT_SET_SIZE(self
->area
, w
, h
);
480 static void menu_frame_update(ObMenuFrame
*self
)
484 menu_pipe_execute(self
->menu
);
485 menu_find_submenus(self
->menu
);
487 self
->selected
= NULL
;
489 for (mit
= self
->menu
->entries
, fit
= self
->entries
; mit
&& fit
;
490 mit
= g_list_next(mit
), fit
= g_list_next(fit
))
492 ObMenuEntryFrame
*f
= fit
->data
;
493 f
->entry
= mit
->data
;
497 ObMenuEntryFrame
*e
= menu_entry_frame_new(mit
->data
, self
);
498 self
->entries
= g_list_append(self
->entries
, e
);
499 mit
= g_list_next(mit
);
503 GList
*n
= g_list_next(fit
);
504 menu_entry_frame_free(fit
->data
);
505 self
->entries
= g_list_delete_link(self
->entries
, fit
);
509 menu_frame_render(self
);
512 void menu_frame_show(ObMenuFrame
*self
, ObMenuFrame
*parent
)
516 if (g_list_find(menu_frame_visible
, self
))
521 menu_frame_hide(parent
->child
);
522 parent
->child
= self
;
524 self
->parent
= parent
;
526 if (menu_frame_visible
== NULL
) {
527 /* no menus shown yet */
528 grab_pointer(TRUE
, None
);
532 /* determine if the underlying menu is already visible */
533 for (it
= menu_frame_visible
; it
; it
= g_list_next(it
)) {
534 ObMenuFrame
*f
= it
->data
;
535 if (f
->menu
== self
->menu
)
539 if (self
->menu
->update_func
)
540 self
->menu
->update_func(self
, self
->menu
->data
);
543 menu_frame_visible
= g_list_prepend(menu_frame_visible
, self
);
544 menu_frame_update(self
);
546 menu_frame_move_on_screen(self
);
548 XMapWindow(ob_display
, self
->window
);
551 void menu_frame_hide(ObMenuFrame
*self
)
553 GList
*it
= g_list_find(menu_frame_visible
, self
);
559 menu_frame_hide(self
->child
);
562 self
->parent
->child
= NULL
;
565 menu_frame_visible
= g_list_delete_link(menu_frame_visible
, it
);
567 if (menu_frame_visible
== NULL
) {
568 /* last menu shown */
569 grab_pointer(FALSE
, None
);
570 grab_keyboard(FALSE
);
573 XUnmapWindow(ob_display
, self
->window
);
575 menu_frame_free(self
);
578 void menu_frame_hide_all()
580 GList
*it
= g_list_last(menu_frame_visible
);
582 menu_frame_hide(it
->data
);
585 void menu_frame_hide_all_client(ObClient
*client
)
587 GList
*it
= g_list_last(menu_frame_visible
);
589 ObMenuFrame
*f
= it
->data
;
590 if (f
->client
== client
)
596 ObMenuFrame
* menu_frame_under(gint x
, gint y
)
598 ObMenuFrame
*ret
= NULL
;
601 for (it
= menu_frame_visible
; it
; it
= g_list_next(it
)) {
602 ObMenuFrame
*f
= it
->data
;
604 if (RECT_CONTAINS(f
->area
, x
, y
)) {
612 ObMenuEntryFrame
* menu_entry_frame_under(gint x
, gint y
)
615 ObMenuEntryFrame
*ret
= NULL
;
618 if ((frame
= menu_frame_under(x
, y
))) {
619 x
-= ob_rr_theme
->bwidth
+ frame
->area
.x
;
620 y
-= frame
->title_h
+ ob_rr_theme
->bwidth
+ frame
->area
.y
;
622 for (it
= frame
->entries
; it
; it
= g_list_next(it
)) {
623 ObMenuEntryFrame
*e
= it
->data
;
625 if (RECT_CONTAINS(e
->area
, x
, y
)) {
634 void menu_frame_select(ObMenuFrame
*self
, ObMenuEntryFrame
*entry
)
636 ObMenuEntryFrame
*old
= self
->selected
;
637 ObMenuFrame
*oldchild
= self
->child
;
639 if (entry
&& entry
->entry
->type
== OB_MENU_ENTRY_TYPE_SEPARATOR
)
642 if (old
== entry
) return;
644 self
->selected
= entry
;
647 menu_entry_frame_render(old
);
649 menu_frame_hide(oldchild
);
651 if (self
->selected
) {
652 menu_entry_frame_render(self
->selected
);
654 if (self
->selected
->entry
->type
== OB_MENU_ENTRY_TYPE_SUBMENU
)
655 menu_entry_frame_show_submenu(self
->selected
);
659 void menu_entry_frame_show_submenu(ObMenuEntryFrame
*self
)
663 if (!self
->entry
->data
.submenu
.submenu
) return;
665 f
= menu_frame_new(self
->entry
->data
.submenu
.submenu
,
666 self
->frame
->client
);
668 self
->frame
->area
.x
+ self
->frame
->area
.width
669 - ob_rr_theme
->menu_overlap
- ob_rr_theme
->bwidth
,
670 self
->frame
->area
.y
+ self
->frame
->title_h
+
671 self
->area
.y
+ ob_rr_theme
->menu_overlap
);
672 menu_frame_show(f
, self
->frame
);
675 void menu_entry_frame_execute(ObMenuEntryFrame
*self
, gboolean hide
)
677 if (self
->entry
->type
== OB_MENU_ENTRY_TYPE_NORMAL
&&
678 self
->entry
->data
.normal
.enabled
)
680 /* grab all this shizzle, cuz when the menu gets hidden, 'self'
682 ObMenuEntry
*entry
= self
->entry
;
683 ObMenuExecuteFunc func
= self
->frame
->menu
->execute_func
;
684 gpointer data
= self
->frame
->menu
->data
;
685 GSList
*acts
= self
->entry
->data
.normal
.actions
;
686 ObClient
*client
= self
->frame
->client
;
688 /* release grabs before executing the shit */
690 menu_frame_hide_all();
697 for (it
= acts
; it
; it
= g_slist_next(it
))
699 ObAction
*act
= it
->data
;
700 act
->data
.any
.c
= client
;
702 if (act
->func
== action_moveresize
)
703 screen_pointer_pos(&act
->data
.moveresize
.x
,
704 &act
->data
.moveresize
.y
);
706 if (!(act
->func
== action_cycle_windows
||
707 act
->func
== action_desktop_dir
||
708 act
->func
== action_send_to_desktop_dir
||
709 act
->func
== action_showmenu
))
711 act
->func(&act
->data
);
718 void menu_frame_select_previous(ObMenuFrame
*self
)
720 GList
*it
= NULL
, *start
;
723 start
= it
= g_list_find(self
->entries
, self
->selected
);
727 it
= it
? g_list_previous(it
) : g_list_last(self
->entries
);
733 if (e
->entry
->type
== OB_MENU_ENTRY_TYPE_SUBMENU
)
735 if (e
->entry
->type
== OB_MENU_ENTRY_TYPE_NORMAL
&&
736 e
->entry
->data
.normal
.enabled
)
741 menu_frame_select(self
, it
? it
->data
: NULL
);
744 void menu_frame_select_next(ObMenuFrame
*self
)
746 GList
*it
= NULL
, *start
;
749 start
= it
= g_list_find(self
->entries
, self
->selected
);
753 it
= it
? g_list_next(it
) : self
->entries
;
759 if (e
->entry
->type
== OB_MENU_ENTRY_TYPE_SUBMENU
)
761 if (e
->entry
->type
== OB_MENU_ENTRY_TYPE_NORMAL
&&
762 e
->entry
->data
.normal
.enabled
)
767 menu_frame_select(self
, it
? it
->data
: NULL
);