2 * ion/mod_menu/grabmenu.c
4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
12 #include <libextl/extl.h>
14 #include <ioncore/common.h>
15 #include <ioncore/pointer.h>
16 #include <ioncore/grab.h>
17 #include <ioncore/binding.h>
18 #include <ioncore/conf-bindings.h>
19 #include <ioncore/key.h>
24 static bool grabmenu_handler(WRegion *reg, XEvent *xev)
26 XKeyEvent *ev=&xev->xkey;
27 WMenu *menu=(WMenu*)reg;
29 if(ev->type==KeyRelease){
30 if(ioncore_unmod(ev->state, ev->keycode)==0){
40 if((menu->gm_state==ev->state || menu->gm_state==AnyModifier)
41 && ev->keycode==menu->gm_kcb){
42 menu_select_next(menu);
49 /*--lowlevel routine not to be called by the user--*/
51 WMenu *mod_menu_do_grabmenu(WMPlex *mplex, ExtlFn handler, ExtlTab tab,
54 WMenuCreateParams fnp;
55 WMPlexAttachParams par;
61 if(!ioncore_current_key(&kcb, &state, &sub))
65 /* TODO: cycle key? */
66 return mod_menu_do_menu(mplex, handler, tab, param);
72 fnp.submenu_mode=FALSE;
73 fnp.big_mode=extl_table_is_bool_set(param, "big");
75 extl_table_gets_i(param, "initial", &(fnp.initial));
77 par.flags=(MPLEX_ATTACH_SWITCHTO|
78 MPLEX_ATTACH_UNNUMBERED|
79 MPLEX_ATTACH_SIZEPOLICY);
80 par.szplcy=SIZEPOLICY_FULL_BOUNDS;
82 menu=(WMenu*)mplex_do_attach_new(mplex, &par,
83 (WRegionCreateFn*)create_menu,
92 ioncore_grab_establish((WRegion*)menu, grabmenu_handler, NULL, 0);