]>
Dogcows Code - chaz/openbox/blob - plugins/keyboard/keyboard.c
1 #include "../../kernel/focus.h"
2 #include "../../kernel/dispatch.h"
3 #include "../../kernel/openbox.h"
4 #include "../../kernel/grab.h"
5 #include "../../kernel/action.h"
11 void plugin_setup_config()
15 KeyBindingTree
*firstnode
;
17 static KeyBindingTree
*curpos
;
18 static guint reset_key
, reset_state
;
19 static gboolean grabbed
;
21 static void grab_keys(gboolean grab
)
26 KeyBindingTree
*p
= firstnode
;
28 grab_key(p
->key
, p
->state
, GrabModeSync
);
34 static void reset_chains()
44 gboolean
kbind(GList
*keylist
, Action
*action
)
46 KeyBindingTree
*tree
, *t
;
49 g_assert(keylist
!= NULL
);
50 g_assert(action
!= NULL
);
52 if (!(tree
= tree_build(keylist
))) {
53 g_warning("invalid binding");
56 if ((t
= tree_find(tree
, &conflict
)) != NULL
) {
57 /* already bound to something */
58 g_warning("keychain is already bound");
63 g_warning("conflict with binding");
68 /* grab the server here to make sure no key presses go missed */
74 while (t
->first_child
) t
= t
->first_child
;
76 /* assimilate this built tree into the main tree. assimilation
77 destroys/uses the tree */
78 tree_assimilate(tree
);
86 static void press(ObEvent
*e
, void *foo
)
88 if (e
->data
.x
.e
->xkey
.keycode
== reset_key
&&
89 e
->data
.x
.e
->xkey
.state
== reset_state
) {
96 p
= curpos
->first_child
;
98 if (p
->key
== e
->data
.x
.e
->xkey
.keycode
&&
99 p
->state
== e
->data
.x
.e
->xkey
.state
) {
100 if (p
->first_child
!= NULL
) { /* part of a chain */
108 if (p
->action
->func
!= NULL
) {
109 p
->action
->data
.any
.c
= focus_client
;
111 g_assert(!(p
->action
->func
== action_move
||
112 p
->action
->func
== action_resize
));
114 p
->action
->func(&p
->action
->data
);
124 XAllowEvents(ob_display
, AsyncKeyboard
, e
->data
.x
.e
->xkey
.time
);
127 void plugin_startup()
129 dispatch_register(Event_X_KeyPress
, (EventHandler
)press
, NULL
);
134 void plugin_shutdown()
136 dispatch_register(0, (EventHandler
)press
, NULL
);
139 tree_destroy(firstnode
);
This page took 0.042843 seconds and 5 git commands to generate.