diff --git a/src/client.c b/src/client.c index 3b06473..8abff50 100644 --- a/src/client.c +++ b/src/client.c @@ -486,6 +486,55 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar) return c; } +/** Set a geometry with the client size hints + *\param geo Geometry pointer + *\param c Client pointer +*/ +void +client_geo_hints(XRectangle *geo, Client *c) +{ + /* minimum possible */ + if(geo->width < 1) + geo->width = 1; + if(geo->height < 1) + geo->height = 1; + + /* base */ + geo->width -= c->basew; + geo->height -= c->baseh; + + /* aspect */ + if(c->minay > 0 && c->maxay > 0 + && c->minax > 0 && c->maxax > 0) + { + if(geo->width * c->maxay > geo->height * c->maxax) + geo->width = geo->height * c->maxax / c->maxay; + else if(geo->width * c->minay < geo->height * c->minax) + geo->height = geo->width * c->minay / c->minax; + } + + /* incremental */ + if(c->incw) + geo->width -= geo->width % c->incw; + if(c->inch) + geo->height -= geo->height % c->inch; + + /* base dimension */ + geo->width += c->basew; + geo->height += c->baseh; + + if(c->minw > 0 && geo->width < c->minw) + geo->width = c->minw; + if(c->minh > 0 && geo->height < c->minh) + geo->height = c->minh; + if(c->maxw > 0 && geo->width > c->maxw) + geo->width = c->maxw; + if(c->maxh > 0 && geo->height > c->maxh) + geo->height = c->maxh; + + return; +} + /** Move and Resize a client * \param c Client pointer * \param geo Coordinate info for the future size @@ -498,56 +547,12 @@ client_moveresize(Client *c, XRectangle geo, Bool r) if(!c || c->state_dock) return; - /* Resize hints {{{ */ if(r) - { - /* minimum possible */ - if(geo.width < 1) - geo.width = 1; - if(geo.height < 1) - geo.height = 1; - - /* base */ - geo.width -= c->basew; - geo.height -= c->baseh; - - /* aspect */ - if(c->minay > 0 && c->maxay > 0 - && c->minax > 0 && c->maxax > 0) - { - if(geo.width * c->maxay > geo.height * c->maxax) - geo.width = geo.height * c->maxax / c->maxay; - else if(geo.width * c->minay < geo.height * c->minax) - geo.height = geo.width * c->minay / c->minax; - } - - /* incremental */ - if(c->incw) - geo.width -= geo.width % c->incw; - if(c->inch) - geo.height -= geo.height % c->inch; - - /* base dimension */ - geo.width += c->basew; - geo.height += c->baseh; - - if(c->minw > 0 && geo.width < c->minw) - geo.width = c->minw; - if(c->minh > 0 && geo.height < c->minh) - geo.height = c->minh; - if(c->maxw > 0 && geo.width > c->maxw) - geo.width = c->maxw; - if(c->maxh > 0 && geo.height > c->maxh) - geo.height = c->maxh; - if(geo.width <= 0 || geo.height <= 0) - return; - } - /* }}} */ + client_geo_hints(&geo, c); c->max = False; - if(tags[selscreen][seltag[selscreen]].layout.func == freelayout - || c->free); + if(r && (tags[selscreen][seltag[selscreen]].layout.func == freelayout || c->free)); c->geo = c->ogeo = geo; c->screen = screen_get_with_geo(c->geo.x, c->geo.y); @@ -693,9 +698,9 @@ client_swap(Client *c1, Client *c2) if(c1->screen != c2->screen) arrange(c2->screen); - /* Update frame to draw the right title */ - frame_update(c1); - frame_update(c2); + /* Get the new client name */ + client_get_name(c1); + client_get_name(c2); return; } diff --git a/src/mouse.c b/src/mouse.c index 3505239..14500b4 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -165,6 +165,8 @@ void mouse_resize(Client *c) { XRectangle geo = c->geo, ogeo = c->geo; + int ocx = c->geo.x; + int ocy = c->geo.y; XEvent ev; Window w; int d, u, omx, omy; @@ -191,7 +193,10 @@ mouse_resize(Client *c) gci = XCreateGC(dpy, ROOT, GCFunction|GCSubwindowMode|GCLineWidth, &xgc); if(!c->tile) + { + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->geo.width + conf.client.borderheight, c->geo.height); mouse_dragborder(c->geo, gci); + } do { @@ -219,13 +224,10 @@ mouse_resize(Client *c) { mouse_dragborder(geo, gci); - if((geo.width + ev.xmotion.x_root - omx) > 1) - geo.width += ev.xmotion.x_root - omx; - if((geo.height + ev.xmotion.y_root - omy) > 1) - geo.height += ev.xmotion.y_root - omy; + geo.width = ((ev.xmotion.x - ocx <= 1) ? 1 : ev.xmotion.x - ocx); + geo.height = ((ev.xmotion.y - ocy <= 1) ? 1 : ev.xmotion.y - ocy); - omx = ev.xmotion.x_root; - omy = ev.xmotion.y_root; + client_geo_hints(&geo, c); mouse_dragborder((ogeo = geo), gci); diff --git a/src/wmfs.h b/src/wmfs.h index 69e53bd..002e56a 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -142,6 +142,7 @@ void client_kill(Client *c); Bool ishide(Client *c, int screen); void client_map(Client *c); Client* client_manage(Window w, XWindowAttributes *wa, Bool ar); +void client_geo_hints(XRectangle *geo, Client *c); void client_moveresize(Client *c, XRectangle geo, Bool r); void client_maximize(Client *c); void client_size_hints(Client *c);