From b2bb33b9d8a59f158cf68eab23880be0b311a663 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 26 Aug 2008 16:02:43 +0200 Subject: [PATCH] titlebar: remove/add now handle border Signed-off-by: Julien Danjou --- mouse.c | 6 ------ placement.c | 12 +++++------- titlebar.h | 22 ++++++++++++++++++++-- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/mouse.c b/mouse.c index 414a029bd..9e347c83e 100644 --- a/mouse.c +++ b/mouse.c @@ -140,8 +140,6 @@ mouse_snapclient(client_t *c, area_t geometry, int snap) &globalconf.screens[c->screen].padding); geometry = titlebar_geometry_add(c->titlebar, c->border, geometry); - geometry.width += 2 * c->border; - geometry.height += 2 * c->border; geometry = mouse_snapclienttogeometry_inside(geometry, screen_geometry, snap); @@ -153,8 +151,6 @@ mouse_snapclient(client_t *c, area_t geometry, int snap) if(snapper != c && client_isvisible(snapper, c->screen)) { snapper_geometry = snapper->geometry; - snapper_geometry.width += 2 * snapper->border; - snapper_geometry.height += 2 * snapper->border; snapper_geometry = titlebar_geometry_add(snapper->titlebar, snapper->border, snapper_geometry); geometry = mouse_snapclienttogeometry_outside(geometry, @@ -162,8 +158,6 @@ mouse_snapclient(client_t *c, area_t geometry, int snap) snap); } - geometry.width -= 2 * c->border; - geometry.height -= 2 * c->border; return titlebar_geometry_remove(c->titlebar, c->border, geometry); } diff --git a/placement.c b/placement.c index 7cde51a50..066feeb8d 100644 --- a/placement.c +++ b/placement.c @@ -35,7 +35,7 @@ const name_func_link_t FloatingPlacementList[] = }; static area_t -placement_fix_offscreen(area_t geometry, int screen, int border) +placement_fix_offscreen(area_t geometry, int screen) { area_t screen_geometry; @@ -45,12 +45,12 @@ placement_fix_offscreen(area_t geometry, int screen, int border) /* fix offscreen */ if(AREA_RIGHT(geometry) > AREA_RIGHT(screen_geometry)) - geometry.x = screen_geometry.x + screen_geometry.width - (geometry.width + 2 * border); + geometry.x = screen_geometry.x + screen_geometry.width - geometry.width; else if(AREA_LEFT(geometry) < AREA_LEFT(screen_geometry)) geometry.x = screen_geometry.x; if(AREA_BOTTOM(geometry) > AREA_BOTTOM(screen_geometry)) - geometry.y = screen_geometry.y + screen_geometry.height - (geometry.height + 2 * border); + geometry.y = screen_geometry.y + screen_geometry.height - geometry.height; else if(AREA_TOP(geometry) < AREA_TOP(screen_geometry)) geometry.y = screen_geometry.y; @@ -85,8 +85,6 @@ placement_smart(client_t *c) && client_isvisible(client, c->screen)) { newgeometry = client->f_geometry; - newgeometry.width += 2 * client->border; - newgeometry.height += 2 * client->border; newgeometry = titlebar_geometry_add(c->titlebar, c->border, newgeometry); area_array_remove(&areas, newgeometry); } @@ -123,7 +121,7 @@ placement_smart(client_t *c) newgeometry.height = c->f_geometry.height; newgeometry = titlebar_geometry_add(c->titlebar, c->border, newgeometry); - newgeometry = placement_fix_offscreen(newgeometry, c->screen, c->border); + newgeometry = placement_fix_offscreen(newgeometry, c->screen); newgeometry = titlebar_geometry_remove(c->titlebar, c->border, newgeometry); area_array_wipe(&areas); @@ -153,7 +151,7 @@ placement_under_mouse(client_t *c) } finalgeometry = titlebar_geometry_add(c->titlebar, c->border, finalgeometry); - finalgeometry = placement_fix_offscreen(finalgeometry, c->screen, c->border); + finalgeometry = placement_fix_offscreen(finalgeometry, c->screen); finalgeometry = titlebar_geometry_remove(c->titlebar, c->border, finalgeometry); return finalgeometry; diff --git a/titlebar.h b/titlebar.h index 28ac222c7..088aa4793 100644 --- a/titlebar.h +++ b/titlebar.h @@ -33,7 +33,7 @@ void titlebar_refresh(void); int luaA_titlebar_userdata_new(lua_State *, titlebar_t *); -/** Add the titlebar geometry to a geometry. +/** Add the titlebar geometry and border to a geometry. * \param t The titlebar * \param border The client border size. * \param geometry The geometry @@ -48,25 +48,34 @@ titlebar_geometry_add(titlebar_t *t, int border, area_t geometry) case Top: geometry.y -= t->sw->geometry.height + 2 * t->border.width - border; geometry.height += t->sw->geometry.height + 2 * t->border.width - border; + geometry.width += 2 * border; break; case Bottom: geometry.height += t->sw->geometry.height + 2 * t->border.width - border; + geometry.width += 2 * border; break; case Left: geometry.x -= t->sw->geometry.width + 2 * t->border.width - border; geometry.width += t->sw->geometry.width + 2 * t->border.width - border; + geometry.height += 2 * border; break; case Right: geometry.width += t->sw->geometry.width + 2 * t->border.width - border; + geometry.height += 2 * border; break; default: break; } + else + { + geometry.width += 2 * border; + geometry.height += 2 * border; + } return geometry; } -/** Remove the titlebar geometry to a geometry. +/** Remove the titlebar geometry and border width to a geometry. * \param t The titlebar. * \param border The client border size. * \param geometry The geometry. @@ -81,20 +90,29 @@ titlebar_geometry_remove(titlebar_t *t, int border, area_t geometry) case Top: geometry.y += t->sw->geometry.height + 2 * t->border.width - border; geometry.height -= t->sw->geometry.height + 2 * t->border.width - border; + geometry.width -= 2 * border; break; case Bottom: geometry.height -= t->sw->geometry.height + 2 * t->border.width - border; + geometry.width -= 2 * border; break; case Left: geometry.x += t->sw->geometry.width + 2 * t->border.width - border; geometry.width -= t->sw->geometry.width + 2 * t->border.width - border; + geometry.height -= 2 * border; break; case Right: geometry.width -= t->sw->geometry.width + 2 * t->border.width - border; + geometry.height -= 2 * border; break; default: break; } + else + { + geometry.width -= 2 * border; + geometry.height -= 2 * border; + } return geometry; }