From 649a631f97e1e3045d668e6ae0ee4f73bd0822d4 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sun, 21 Jun 2009 01:55:52 +0200 Subject: [PATCH] Mouse: Grab server only when the client is not tiled --- src/client.c | 8 ++++++++ src/mouse.c | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/client.c b/src/client.c index 00ed7a7..afb1c87 100644 --- a/src/client.c +++ b/src/client.c @@ -674,6 +674,10 @@ client_size_hints(Client *c) void client_swap(Client *c1, Client *c2) { + /* Check if no one of these clients are free */ + CHECK(!c1->free); + CHECK(!c2->free); + /* Swap only the windows */ swap_ptr((void**)&c1->win, (void**)&c2->win); @@ -681,6 +685,10 @@ client_swap(Client *c1, Client *c2) XReparentWindow(dpy, c1->win, c1->frame, BORDH, TBARH); XReparentWindow(dpy, c2->win, c2->frame, BORDH, TBARH); + /* Re-set size hints properties */ + client_size_hints(c1); + client_size_hints(c2); + /* Resize the windows */ client_moveresize(c1, c1->geo, False); client_moveresize(c2, c2->geo, False); diff --git a/src/mouse.c b/src/mouse.c index 4410c2c..b0965a6 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -72,7 +72,8 @@ mouse_move(Client *c) None, cursor[CurMove], CurrentTime) != GrabSuccess) return; - XGrabServer(dpy); + if(!c->tile) + XGrabServer(dpy); /* Set the GC for the rectangle */ xgc.function = GXinvert; @@ -150,10 +151,10 @@ mouse_move(Client *c) mouse_dragborder(geo, gci); client_moveresize(c, geo, False); frame_update(c); + XUngrabServer(dpy); } client_update_attributes(c); XUngrabPointer(dpy, CurrentTime); - XUngrabServer(dpy); XFreeGC(dpy, gci); return; @@ -167,8 +168,6 @@ void mouse_resize(Client *c) { XRectangle geo = c->geo, ogeo = c->geo; - int ocx = c->geo.x; - int ocy = c->geo.y; Position pos = Right; XEvent ev; Window w; @@ -191,7 +190,8 @@ mouse_resize(Client *c) CurrentTime) != GrabSuccess) return; - XGrabServer(dpy); + if(!c->tile) + XGrabServer(dpy); /* Set the GC for the rectangle */ xgc.function = GXinvert; @@ -238,16 +238,16 @@ mouse_resize(Client *c) if(pos == Right) { - geo.width = ((ev.xmotion.x - ocx < c->minw) ? c->minw : ev.xmotion.x - ocx); - geo.height = ((ev.xmotion.y - ocy < c->minh) ? c->minh : ev.xmotion.y - ocy); + geo.width = ((ev.xmotion.x - c->geo.x < c->minw) ? c->minw : ev.xmotion.x - c->geo.x); + geo.height = ((ev.xmotion.y - c->geo.y < c->minh) ? c->minh : ev.xmotion.y - c->geo.y); } else { - geo.x = (geo.width != c->maxw) ? ocx - (ocx - ev.xmotion.x) : geo.x; - geo.width = ((c->geo.width + (ocx - geo.x) < c->minw) + geo.x = (geo.width != c->maxw) ? c->geo.x - (c->geo.x - ev.xmotion.x) : geo.x; + geo.width = ((c->geo.width + (c->geo.x - geo.x) < c->minw) ? c->minw && (geo.x = (c->geo.x + c->geo.width) - c->minw) - : c->geo.width + (ocx - geo.x)); - geo.height = ((ev.xmotion.y - ocy <= 1) ? 1 : ev.xmotion.y - ocy); + : c->geo.width + (c->geo.x - geo.x)); + geo.height = ((ev.xmotion.y - c->geo.y <= 1) ? 1 : ev.xmotion.y - c->geo.y); } client_geo_hints(&geo, c); @@ -265,13 +265,13 @@ mouse_resize(Client *c) mouse_dragborder(ogeo, gci); client_moveresize(c, geo, True); frame_update(c); + XUngrabServer(dpy); } else tags[selscreen][seltag[selscreen]].layout.func(c->screen); client_update_attributes(c); XUngrabPointer(dpy, CurrentTime); - XUngrabServer(dpy); XFreeGC(dpy, gci); return;