diff --git a/client.c b/client.c index eff19216..259d4a9a 100644 --- a/client.c +++ b/client.c @@ -475,7 +475,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen) ewmh_update_net_client_list(phys_screen); } -area_t +static area_t client_geometry_hints(Client *c, area_t geometry) { double dx, dy, max, min, ratio; @@ -525,14 +525,22 @@ client_geometry_hints(Client *c, area_t geometry) /** Resize client window * \param c client to resize * \param geometry new window geometry + * \param hints use resize hints * \param return True if resize has been done */ Bool -client_resize(Client *c, area_t geometry) +client_resize(Client *c, area_t geometry, Bool hints) { int new_screen; area_t area; XWindowChanges wc; + Layout *layout = layout_get_current(c->screen); + + if(hints) + geometry = client_geometry_hints(c, geometry); + + if(!c->isfloating && layout->arrange != layout_floating) + geometry = titlebar_update_geometry(c, geometry); if(geometry.width <= 0 || geometry.height <= 0) return False; @@ -553,7 +561,8 @@ client_resize(Client *c, area_t geometry) if(c->geometry.x != geometry.x || c->geometry.y != geometry.y || c->geometry.width != geometry.width || c->geometry.height != geometry.height) { - new_screen = screen_get_bycoord(globalconf.screens_info, c->screen, geometry.x, geometry.y); + new_screen = + screen_get_bycoord(globalconf.screens_info, c->screen, geometry.x, geometry.y); c->geometry.x = wc.x = geometry.x; c->geometry.width = wc.width = geometry.width; @@ -590,7 +599,7 @@ client_setfloating(Client *c, Bool floating) { if((c->isfloating = floating)) { - client_resize(c, c->f_geometry); + client_resize(c, c->f_geometry, False); XRaiseWindow(globalconf.display, c->win); } else @@ -599,7 +608,7 @@ client_setfloating(Client *c, Bool floating) if(c->ismax) { c->ismax = False; - client_resize(c, c->m_geometry); + client_resize(c, c->m_geometry, False); } } if(client_isvisible(c, c->screen)) @@ -935,7 +944,7 @@ uicb_client_moveresize(int screen, char *arg) &dummy, &dummy, &mx, &my, &dx, &dy, &dui); if(globalconf.screens[sel->screen].resize_hints) geometry = client_geometry_hints(sel, geometry); - client_resize(sel, geometry); + client_resize(sel, geometry, False); if (xqp && ox <= mx && (ox + 2 * sel->border + ow) >= mx && oy <= my && (oy + 2 * sel->border + oh) >= my) { @@ -997,18 +1006,18 @@ client_maximize(Client *c, area_t geometry) if(layout_get_current(c->screen)->arrange != layout_floating) client_setfloating(c, True); client_focus(c, c->screen, True); - client_resize(c, geometry); + client_resize(c, geometry, False); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); } else if(c->wasfloating) { client_setfloating(c, True); - client_resize(c, c->m_geometry); + client_resize(c, c->m_geometry, False); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); } else if(layout_get_current(c->screen)->arrange == layout_floating) { - client_resize(c, c->m_geometry); + client_resize(c, c->m_geometry, False); widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); } else diff --git a/client.h b/client.h index acfef500..4e43923d 100644 --- a/client.h +++ b/client.h @@ -31,8 +31,7 @@ void client_focus(Client *, int, Bool); void client_ban(Client *); void client_unban(Client *); void client_manage(Window, XWindowAttributes *, int); -area_t client_geometry_hints(Client *, area_t); -Bool client_resize(Client *, area_t); +Bool client_resize(Client *, area_t, Bool); void client_unmanage(Client *); void client_updatewmhints(Client *); long client_updatesizehints(Client *); diff --git a/event.c b/event.c index 79ed7a66..3b75847c 100644 --- a/event.c +++ b/event.c @@ -182,7 +182,7 @@ event_handle_configurerequest(XEvent * e) { old_screen = c->screen; - client_resize(c, geometry); + client_resize(c, geometry, False); tag_client_with_rule(c, rule_matching_client(c)); diff --git a/ewmh.c b/ewmh.c index 937d4703..cbdb2ece 100644 --- a/ewmh.c +++ b/ewmh.c @@ -272,7 +272,7 @@ ewmh_process_state_atom(Client *c, Atom state, int set) client_setfloating(c, True); } widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); - client_resize(c, geometry); + client_resize(c, geometry, False); XRaiseWindow(globalconf.display, c->win); } } diff --git a/layouts/fibonacci.c b/layouts/fibonacci.c index aef7a98e..41412c6d 100644 --- a/layouts/fibonacci.c +++ b/layouts/fibonacci.c @@ -83,13 +83,7 @@ layout_fibonacci(int screen, int shape) } geometry.width -= 2 * c->border; geometry.height -= 2 * c->border; - if(globalconf.screens[screen].resize_hints) - client_resize(c, - client_geometry_hints(c, - titlebar_update_geometry(c, - geometry))); - else - client_resize(c, titlebar_update_geometry(c, geometry)); + client_resize(c, geometry, globalconf.screens[screen].resize_hints); geometry.width += 2 * c->border; geometry.height += 2 * c->border; } diff --git a/layouts/floating.c b/layouts/floating.c index f0fc38a6..a790ffdc 100644 --- a/layouts/floating.c +++ b/layouts/floating.c @@ -32,6 +32,6 @@ layout_floating(int screen) for(c = globalconf.clients; c; c = c->next) if(client_isvisible(c, screen) && !c->ismax) - client_resize(c, c->f_geometry); + client_resize(c, c->f_geometry, False); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/layouts/max.c b/layouts/max.c index e73e9aed..ec157bed 100644 --- a/layouts/max.c +++ b/layouts/max.c @@ -41,13 +41,7 @@ layout_max(int screen) { area.width -= 2 * c->border; area.height -= 2 * c->border; - if(globalconf.screens[screen].resize_hints) - client_resize(c, - client_geometry_hints(c, - titlebar_update_geometry(c, - area))); - else - client_resize(c, titlebar_update_geometry(c, area)); + client_resize(c, area, False); area.width += 2 * c->border; area.height += 2 * c->border; } diff --git a/layouts/tile.c b/layouts/tile.c index 1c530111..936a972a 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -208,11 +208,7 @@ _tile(int screen, const Position position) geometry.width = mw - 2 * c->border; geometry.height = mh - 2 * c->border; - geometry = titlebar_update_geometry(c, geometry); - - if(globalconf.screens[screen].resize_hints) - geometry = client_geometry_hints(c, geometry); - client_resize(c, geometry); + client_resize(c, geometry, globalconf.screens[screen].resize_hints); } else { @@ -263,12 +259,7 @@ _tile(int screen, const Position position) if(position == Bottom) geometry.y += mh; } - - geometry = titlebar_update_geometry(c, geometry); - - if(globalconf.screens[screen].resize_hints) - geometry = client_geometry_hints(c, geometry); - client_resize(c, geometry); + client_resize(c, geometry, globalconf.screens[screen].resize_hints); } i++; } diff --git a/mouse.c b/mouse.c index 3010ae00..093bfb4a 100644 --- a/mouse.c +++ b/mouse.c @@ -113,9 +113,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) geometry.width = c->geometry.width; geometry.height = c->geometry.height; - client_resize(c, geometry); - - titlebar_update_geometry_floating(c); + client_resize(c, geometry, False); while(XCheckMaskEvent(globalconf.display, PointerMotionMask, &ev)); } @@ -231,7 +229,7 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused))) geometry.height = 1; geometry.x = c->geometry.x; geometry.y = c->geometry.y; - client_resize(c, client_geometry_hints(c, geometry)); + client_resize(c, geometry, True); } else if(layout->arrange == layout_tile || layout->arrange == layout_tileleft || layout->arrange == layout_tiletop || layout->arrange == layout_tilebottom) diff --git a/screen.c b/screen.c index 840555b6..5e65e0fc 100644 --- a/screen.c +++ b/screen.c @@ -189,11 +189,11 @@ move_client_to_screen(Client *c, int new_screen, Bool doresize) if(c->m_geometry.y + c->m_geometry.height >= to.y + to.height) c->m_geometry.y = to.y + to.height - c->m_geometry.height - 2 * c->border; - client_resize(c, new_geometry); + client_resize(c, new_geometry, False); } /* if floating, move to this new coords */ else if(c->isfloating) - client_resize(c, new_f_geometry); + client_resize(c, new_f_geometry, False); /* otherwise just register them */ else {