diff --git a/client.c b/client.c index c252a3b9..39d6328c 100644 --- a/client.c +++ b/client.c @@ -422,8 +422,23 @@ client_manage(Window w, XWindowAttributes *wa, int screen) client_setfloating(c, rettrans || c->isfixed); if(!(flags & (USPosition | PPosition))) - c->f_geometry = - globalconf.screens[c->screen].floating_placement(c->f_geometry, c->border, c->screen); + { + c->f_geometry = globalconf.screens[c->screen].floating_placement(c->f_geometry, + c->border, + c->screen); + /* remove effects of the titlebar */ + switch(c->titlebar.position) + { + case Top: + c->f_geometry.y += c->titlebar.sw->geometry.height; + break; + case Left: + c->f_geometry.x += c->titlebar.sw->geometry.width; + break; + default: + break; + } + } XSelectInput(globalconf.display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); @@ -567,7 +582,7 @@ client_resize(Client *c, area_t geometry, Bool hints) { if(!c->ismax) c->f_geometry = geometry; - titlebar_update_geometry_floating(c); + titlebar_update_geometry_floating(c); } XConfigureWindow(globalconf.display, c->win, diff --git a/placement.c b/placement.c index 7927fb4f..691a1353 100644 --- a/placement.c +++ b/placement.c @@ -55,6 +55,35 @@ placement_fix_offscreen(area_t geometry, int screen, int border) return newgeometry; } +static area_t +placement_geometry_add_titlebar(Titlebar *t, area_t geometry) +{ + if(!t->sw) + return geometry; + + switch(t->position) + { + default: + break; + case Top: + geometry.y -= t->sw->geometry.height; + geometry.height += t->sw->geometry.height; + break; + case Bottom: + geometry.y += t->sw->geometry.height; + break; + case Left: + geometry.x -= t->sw->geometry.width; + geometry.width += t->sw->geometry.width; + break; + case Right: + geometry.width += t->sw->geometry.width; + break; + } + + return geometry; +} + /** Compute smart coordinates for a client window * \param geometry current/requested client geometry * \param screen screen used @@ -82,6 +111,7 @@ placement_smart(area_t geometry, int border, int screen) newgeometry = c->f_geometry; newgeometry.width += 2 * c->border; newgeometry.height += 2 * c->border; + newgeometry = placement_geometry_add_titlebar(&c->titlebar, newgeometry); area_list_remove(&arealist, &newgeometry); }