]>
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/event.h"
5 #include "../../kernel/grab.h"
6 #include "../../kernel/action.h"
10 #include "translate.h"
13 void plugin_setup_config()
17 KeyBindingTree
*firstnode
;
19 static KeyBindingTree
*curpos
;
20 static guint reset_key
, reset_state
;
21 static gboolean grabbed
;
23 static void grab_keys(gboolean grab
)
28 KeyBindingTree
*p
= firstnode
;
30 grab_key(p
->key
, p
->state
, GrabModeSync
);
36 static void reset_chains()
44 XAllowEvents(ob_display
, AsyncKeyboard
, event_lasttime
);
47 gboolean
kbind(GList
*keylist
, Action
*action
)
49 KeyBindingTree
*tree
, *t
;
52 g_assert(keylist
!= NULL
);
53 g_assert(action
!= NULL
);
55 if (!(tree
= tree_build(keylist
)))
57 if ((t
= tree_find(tree
, &conflict
)) != NULL
) {
58 /* already bound to something */
59 g_warning("keychain is already bound");
64 g_warning("conflict with binding");
69 /* grab the server here to make sure no key presses go missed */
75 while (t
->first_child
) t
= t
->first_child
;
77 /* assimilate this built tree into the main tree. assimilation
78 destroys/uses the tree */
79 tree_assimilate(tree
);
87 static void press(ObEvent
*e
, void *foo
)
89 if (e
->data
.x
.e
->xkey
.keycode
== reset_key
&&
90 e
->data
.x
.e
->xkey
.state
== reset_state
) {
97 p
= curpos
->first_child
;
99 if (p
->key
== e
->data
.x
.e
->xkey
.keycode
&&
100 p
->state
== e
->data
.x
.e
->xkey
.state
) {
101 if (p
->first_child
!= NULL
) { /* part of a chain */
106 XAllowEvents(ob_display
, AsyncKeyboard
,
111 if (p
->action
->func
!= NULL
) {
112 p
->action
->data
.any
.c
= focus_client
;
114 g_assert(!(p
->action
->func
== action_move
||
115 p
->action
->func
== action_resize
));
117 p
->action
->func(&p
->action
->data
);
129 void plugin_startup()
131 dispatch_register(Event_X_KeyPress
, (EventHandler
)press
, NULL
);
133 translate_key("C-g", &reset_state
, &reset_key
);
138 void plugin_shutdown()
140 dispatch_register(0, (EventHandler
)press
, NULL
);
143 tree_destroy(firstnode
);
This page took 0.044962 seconds and 4 git commands to generate.