wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 8a333e8010e609064523a76db4be0b3c1cea88b9
parent 7cb8271f66007734065e1d7ded4d7197aeeb5eb2
Author: Kris Maglione <jg@suckless.org>
Date:   Wed,  7 Feb 2007 22:04:18 -0500

Implemented a click-to-raise policy in floating mode. Comments?


Diffstat:
client.c | 21++++-----------------
event.c | 8+++++---
mouse.c | 33+++++++--------------------------
view.c | 1-
4 files changed, 16 insertions(+), 47 deletions(-)

diff --git a/client.c b/client.c @@ -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, XWindowAttributes *wa) { 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); @@ -122,17 +125,6 @@ set_client_state(Client * c, int state) } 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 focus_client(Client *c, Bool restack) { Client *old_in_area; Client *old; @@ -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 @@ void 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 --git a/event.c b/event.c @@ -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 --git a/mouse.c b/mouse.c @@ -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 align) { 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); @@ -339,6 +341,10 @@ do_mouse_resize(Client *c, BlitzAlign align) { 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; pt_y = dy = frect.height / 2; @@ -352,15 +358,11 @@ do_mouse_resize(Client *c, BlitzAlign align) { 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 align) { } } } - -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 --git a/view.c b/view.c @@ -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; }