[hackers] wmii: new tip (= 1778)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Thu, 08 Feb 2007 04:10:04 +0100

changeset: 1778:60efebfd24ce
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Wed Feb 07 22:04:18 2007 -0500
files: client.c event.c mouse.c view.c
description:
Implemented a click-to-raise policy in floating mode. Comments?

diff -r 9761eb2391f4 -r 60efebfd24ce client.c
--- a/client.c Wed Feb 07 21:26:02 2007 -0500
+++ b/client.c Wed Feb 07 22:04:18 2007 -0500
@@ -11,6 +11,7 @@ static char *Ebadcmd = "bad command",
             *Ebadvalue = "bad value";
 
 #define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask | EnterWindowMask)
+#define ButtonMask (ButtonPressMask | ButtonReleaseMask)
 
 Client *
 sel_client() {
@@ -104,6 +105,8 @@ create_client(Window w, XWindowAttribute
                         DefaultDepth(blz.dpy, blz.screen), CopyFromParent,
                         DefaultVisual(blz.dpy, blz.screen),
                         CWOverrideRedirect | CWBackPixmap | CWEventMask, &fwa);
+ XGrabButton(blz.dpy, AnyButton, AnyModifier, c->framewin, False, ButtonMask,
+ GrabModeSync, GrabModeSync, None, None);
         c->gc = XCreateGC(blz.dpy, c->framewin, 0, 0);
         XSync(blz.dpy, False);
         for(t=&client; *t; t=&(*t)->next);
@@ -119,17 +122,6 @@ set_client_state(Client * c, int state)
         long data[] = { state, None };
         XChangeProperty(blz.dpy, c->win, wm_atom[WMState], wm_atom[WMState], 32,
                         PropModeReplace, (unsigned char *) data, 2);
-}
-
-void
-update_client_grab(Client *c, Bool is_sel) {
- if(is_sel) {
- ungrab_mouse(c->framewin, AnyModifier, AnyButton);
- grab_mouse(c->framewin, def.mod, Button1);
- grab_mouse(c->framewin, def.mod, Button3);
- }
- else
- grab_mouse(c->framewin, AnyModifier, Button1);
 }
 
 void
