2 * ion/mod_menu/grabmenu.c
4 * Copyright (c) Tuomo Valkonen 1999-2006.
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 && ev->keycode==menu->gm_kcb)
41 menu_select_next(menu);
47 /*--lowlevel routine not to be called by the user--*/
49 WMenu *mod_menu_do_grabmenu(WMPlex *mplex, ExtlFn handler, ExtlTab tab,
52 WMenuCreateParams fnp;
53 WMPlexAttachParams par;
57 ev=ioncore_current_key_event();
65 fnp.submenu_mode=FALSE;
66 fnp.big_mode=extl_table_is_bool_set(param, "big");
68 extl_table_gets_i(param, "initial", &(fnp.initial));
70 par.flags=(MPLEX_ATTACH_SWITCHTO|
71 MPLEX_ATTACH_UNNUMBERED|
72 MPLEX_ATTACH_SIZEPOLICY);
73 par.szplcy=SIZEPOLICY_FULL_BOUNDS;
75 menu=(WMenu*)mplex_do_attach_new(mplex, &par,
76 (WRegionCreateFn*)create_menu,
82 menu->gm_kcb=ev->keycode;
83 menu->gm_state=ev->state;
85 ioncore_grab_establish((WRegion*)menu, grabmenu_handler, NULL, 0);