From a42d43a8538b461e0e28f0609e9999133d4fd732 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sun, 16 Mar 2008 17:28:04 +0100 Subject: [PATCH] Fix various placement issue with titlebar Signed-off-by: Julien Danjou --- client.c | 21 ++++++++++++++++++--- placement.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) 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); }