[hackers] [wmii] Improvements to button grabs

From: Kris Maglione <jg_AT_suckless.org>
Date: Fri Feb 09 22:28:16 2007

changeset: 1812:761af72a793e
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Fri Feb 09 16:26:23 2007 -0500
summary: Improvements to button grabs

diff -r 01cbfde535d4 -r 761af72a793e client.c
--- a/client.c Fri Feb 09 14:06:24 2007 -0500
+++ b/client.c Fri Feb 09 16:26:23 2007 -0500
@@ -44,17 +44,17 @@ create_client(Window w, XWindowAttribute
         fwa.background_pixmap = ParentRelative;
         fwa.event_mask =
                 SubstructureRedirectMask | SubstructureNotifyMask | ExposureMask
- | ButtonPressMask | PointerMotionMask | ButtonReleaseMask | KeyPressMask;
+ | PointerMotionMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask;
         c->framewin = XCreateWindow(blz.dpy, blz.root, c->rect.x, c->rect.y,
                         c->rect.width + 2 * def.border,
                         c->rect.height + def.border + labelh(&def.font), 0,
                         DefaultDepth(blz.dpy, blz.screen), CopyFromParent,
                         DefaultVisual(blz.dpy, blz.screen),
                         CWOverrideRedirect | CWBackPixmap | CWEventMask, &fwa);
- XGrabButton(blz.dpy, Button1, AnyModifier, c->framewin, False, ButtonMask,
- GrabModeSync, GrabModeSync, None, None);
- XGrabButton(blz.dpy, Button3, AnyModifier, c->framewin, False, ButtonMask,
- GrabModeSync, GrabModeSync, None, None);
+ XGrabButton(blz.dpy, Button1, AnyModifier, c->framewin, True, ButtonMask,
+ GrabModeSync, GrabModeAsync, None, None);
+ XGrabButton(blz.dpy, Button3, AnyModifier, c->framewin, True, ButtonMask,
+ GrabModeSync, GrabModeAsync, None, None);
         c->gc = XCreateGC(blz.dpy, c->framewin, 0, 0);
         XSync(blz.dpy, False);
         for(t=&client; *t; t=&(*t)->next);
diff -r 01cbfde535d4 -r 761af72a793e event.c
--- a/event.c Fri Feb 09 14:06:24 2007 -0500
+++ b/event.c Fri Feb 09 16:26:23 2007 -0500
@@ -44,9 +44,12 @@ static void
 static void
 buttonpress(XEvent *e) {
         Frame *f;
- XButtonPressedEvent *ev = &e->xbutton;
-
+ Bool inclient;
+ XButtonPressedEvent *ev;
+
+ ev = &e->xbutton;
         if((f = frame_of_win(ev->window))) {
+ inclient = ispointinrect(ev->x, ev->y, &f->client->rect);
                 ev->state &= valid_mask;
                 if((ev->state & def.mod) == def.mod) {
                         switch(ev->button) {
@@ -66,17 +69,19 @@ buttonpress(XEvent *e) {
                         break;
                         }
                 }else{
+ if(inclient)
+ XAllowEvents(blz.dpy, ReplayPointer, ev->time);
+ else
+ XAllowEvents(blz.dpy, AsyncPointer, ev->time);
                         if(ev->button == Button1) {
                                 if(frame_to_top(f) || f->client != sel_client())
                                         focus(f->client, True);
- if(ispointinrect(ev->x, ev->y, &f->titlebar.rect)
- ||ispointinrect(ev->x, ev->y, &f->grabbox.rect))
+ if(!inclient)
                                         do_mouse_resize(f->client, CENTER);
                         }
- XAllowEvents(blz.dpy, ReplayPointer, ev->time);
                 }
- }
- XSync(blz.dpy, False);
+ }else
+ XAllowEvents(blz.dpy, AsyncPointer, ev->time);
 }
 
 static void
Received on Fri Feb 09 2007 - 22:28:16 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:06 UTC