]> Dogcows Code - chaz/openbox/blobdiff - openbox/mouse.c
using the ObMainLoop, which rulz the planet
[chaz/openbox] / openbox / mouse.c
index 93d00784fb7232638f616795d8f7c1ce4c876dfc..2e8507c347784011916350573a336a0f5cd9ec3f 100644 (file)
@@ -1,5 +1,6 @@
 #include "openbox.h"
 #include "config.h"
+#include "xerror.h"
 #include "action.h"
 #include "event.h"
 #include "client.h"
@@ -17,9 +18,9 @@ typedef struct {
     GSList *actions[OB_MOUSE_NUM_ACTIONS]; /* lists of Action pointers */
 } ObMouseBinding;
 
-#define CLIENT_CONTEXT(co, cl) (co == OB_FRAME_CONTEXT_CLIENT || \
-                                (co == OB_FRAME_CONTEXT_ROOT && \
-                                 cl->type == OB_CLIENT_TYPE_DESKTOP))
+#define CLIENT_CONTEXT(co, cl) ((cl && cl->type == OB_CLIENT_TYPE_DESKTOP) ? \
+                                co == OB_FRAME_CONTEXT_DESKTOP : \
+                                co == OB_FRAME_CONTEXT_CLIENT)
 
 /* Array of GSList*s of PointerBinding*s. */
 static GSList *bound_contexts[OB_FRAME_NUM_CONTEXTS];
@@ -202,7 +203,7 @@ void mouse_event(ObClient *client, ObFrameContext context, XEvent *e)
     static int px, py;
     gboolean click = FALSE;
     gboolean dclick = FALSE;
-    
+
     switch (e->type) {
     case ButtonPress:
         px = e->xbutton.x_root;
@@ -228,27 +229,31 @@ void mouse_event(ObClient *client, ObFrameContext context, XEvent *e)
             int junk1, junk2;
             Window wjunk;
             guint ujunk, b, w, h;
-            XGetGeometry(ob_display, e->xbutton.window,
-                         &wjunk, &junk1, &junk2, &w, &h, &b, &ujunk);
-            if (e->xbutton.x >= (signed)-b &&
-                e->xbutton.y >= (signed)-b &&
-                e->xbutton.x < (signed)(w+b) &&
-                e->xbutton.y < (signed)(h+b)) {
-                click = TRUE;
-                /* double clicks happen if there were 2 in a row! */
-                if (lbutton == button &&
-                    lwindow == e->xbutton.window &&
-                    e->xbutton.time - config_mouse_dclicktime <=
-                    ltime) {
-                    dclick = TRUE;
-                    lbutton = 0;
+            xerror_set_ignore(TRUE);
+            junk1 = XGetGeometry(ob_display, e->xbutton.window,
+                                 &wjunk, &junk1, &junk2, &w, &h, &b, &ujunk);
+            xerror_set_ignore(FALSE);
+            if (junk1) {
+                if (e->xbutton.x >= (signed)-b &&
+                    e->xbutton.y >= (signed)-b &&
+                    e->xbutton.x < (signed)(w+b) &&
+                    e->xbutton.y < (signed)(h+b)) {
+                    click = TRUE;
+                    /* double clicks happen if there were 2 in a row! */
+                    if (lbutton == button &&
+                        lwindow == e->xbutton.window &&
+                        e->xbutton.time - config_mouse_dclicktime <=
+                        ltime) {
+                        dclick = TRUE;
+                        lbutton = 0;
+                    } else {
+                        lbutton = button;
+                        lwindow = e->xbutton.window;
+                    }
                 } else {
-                    lbutton = button;
-                    lwindow = e->xbutton.window;
+                    lbutton = 0;
+                    lwindow = None;
                 }
-            } else {
-                lbutton = 0;
-                lwindow = None;
             }
 
             button = 0;
This page took 0.025256 seconds and 4 git commands to generate.