@@ -153,11 +145,6 @@ focus_client(Client *c, Bool restack) {
         c->floating = f->area->floating;
         if(restack)
                 restack_view(v);
- else {
- if(old)
- update_client_grab(old, False);
- update_client_grab(c, True);
- }
         if(!c->floating && f->area->mode == Colstack)
                 arrange_column(f->area, False);
         XSetInputFocus(blz.dpy, c->win, RevertToPointerRoot, CurrentTime);
@@ -184,7 +171,7 @@ map_client(Client *c) {
 map_client(Client *c) {
         XSelectInput(blz.dpy, c->win, CLIENT_MASK & ~StructureNotifyMask);
         XMapWindow(blz.dpy, c->win);
- XSelectInput(blz.dpy, c->win, CLIENT_MASK);
+ XSelectInput(blz.dpy, c->win, CLIENT_MASK);
         set_client_state(c, NormalState);
 }
 
diff -r 9761eb2391f4 -r 60efebfd24ce event.c
--- a/event.c Wed Feb 07 21:26:02 2007 -0500
+++ b/event.c Wed Feb 07 22:04:18 2007 -0500
@@ -85,7 +85,6 @@ buttonpress(XEvent *e) {
         if((f = frame_of_win(ev->window))) {
                 ev->state &= valid_mask;
                 if((ev->state & def.mod) == def.mod) {
- focus(f->client, True);
                         switch(ev->button) {
                         case Button1:
                                 do_mouse_resize(f->client, CENTER);
@@ -94,11 +93,14 @@ buttonpress(XEvent *e) {
                                 do_mouse_resize(f->client,
                                                 quadofcoord(&f->client->rect, ev->x, ev->y));
                         default:
+ XAllowEvents(blz.dpy, ReplayPointer, ev->time);
                         break;
                         }
+ }else{
+ if(ev->button == Button1)
+ focus(f->client, True);
+ XAllowEvents(blz.dpy, ReplayPointer, ev->time);
                 }
- else if(ev->button == Button1)
- focus(f->client, True);
         }
 }
 
diff -r 9761eb2391f4 -r 60efebfd24ce mouse.c
--- a/mouse.c Wed Feb 07 21:26:02 2007 -0500
+++ b/mouse.c Wed Feb 07 22:04:18 2007 -0500
@@ -7,7 +7,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#define ButtonMask (ButtonPressMask | ButtonReleaseMask)
+#define ButtonMask (ButtonPressMask | ButtonReleaseMask)
 #define MouseMask (ButtonMask | PointerMotionMask)
 
 static void
@@ -329,6 +329,8 @@ do_mouse_resize(Client *c, BlitzAlign al
         rects = floating ? rects_of_view(f->area->view, &num) : nil;
         snap = floating ? screen->rect.height / 66 : 0;
         cur = cursor[CurResize];
+ if(align == CENTER)
+ cur = cursor[CurInvisible];
         
         if(!floating && (align == CENTER)) {
                 do_managed_move(c);
@@ -338,6 +340,10 @@ do_mouse_resize(Client *c, BlitzAlign al
         XQueryPointer(blz.dpy, c->framewin, &dummy, &dummy, &i, &i, &pt_x, &pt_y, &di);
         rx = (float)pt_x / frect.width;
         ry = (float)pt_y / frect.height;
+
+ if(XGrabPointer(blz.dpy, c->framewin, False, MouseMask, GrabModeAsync, GrabModeAsync,
+ None, cur, CurrentTime) != GrabSuccess)
+ return;
 
         if (align != CENTER) {
                 pt_x = dx = frect.width / 2;
@@ -352,15 +358,11 @@ do_mouse_resize(Client *c, BlitzAlign al
                 hr_x = screen->rect.width / 2;
                 hr_y = screen->rect.height / 2;
                 XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, hr_x, hr_y);
- cur = cursor[CurInvisible];
         }
 
         XQueryPointer(blz.dpy, blz.root, &dummy, &dummy, &i, &i, &pt_x, &pt_y, &di);
 
         XSync(blz.dpy, False);
- if(XGrabPointer(blz.dpy, c->framewin, False, MouseMask, GrabModeAsync, GrabModeAsync,
- None, cur, CurrentTime) != GrabSuccess)
- return;
         XGrabServer(blz.dpy);
 
         draw_xor_border(&frect);
@@ -428,24 +430,3 @@ do_mouse_resize(Client *c, BlitzAlign al
                 }
         }
 }
-
-void
-grab_mouse(Window w, unsigned long mod, unsigned int button) {
- XGrabButton(blz.dpy, button, mod, w, False, ButtonMask,
- GrabModeAsync, GrabModeSync, None, None);
- if((mod != AnyModifier) && num_lock_mask) {
- XGrabButton(blz.dpy, button, mod | num_lock_mask, w, False, ButtonMask,
- GrabModeAsync, GrabModeSync, None, None);
- XGrabButton(blz.dpy, button, mod | num_lock_mask | LockMask, w, False,
- ButtonMask, GrabModeAsync, GrabModeSync, None, None);
- }
-}
-
-void
-ungrab_mouse(Window w, unsigned long mod, unsigned int button) {
- XUngrabButton(blz.dpy, button, mod, w);
- if(mod != AnyModifier && num_lock_mask) {
- XUngrabButton(blz.dpy, button, mod | num_lock_mask, w);
- XUngrabButton(blz.dpy, button, mod | num_lock_mask | LockMask, w);
- }
-}
diff -r 9761eb2391f4 -r 60efebfd24ce view.c
--- a/view.c Wed Feb 07 21:26:02 2007 -0500
+++ b/view.c Wed Feb 07 22:04:18 2007 -0500
@@ -197,7 +197,6 @@ restack_view(View *v) {
                         wins[n++] = a->sel->client->framewin;
                         for(f=a->frame; f; f=f->anext) {
                                 Client *c = f->client;
- update_client_grab(c, (v->sel == a) && (a->sel == f));
                                 if(f != a->sel)
                                         wins[n++] = c->framewin;
                         }
Received on Thu Feb 08 2007 - 04:10:04 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:58 UTC