Add grab option to <keybind> to not grab the keycombo. This is for example to let...
authorMikael Magnusson <mikachu@comhem.se>
Mon, 23 Jul 2007 23:44:15 +0000 (01:44 +0200)
committerMikael Magnusson <mikachu@comhem.se>
Wed, 16 Jan 2008 06:19:58 +0000 (07:19 +0100)
openbox/config.c
openbox/keyboard.c
openbox/keyboard.h
openbox/keytree.c
openbox/keytree.h

index 0f886ccad00a497369ef6b03acfaf45b5ce5304d..d7418e688f4ab0f3bbd99db8908f08768f03fda4 100644 (file)
@@ -347,11 +347,13 @@ static void parse_key(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
     gchar *key;
     xmlNodePtr n;
     gboolean is_chroot = FALSE;
+    gboolean grab = TRUE;
 
     if (!parse_attr_string("key", node, &key))
         return;
 
     parse_attr_bool("chroot", node, &is_chroot);
+    parse_attr_bool("grab", node, &grab);
 
     keylist = g_list_append(keylist, key);
 
@@ -367,7 +369,7 @@ static void parse_key(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
 
             action = actions_parse(i, doc, n);
             if (action)
-                keyboard_bind(keylist, action);
+                keyboard_bind(keylist, action, grab);
             n = parse_find_node("action", n->next);
         }
     }
@@ -799,7 +801,7 @@ static void bind_default_keyboard()
     };
     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 6e45e5c49b6ddd624f4b46462bc1fc948729f310..bb4e4fce3c4653346c15d24ec9af31b471586316 100644 (file)
@@ -51,8 +51,9 @@ static void grab_keys(gboolean grab)
     if (grab) {
         p = curpos ? curpos->first_child : keyboard_firstnode;
         while (p) {
-            grab_key(p->key, p->state, RootWindow(ob_display, ob_screen),
-                     GrabModeAsync);
+            if (p->grab)
+                grab_key(p->key, p->state, RootWindow(ob_display, ob_screen),
+                         GrabModeAsync);
             p = p->next_sibling;
         }
         if (curpos)
@@ -127,14 +128,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;
@@ -142,7 +143,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) {
index 1c55e05079a8b673b776ffa656a2143e42a1d7c9..b3fa43cf7fafe6798b4cab6adcbeaa1d042e0c58 100644 (file)
@@ -35,7 +35,7 @@ void keyboard_startup(gboolean reconfig);
 void keyboard_shutdown(gboolean reconfig);
 
 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 keyboard_event(struct _ObClient *client, const XEvent *e);
index fb26624d0732d88105c97094d036137d5d5fcf9d..c167495ddd0ac9db09cb83f4367667c4b1df4291 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;
         if (!translate_key(it->data, &ret->state, &ret->key)) {
             tree_destroy(ret);
index 391cb154fb91a5cc61c2f12ac8771dd8a17b91b3..cf9e802826beb03e4a7591d809d745ad90837d6a 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);