From 37b4f62258648e593dbf7047f840a3b065e08151 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 26 Jan 2008 13:11:12 +0100 Subject: [PATCH] always grab Button1 --- client.c | 4 +++- event.c | 4 ++-- window.c | 23 +++++++++-------------- window.h | 2 +- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/client.c b/client.c index 9f96531e..9be75341 100644 --- a/client.c +++ b/client.c @@ -187,7 +187,6 @@ focus(Client *c, int screen, Bool from_mouse) if(globalconf.focus->client) client_unfocus(globalconf.focus->client); - if(c) { /* save sel in focus history */ @@ -199,6 +198,9 @@ focus(Client *c, int screen, Bool from_mouse) || !globalconf.screens[screen].sloppy_focus || globalconf.screens[screen].sloppy_focus_raise) XRaiseWindow(globalconf.display, c->win); + /* since we're dropping EnterWindow events and sometimes the window + * will appear under the mouse, grabbuttons */ + window_grabbuttons(phys_screen, c->win); } else XSetInputFocus(globalconf.display, diff --git a/event.c b/event.c index fa48df37..d768d4cc 100644 --- a/event.c +++ b/event.c @@ -122,7 +122,7 @@ handle_event_buttonpress(XEvent *e) && ev->button == Button1) { XAllowEvents(globalconf.display, ReplayPointer, CurrentTime); - window_grabbuttons(get_phys_screen(c->screen), c->win, True); + window_grabbuttons(get_phys_screen(c->screen), c->win); } else handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL); @@ -228,7 +228,7 @@ handle_event_enternotify(XEvent * e) if((c = get_client_bywin(globalconf.clients, ev->window))) { - window_grabbuttons(get_phys_screen(c->screen), c->win, False); + window_grabbuttons(get_phys_screen(c->screen), c->win); if(globalconf.screens[c->screen].sloppy_focus) focus(c, c->screen, True); } diff --git a/window.c b/window.c index edfbf3d7..c2673854 100644 --- a/window.c +++ b/window.c @@ -89,25 +89,20 @@ window_configure(Window win, Area geometry, int border) /** Grab or ungrab buttons on a window * \param screen The screen * \param win The window - * \param focused True if client is focused - * \param raised True if the client is above other clients */ void -window_grabbuttons(int screen, Window win, Bool raised) +window_grabbuttons(int screen, Window win) { Button *b; - if(!raised) - { - XGrabButton(globalconf.display, Button1, NoSymbol, - win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); - XGrabButton(globalconf.display, Button1, NoSymbol | LockMask, - win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); - XGrabButton(globalconf.display, Button1, NoSymbol | globalconf.numlockmask, - win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); - XGrabButton(globalconf.display, Button1, NoSymbol | globalconf.numlockmask | LockMask, - win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); - } + XGrabButton(globalconf.display, Button1, NoSymbol, + win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); + XGrabButton(globalconf.display, Button1, NoSymbol | LockMask, + win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); + XGrabButton(globalconf.display, Button1, NoSymbol | globalconf.numlockmask, + win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); + XGrabButton(globalconf.display, Button1, NoSymbol | globalconf.numlockmask | LockMask, + win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); for(b = globalconf.buttons.client; b; b = b->next) { diff --git a/window.h b/window.h index 3fff3348..04cec955 100644 --- a/window.h +++ b/window.h @@ -27,7 +27,7 @@ int window_setstate(Window, long); long window_getstate(Window); Status window_configure(Window, Area, int); -void window_grabbuttons(int, Window, Bool); +void window_grabbuttons(int, Window); void window_root_grabbuttons(int); void window_setshape(int, Window); int window_settrans(Window, double);