]> git.decadent.org.uk Git - ion3.git/blob - ioncore/binding.h
a776a64f92dc57f3ae2a588dc4734e9a5f6c4df3
[ion3.git] / ioncore / binding.h
1 /*
2  * ion/ioncore/binding.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  *
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.
10  */
11
12 #ifndef ION_IONCORE_BINDING_H
13 #define ION_IONCORE_BINDING_H
14
15 #include <libtu/obj.h>
16 #include <libtu/rb.h>
17 #include <libtu/map.h>
18 #include "common.h"
19 #include "region.h"
20 #include <libextl/extl.h>
21
22
23 #define BINDING_KEYPRESS        0
24 #define BINDING_BUTTONPRESS     1
25 #define BINDING_BUTTONMOTION    2
26 #define BINDING_BUTTONCLICK     3
27 #define BINDING_BUTTONDBLCLICK  4
28
29 #define BINDMAP_INIT        {0, NULL, NULL, NULL, NULL}
30
31 #define FOR_ALL_BINDINGS(B, NODE, MAP) \
32         rb_traverse(NODE, MAP) if(((B)=(WBinding*)rb_val(NODE))!=NULL)
33
34 INTRSTRUCT(WBinding);
35 INTRSTRUCT(WBindmap);
36 INTRSTRUCT(WRegBindingInfo);
37
38
39 DECLSTRUCT(WBinding){
40     uint kcb; /* keycode or button */
41     uint ksb; /* keysym or button */
42     uint state;
43     uint act;
44     int area;
45     bool wait;
46     WBindmap *submap;
47     ExtlFn func;
48 };
49
50
51
52 DECLSTRUCT(WRegBindingInfo){
53     WBindmap *bindmap;
54     WRegBindingInfo *next, *prev;
55     WRegBindingInfo *bm_next, *bm_prev;
56     WRegion *reg;
57     WRegion *owner;
58     int tmp;
59 };
60
61
62
63 DECLSTRUCT(WBindmap){
64     int nbindings;
65     Rb_node bindings;
66     WRegBindingInfo *rbind_list;
67     const StringIntMap *areamap;
68 };
69
70
71 extern void ioncore_init_bindings();
72 extern void ioncore_update_modmap();
73 extern int ioncore_unmod(int state, int keycode);
74 extern bool ioncore_ismod(int keycode);
75 extern int ioncore_modstate();
76
77 extern WBindmap *create_bindmap();
78
79 extern void bindmap_destroy(WBindmap *bindmap);
80 extern void bindmap_refresh(WBindmap *bindmap);
81 extern bool bindmap_add_binding(WBindmap *bindmap, const WBinding *binding);
82 extern bool bindmap_remove_binding(WBindmap *bindmap, const WBinding *binding);
83 extern WBinding *bindmap_lookup_binding(WBindmap *bindmap, int act,
84                                 uint state, uint kcb);
85 extern WBinding *bindmap_lookup_binding_area(WBindmap *bindmap, int act,
86                                      uint state, uint kcb, int area);
87
88 extern void binding_deinit(WBinding *binding);
89 extern void binding_grab_on(const WBinding *binding, Window win);
90 extern void binding_ungrab_on(const WBinding *binding, Window win);
91
92 #endif /* ION_IONCORE_BINDING_H */