-#define METH(n, d) {#n, (PyCFunction)keyb_##n, METH_VARARGS, #d}
-
-static PyMethodDef KeyboardMethods[] = {
- METH(bind,
- "bind(keychain, func)\n\n"
- "Binds a key-chain to a function. The keychain is a tuple of strings "
- "which define a chain of key presses. Each member of the tuple has "
- "the format [Modifier-]...[Key]. Modifiers can be 'mod1', 'mod2', "
- "'mod3', 'mod4', 'mod5', 'control', and 'shift'. The keys on your "
- "keyboard that are bound to each of these modifiers can be found by "
- "running 'xmodmap'. The Key can be any valid key definition. Key "
- "definitions can be found by running 'xev', pressing the key while "
- "its window is focused, and watching its output. Here are some "
- "examples of valid keychains: ('a'), ('F7'), ('control-a', 'd'), "
- "('control-mod1-x', 'control-mod4-g'), ('F1', 'space'). The func "
- "must have a definition similar to 'def func(keydata, client)'. A "
- "keychain cannot be bound to more than one function."),
- METH(clearBinds,
- "clearBinds()\n\n"
- "Removes all bindings that were previously made by bind()."),
- METH(grab,
- "grab(func)\n\n"
- "Grabs the entire keyboard, causing all possible keyboard events to "
- "be passed to the given function. CAUTION: Be sure when you grab() "
- "that you also have an ungrab() that will execute, or you will not "
- "be able to type until you restart Openbox. The func must have a "
- "definition similar to 'def func(keydata)'. The keyboard cannot be "
- "grabbed if it is already grabbed."),
- METH(ungrab,
- "ungrab()\n\n"
- "Ungrabs the keyboard. The keyboard cannot be ungrabbed if it is not "
- "grabbed."),
- { NULL, NULL, 0, NULL }
-};
-
-/***************************************************************************
-
- Type methods/struct
-
- ***************************************************************************/
-
-static void keyb_dealloc(PyObject *self)
-{
- PyObject_Del(self);
+ if (curpos == NULL)
+ p = keyboard_firstnode;
+ else
+ p = curpos->first_child;
+ while (p) {
+ if (p->key == e->xkey.keycode &&
+ p->state == e->xkey.state) {
+ if (p->first_child != NULL) { /* part of a chain */
+ ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
+ /* 5 second timeout for chains */
+ ob_main_loop_timeout_add(ob_main_loop, 5 * G_USEC_PER_SEC,
+ chain_timeout, NULL, NULL);
+ grab_keys(FALSE);
+ curpos = p;
+ grab_keys(TRUE);
+ } else {
+ GSList *it;
+ for (it = p->actions; it; it = it->next) {
+ ObAction *act = it->data;
+ if (act->func != NULL) {
+ act->data.any.c = client;
+
+ if (act->func == action_moveresize) {
+ screen_pointer_pos(&act->data.moveresize.x,
+ &act->data.moveresize.y);
+ }
+
+ if (act->data.any.interactive) {
+ act->data.inter.cancel = FALSE;
+ act->data.inter.final = FALSE;
+ keyboard_interactive_grab(e->xkey.state, client,
+ 0, act);
+ }
+
+ if (act->func == action_showmenu) {
+ act->data.showmenu.x = e->xkey.x_root;
+ act->data.showmenu.y = e->xkey.y_root;
+ }
+
+ act->data.any.c = client;
+ act->func(&act->data);
+ }
+ }
+
+ keyboard_reset_chains();
+ }
+ break;
+ }
+ p = p->next_sibling;
+ }