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.
gchar *keystring, **keys, **key;
xmlNodePtr n;
gboolean is_chroot = FALSE;
gchar *keystring, **keys, **key;
xmlNodePtr n;
gboolean is_chroot = FALSE;
if (!obt_xml_attr_string(node, "key", &keystring))
return;
obt_xml_attr_bool(node, "chroot", &is_chroot);
if (!obt_xml_attr_string(node, "key", &keystring))
return;
obt_xml_attr_bool(node, "chroot", &is_chroot);
+ obt_xml_attr_bool(node, "grab", &grab);
keys = g_strsplit(keystring, " ", 0);
for (key = keys; *key; ++key) {
keys = g_strsplit(keystring, " ", 0);
for (key = keys; *key; ++key) {
action = actions_parse(n);
if (action)
action = actions_parse(n);
if (action)
- keyboard_bind(keylist, action);
+ keyboard_bind(keylist, action, grab);
n = obt_xml_find_node(n->next, "action");
}
}
n = obt_xml_find_node(n->next, "action");
}
}
};
for (it = binds; it->key; ++it) {
GList *l = g_list_append(NULL, g_strdup(it->key));
};
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);
if (grab) {
p = curpos ? curpos->first_child : keyboard_firstnode;
while (p) {
if (grab) {
p = curpos ? curpos->first_child : keyboard_firstnode;
while (p) {
grab_key(p->key, p->state, obt_root(ob_screen),
GrabModeAsync);
p = p->next_sibling;
grab_key(p->key, p->state, obt_root(ob_screen),
GrabModeAsync);
p = p->next_sibling;
chroot binding. so add it to the tree then. */
if (!tree_chroot(keyboard_firstnode, keylist)) {
KeyBindingTree *tree;
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);
}
}
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;
{
KeyBindingTree *tree, *t;
gboolean conflict;
g_assert(keylist != NULL);
g_assert(action != NULL);
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) {
return FALSE;
if ((t = tree_find(tree, &conflict)) != NULL) {
while (node->actions) {
/* add each action, and remove them from the original tree so
they don't get free'd on us */
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);
}
node->actions = g_slist_delete_link(node->actions, node->actions);
}
void keyboard_rebind(void);
void keyboard_chroot(GList *keylist);
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);
gboolean keyboard_event(struct _ObClient *client, const XEvent *e);
void keyboard_unbind_all(void);
gboolean keyboard_event(struct _ObClient *client, const XEvent *e);
-KeyBindingTree *tree_build(GList *keylist)
+KeyBindingTree *tree_build(GList *keylist, gboolean grab)
{
GList *it;
KeyBindingTree *ret = NULL, *p;
{
GList *it;
KeyBindingTree *ret = NULL, *p;
ret->keylist = g_list_prepend(ret->keylist,
g_strdup(kit->data)); /* deep copy */
ret->first_child = p;
ret->keylist = g_list_prepend(ret->keylist,
g_strdup(kit->data)); /* deep copy */
ret->first_child = p;
if (p != NULL) p->parent = ret;
translate_key(it->data, &ret->state, &ret->key);
}
if (p != NULL) p->parent = ret;
translate_key(it->data, &ret->state, &ret->key);
}
typedef struct KeyBindingTree {
guint state;
guint key;
typedef struct KeyBindingTree {
guint state;
guint key;
GList *keylist;
GSList *actions; /* list of Action pointers */
gboolean chroot;
GList *keylist;
GSList *actions; /* list of Action pointers */
gboolean chroot;
} KeyBindingTree;
void tree_destroy(KeyBindingTree *tree);
} 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);
void tree_assimilate(KeyBindingTree *node);
KeyBindingTree *tree_find(KeyBindingTree *search, gboolean *conflict);
gboolean tree_chroot(KeyBindingTree *tree, GList *keylist);