]> Dogcows Code - chaz/openbox/commitdiff
use the grab.h funcs to grab keys and buttons
authorDana Jansens <danakj@orodu.net>
Wed, 19 Mar 2003 18:56:15 +0000 (18:56 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 19 Mar 2003 18:56:15 +0000 (18:56 +0000)
plugins/keyboard/keyboard.c
plugins/mouse/mouse.c

index 141bb5b1a1e2a706918c021e777d053caf5025c2..a559e3f03cef79cba6a7e2d941530e49bebd56c3 100644 (file)
@@ -16,13 +16,11 @@ static gboolean grabbed;
 static void grab_keys(gboolean grab)
 {
     if (!grab) {
-       XUngrabKey(ob_display, AnyKey, AnyModifier, ob_root);
+        ungrab_all_keys();
     } else {
        KeyBindingTree *p = firstnode;
        while (p) {
-            /* XXX grab all lock keys too */
-           XGrabKey(ob_display, p->key, p->state, ob_root, FALSE,
-                    GrabModeAsync, GrabModeSync);
+            grab_key(p->key, p->state, GrabModeSync);
            p = p->next_sibling;
        }
     }
index ad332982b53cb8983bec8d7a66dbcd4943fcf573..0cb6b5c0095213a7bdd423bf5c1062668cfa784b 100644 (file)
@@ -3,6 +3,7 @@
 #include "../../kernel/action.h"
 #include "../../kernel/client.h"
 #include "../../kernel/frame.h"
+#include "../../kernel/grab.h"
 #include "../../kernel/engine.h"
 #include "translate.h"
 #include "mouse.h"
@@ -16,40 +17,33 @@ struct foreach_grab_temp {
     gboolean grab;
 };
 
-static void grab_button(Client *client, guint state, guint button,
-                       GQuark context, gboolean grab)
-{
-    Window win;
-    int mode = GrabModeAsync;
-    unsigned int mask;
-
-    if (context == g_quark_try_string("frame")) {
-       win = client->frame->window;
-       mask = ButtonPressMask | ButtonMotionMask | ButtonReleaseMask;
-    } else if (context == g_quark_try_string("client")) {
-       win = client->frame->plate;
-       mode = GrabModeSync; /* this is handled in pointer_event */
-       mask = ButtonPressMask; /* can't catch more than this with Sync mode
-                                  the release event is manufactured in
-                                  pointer_fire */
-    } else return;
-
-    if (grab)
-        /* XXX grab all lock keys */
-       XGrabButton(ob_display, button, state, win, FALSE, mask, mode,
-                   GrabModeAsync, None, None);
-    else
-        /* XXX ungrab all lock keys */
-       XUngrabButton(ob_display, button, state, win);
-}
-
 static void foreach_grab(GQuark key, gpointer data, gpointer user_data)
 {
     struct foreach_grab_temp *d = user_data;
     GSList *it;
     for (it = data; it != NULL; it = it->next) {
+        /* grab/ungrab the button */
        MouseBinding *b = it->data;
-       grab_button(d->client, b->state, b->button, key, d->grab);
+        Window win;
+        int mode;
+        unsigned int mask;
+
+        if (key == g_quark_try_string("frame")) {
+            win = d->client->frame->window;
+            mode = GrabModeAsync;
+            mask = ButtonPressMask | ButtonMotionMask | ButtonReleaseMask;
+        } else if (key == g_quark_try_string("client")) {
+            win = d->client->frame->plate;
+            mode = GrabModeSync; /* this is handled in event */
+            mask = ButtonPressMask; /* can't catch more than this with Sync
+                                       mode the release event is manufactured
+                                       in event */
+        } else return;
+
+        if (d->grab)
+            grab_button(b->button, b->state, win, mask, mode);
+        else
+            ungrab_button(b->button, b->state, win);
     }
 }
   
This page took 0.025209 seconds and 4 git commands to generate.