diff --git a/client.c b/client.c index 4e704857e..8f3d784ba 100644 --- a/client.c +++ b/client.c @@ -132,7 +132,7 @@ client_get_byname(Client *list, char *name) return NULL; } -static void +void client_updatetitlebar(Client *c) { DrawCtx *ctx; @@ -465,6 +465,25 @@ client_manage(Window w, XWindowAttributes *wa, int screen) ewmh_update_net_client_list(phys_screen); } +area_t +client_titlebar_update_position(Client *c, area_t geometry) +{ + if(!c->titlebar) + return geometry;; + + simplewindow_move_resize(c->titlebar, + geometry.x, + geometry.y, + geometry.width, + c->titlebar->geometry.height); + + client_updatetitlebar(c); + geometry.y += c->titlebar->geometry.height; + geometry.height -= c->titlebar->geometry.height; + + return geometry; +} + area_t client_geometry_hints(Client *c, area_t geometry) { @@ -524,12 +543,6 @@ client_resize(Client *c, area_t geometry) area_t area; XWindowChanges wc; - if(c->titlebar) - { - geometry.y += c->titlebar->geometry.height; - geometry.height -= c->titlebar->geometry.height; - } - if(geometry.width <= 0 || geometry.height <= 0) return False; @@ -556,24 +569,25 @@ client_resize(Client *c, area_t geometry) c->geometry.y = wc.y = geometry.y; c->geometry.height = wc.height = geometry.height; - if(c->titlebar) - { - simplewindow_move_resize(c->titlebar, - geometry.x, - geometry.y - c->titlebar->geometry.height, - geometry.width, - c->titlebar->geometry.height); - client_updatetitlebar(c); - - c->geometry.y -= c->titlebar->geometry.height; - c->geometry.height += c->titlebar->geometry.height; - } - /* save the floating geometry if the window is floating but not * maximized */ - if((c->isfloating || - layout_get_current(new_screen)->arrange == layout_floating) && !c->ismax) - c->f_geometry = geometry; + if(c->isfloating + || layout_get_current(new_screen)->arrange == layout_floating) + { + if(!c->ismax) + c->f_geometry = geometry; + + if(c->titlebar) + { + simplewindow_move_resize(c->titlebar, + geometry.x, + geometry.y - c->titlebar->geometry.height, + geometry.width, + c->titlebar->geometry.height); + + client_updatetitlebar(c); + } + } XConfigureWindow(globalconf.display, c->win, CWX | CWY | CWWidth | CWHeight, &wc); diff --git a/client.h b/client.h index acfef500d..cbf904a9a 100644 --- a/client.h +++ b/client.h @@ -31,11 +31,13 @@ void client_focus(Client *, int, Bool); void client_ban(Client *); void client_unban(Client *); void client_manage(Window, XWindowAttributes *, int); +area_t client_titlebar_update_position(Client *, area_t); area_t client_geometry_hints(Client *, area_t); Bool client_resize(Client *, area_t); void client_unmanage(Client *); void client_updatewmhints(Client *); long client_updatesizehints(Client *); +void client_updatetitlebar(Client *); void client_updatetitle(Client *); void client_saveprops(Client *); void client_kill(Client *); diff --git a/layouts/fibonacci.c b/layouts/fibonacci.c index 6ae546481..11eb6db36 100644 --- a/layouts/fibonacci.c +++ b/layouts/fibonacci.c @@ -83,9 +83,12 @@ 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, geometry)); + client_resize(c, + client_geometry_hints(c, + client_titlebar_update_position(c, + geometry))); else - client_resize(c, geometry); + client_resize(c, client_titlebar_update_position(c, geometry)); geometry.width += 2 * c->border; geometry.height += 2 * c->border; } diff --git a/layouts/max.c b/layouts/max.c index 334c6cf5b..69abbeb78 100644 --- a/layouts/max.c +++ b/layouts/max.c @@ -41,9 +41,12 @@ 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, area)); + client_resize(c, + client_geometry_hints(c, + client_titlebar_update_position(c, + area))); else - client_resize(c, area); + client_resize(c, client_titlebar_update_position(c, area)); area.width += 2 * c->border; area.height += 2 * c->border; } diff --git a/layouts/tile.c b/layouts/tile.c index 0dd470fac..5bc9635fa 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -203,8 +203,12 @@ _tile(int screen, const Position position) break; break; } + geometry.width = mw - 2 * c->border; geometry.height = mh - 2 * c->border; + + geometry = client_titlebar_update_position(c, geometry); + if(globalconf.screens[screen].resize_hints) geometry = client_geometry_hints(c, geometry); client_resize(c, geometry); @@ -258,6 +262,9 @@ _tile(int screen, const Position position) if(position == Bottom) geometry.y += mh; } + + geometry = client_titlebar_update_position(c, geometry); + if(globalconf.screens[screen].resize_hints) geometry = client_geometry_hints(c, geometry); client_resize(c, geometry);