]> Dogcows Code - chaz/openbox/blobdiff - plugins/keyboard/keyboard.c
not being developed anymore, maybe in the future...
[chaz/openbox] / plugins / keyboard / keyboard.c
index 5edd62917a9fb6728dc7071951326dec85f11e88..d1d93241a77e5422ace3440325179aa475f3b341 100644 (file)
@@ -4,17 +4,74 @@
 #include "kernel/event.h"
 #include "kernel/grab.h"
 #include "kernel/action.h"
+#include "kernel/prop.h"
 #include "kernel/parse.h"
 #include "kernel/timer.h"
 #include "tree.h"
 #include "keyboard.h"
-#include "keyparse.h"
 #include "translate.h"
 #include <glib.h>
 
+/*
+
+<keybind key="C-x">
+  <action name="ChangeDesktop">
+    <desktop>3</desktop>
+  </action>
+</keybind>
+
+*/
+
+static void parse_key(xmlDocPtr doc, xmlNodePtr node, GList *keylist)
+{
+    char *key;
+    Action *action;
+    xmlNodePtr n, nact;
+    GList *it;
+
+    n = parse_find_node("keybind", node);
+    while (n) {
+        if (parse_attr_string("key", n, &key)) {
+            keylist = g_list_append(keylist, key);
+
+            parse_key(doc, n->xmlChildrenNode, keylist);
+
+            it = g_list_last(keylist);
+            g_free(it->data);
+            keylist = g_list_delete_link(keylist, it);
+        }
+        n = parse_find_node("keybind", n->next);
+    }
+    if (keylist) {
+        nact = parse_find_node("action", node);
+        while (nact) {
+            if ((action = parse_action(doc, nact))) {
+                /* validate that its okay for a key binding */
+                if (action->func == action_moveresize &&
+                    action->data.moveresize.corner !=
+                    prop_atoms.net_wm_moveresize_move_keyboard &&
+                    action->data.moveresize.corner !=
+                    prop_atoms.net_wm_moveresize_size_keyboard) {
+                    action_free(action);
+                    action = NULL;
+                }
+
+                if (action)
+                    kbind(keylist, action);
+            }
+            nact = parse_find_node("action", nact->next);
+        }
+    }
+}
+
+static void parse_xml(xmlDocPtr doc, xmlNodePtr node, void *d)
+{
+    parse_key(doc, node, NULL);
+}
+
 void plugin_setup_config()
 {
-    parse_reg_section("keyboard", keyparse, NULL);
+    parse_register("keyboard", parse_xml, NULL);
 }
 
 KeyBindingTree *firstnode = NULL;
@@ -34,7 +91,8 @@ static void grab_keys()
         grab_key(p->key, p->state, GrabModeAsync);
         p = p->next_sibling;
     }
-    grab_key(reset_key, reset_state, GrabModeAsync);
+    if (curpos)
+        grab_key(reset_key, reset_state, GrabModeAsync);
 }
 
 static void reset_chains()
@@ -116,11 +174,11 @@ static void event(ObEvent *e, void *foo)
                 Action *act = it->data;
                 act->data.cycle.final = TRUE;
                 act->func(&act->data);
-                grabbed_key = NULL;
-                grab_keyboard(FALSE);
-                reset_chains();
-                return;
             }
+            grabbed_key = NULL;
+            grab_keyboard(FALSE);
+            reset_chains();
+            return;
         }
     }
     if (e->type == Event_X_KeyRelease)
@@ -159,6 +217,7 @@ static void event(ObEvent *e, void *foo)
                                 act->data.cycle.cancel = FALSE;
                             }
 
+                            act->data.any.c = focus_client;
                             act->func(&act->data);
 
                             if (act->func == action_cycle_windows &&
This page took 0.021329 seconds and 4 git commands to generate.