]>
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
)))
54 if ((t
= tree_find(tree
, &conflict
)) != NULL
) {
55 /* already bound to something */
56 g_warning("keychain is already bound");
61 g_warning("conflict with binding");
66 /* grab the server here to make sure no key presses go missed */
72 while (t
->first_child
) t
= t
->first_child
;
74 /* assimilate this built tree into the main tree. assimilation
75 destroys/uses the tree */
76 tree_assimilate(tree
);
84 static void press(ObEvent
*e
, void *foo
)
86 if (e
->data
.x
.e
->xkey
.keycode
== reset_key
&&
87 e
->data
.x
.e
->xkey
.state
== reset_state
) {
94 p
= curpos
->first_child
;
96 if (p
->key
== e
->data
.x
.e
->xkey
.keycode
&&
97 p
->state
== e
->data
.x
.e
->xkey
.state
) {
98 if (p
->first_child
!= NULL
) { /* part of a chain */
106 if (p
->action
->func
!= NULL
) {
107 p
->action
->data
.any
.c
= focus_client
;
109 g_assert(!(p
->action
->func
== action_move
||
110 p
->action
->func
== action_resize
));
112 p
->action
->func(&p
->action
->data
);
122 XAllowEvents(ob_display
, AsyncKeyboard
, e
->data
.x
.e
->xkey
.time
);
125 void plugin_startup()
127 dispatch_register(Event_X_KeyPress
, (EventHandler
)press
, NULL
);
132 void plugin_shutdown()
134 dispatch_register(0, (EventHandler
)press
, NULL
);
137 tree_destroy(firstnode
);
This page took 0.041892 seconds and 4 git commands to generate.