Add grab option to <keybind> to not grab the keycombo.
authorMikael Magnusson <mikachu@comhem.se>
Mon, 23 Jul 2007 23:44:15 +0000 (01:44 +0200)
committerMikael Magnusson <mikachu@comhem.se>
Sat, 8 Mar 2008 16:24:42 +0000 (17:24 +0100)
This is for example to let you bind stuff to the Alt key while alt-tabbing,
but you don't want those keys to be grabbed in normal usage.

openbox/config.c
openbox/keyboard.c
openbox/keyboard.h
openbox/keytree.c
openbox/keytree.h

index cc86ce7cfa748fbc0da12148485a25ce2f396d05..c18ddd570e409a545b10b423c4c01db712b8af59 100644 (file)
@@ -399,11 +399,13 @@ static void parse_key(xmlNodePtr node, GList *keylist)
     gchar *key;
     xmlNodePtr n;
     gboolean is_chroot = FALSE;
+    gboolean grab = TRUE;
 
     if (!obt_parse_attr_string(node, "key", &key))
         return;
 
     obt_parse_attr_bool(node, "chroot", &is_chroot);
+    obt_parse_attr_bool(node, "grab", &grab);
 
     keylist = g_list_append(keylist, key);
 
@@ -419,7 +421,7 @@ static void parse_key(xmlNodePtr node, GList *keylist)
 
             action = actions_parse(n);
             if (action)
-                keyboard_bind(keylist, action);
+                keyboard_bind(keylist, action, grab);
             n = obt_parse_find_node(n->next, "action");
         }
     }
@@ -865,7 +867,7 @@ static void bind_default_keyboard(void)
     };
     for (it = binds; it->key; ++it) {
         GList *l = g_list_append(NULL, g_strdup(it->key));
-        keyboard_bind(l, actions_parse_string(it->actname));
+        keyboard_bind(l, actions_parse_string(it->actname), TRUE);
     }
 }
 
index a693a71c3d63ca3ea287aec1ce440f16b125c61f..ca3992d501f10403efa505d3e4c7b24ea83a064d 100644 (file)
@@ -49,7 +49,7 @@ static void grab_keys(gboolean grab)
     if (grab) {
         p = curpos ? curpos->first_child : keyboard_firstnode;
         while (p) {
-            if (p->key)
+            if (p->key && p->grab)
                 grab_key(p->key, p->state, obt_root(ob_screen),
                          GrabModeSync);
             p = p->next_sibling;
@@ -126,14 +126,14 @@ void keyboard_chroot(GList *keylist)
        chroot binding. so add it to the tree then. */
     if (!tree_chroot(keyboard_firstnode, keylist)) {
         KeyBindingTree *tree;
-        if (!(tree = tree_build(keylist)))
+        if (!(tree = tree_build(keylist, TRUE)))
             return;
         tree_chroot(tree, keylist);
         tree_assimilate(tree);
     }
 }
 
-gboolean keyboard_bind(GList *keylist, ObActionsAct *action)
+gboolean keyboard_bind(GList *keylist, ObActionsAct *action, gboolean grab)
 {
     KeyBindingTree *tree, *t;
     gboolean conflict;
@@ -141,7 +141,7 @@ gboolean keyboard_bind(GList *keylist, ObActionsAct *action)
     g_assert(keylist != NULL);
     g_assert(action != NULL);
 
-    if (!(tree = tree_build(keylist)))
+    if (!(tree = tree_build(keylist, grab)))
         return FALSE;
 
     if ((t = tree_find(tree, &conflict)) != NULL) {
@@ -282,7 +282,7 @@ static void node_rebind(KeyBindingTree *node)
         while (node->actions) {
             /* add each action, and remove them from the original tree so
                they don't get free'd on us */
-            keyboard_bind(node->keylist, node->actions->data);
+            keyboard_bind(node->keylist, node->actions->data, node->grab);
             node->actions = g_slist_delete_link(node->actions, node->actions);
         }
 
index 1674cf92bf3470fb0ef6fc5d503e23999c437889..7ffd198b6a597fa2948fa669bbc92be0cc71560d 100644 (file)
@@ -37,7 +37,7 @@ void keyboard_shutdown(gboolean reconfig);
 void keyboard_rebind(void);
 
 void keyboard_chroot(GList *keylist);
-gboolean keyboard_bind(GList *keylist, struct _ObActionsAct *action);
+gboolean keyboard_bind(GList *keylist, struct _ObActionsAct *action, gboolean grab);
 void keyboard_unbind_all(void);
 
 void keyboard_event(struct _ObClient *client, const XEvent *e);
index ca64385a249ffefaddae53892939217f2373c343..310f9bd72837c96b33ce3bbdf857e277620bc6db 100644 (file)
@@ -44,7 +44,7 @@ void tree_destroy(KeyBindingTree *tree)
     }
 }
 
-KeyBindingTree *tree_build(GList *keylist)
+KeyBindingTree *tree_build(GList *keylist, gboolean grab)
 {
     GList *it;
     KeyBindingTree *ret = NULL, *p;
@@ -62,6 +62,7 @@ KeyBindingTree *tree_build(GList *keylist)
             ret->keylist = g_list_prepend(ret->keylist,
                                           g_strdup(kit->data)); /* deep copy */
         ret->first_child = p;
+        ret->grab = grab;
         if (p != NULL) p->parent = ret;
         translate_key(it->data, &ret->state, &ret->key);
     }
index 66edc3c7faf0af58ba57827370debed953d6c74d..6b37606665af42d8f9f914763ef9126954df681f 100644 (file)
@@ -24,6 +24,7 @@
 typedef struct KeyBindingTree {
     guint state;
     guint key;
+    gboolean grab;
     GList *keylist;
     GSList *actions; /* list of Action pointers */
     gboolean chroot;
@@ -37,7 +38,7 @@ typedef struct KeyBindingTree {
 } KeyBindingTree;
 
 void tree_destroy(KeyBindingTree *tree);
-KeyBindingTree *tree_build(GList *keylist);
+KeyBindingTree *tree_build(GList *keylist, gboolean grab);
 void tree_assimilate(KeyBindingTree *node);
 KeyBindingTree *tree_find(KeyBindingTree *search, gboolean *conflict);
 gboolean tree_chroot(KeyBindingTree *tree, GList *keylist);