From 694f97e4d7962e5451df95299b9d4b08ea0f8f54 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 18 Jun 2008 17:05:10 +0200 Subject: [PATCH] titlebar: set above client edge border Signed-off-by: Julien Danjou --- client.c | 2 +- mouse.c | 6 +++--- placement.c | 10 +++++----- titlebar.c | 8 ++++---- titlebar.h | 30 ++++++++++++++++-------------- 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/client.c b/client.c index 758d1fb3..05e5e0f9 100644 --- a/client.c +++ b/client.c @@ -477,7 +477,7 @@ client_resize(client_t *c, area_t geometry, bool hints) uint32_t values[5]; if(c->titlebar && !c->ismoving && !c->isfloating && layout != layout_floating) - geometry = titlebar_geometry_remove(c->titlebar, geometry); + geometry = titlebar_geometry_remove(c->titlebar, c->border, geometry); if(hints) geometry = client_geometry_hints(c, geometry); diff --git a/mouse.c b/mouse.c index b029befe..2726c4c5 100644 --- a/mouse.c +++ b/mouse.c @@ -134,7 +134,7 @@ mouse_snapclient(client_t *c, area_t geometry, int snap) globalconf.screens[c->screen].statusbar, &globalconf.screens[c->screen].padding); - geometry = titlebar_geometry_add(c->titlebar, geometry); + geometry = titlebar_geometry_add(c->titlebar, c->border, geometry); geometry.width += 2 * c->border; geometry.height += 2 * c->border; @@ -147,7 +147,7 @@ mouse_snapclient(client_t *c, area_t geometry, int snap) snapper_geometry = snapper->geometry; snapper_geometry.width += 2 * c->border; snapper_geometry.height += 2 * c->border; - snapper_geometry = titlebar_geometry_add(c->titlebar, snapper_geometry); + snapper_geometry = titlebar_geometry_add(c->titlebar, c->border, snapper_geometry); geometry = mouse_snapclienttogeometry_outside(geometry, snapper_geometry, @@ -156,7 +156,7 @@ mouse_snapclient(client_t *c, area_t geometry, int snap) geometry.width -= 2 * c->border; geometry.height -= 2 * c->border; - return titlebar_geometry_remove(c->titlebar, geometry); + return titlebar_geometry_remove(c->titlebar, c->border, geometry); } /** Set coordinates to a corner of an area. diff --git a/placement.c b/placement.c index 8a2c1c87..b702fdbc 100644 --- a/placement.c +++ b/placement.c @@ -90,7 +90,7 @@ placement_smart(client_t *c) newgeometry = client->f_geometry; newgeometry.width += 2 * client->border; newgeometry.height += 2 * client->border; - newgeometry = titlebar_geometry_add(c->titlebar, newgeometry); + newgeometry = titlebar_geometry_add(c->titlebar, c->border, newgeometry); area_list_remove(&arealist, &newgeometry); } @@ -118,9 +118,9 @@ placement_smart(client_t *c) newgeometry.width = c->f_geometry.width; newgeometry.height = c->f_geometry.height; - newgeometry = titlebar_geometry_add(c->titlebar, newgeometry); + newgeometry = titlebar_geometry_add(c->titlebar, c->border, newgeometry); newgeometry = placement_fix_offscreen(newgeometry, c->screen, c->border); - newgeometry = titlebar_geometry_remove(c->titlebar, newgeometry); + newgeometry = titlebar_geometry_remove(c->titlebar, c->border, newgeometry); area_list_wipe(&arealist); @@ -144,9 +144,9 @@ placement_under_mouse(client_t *c) p_delete(&qp_r); } - finalgeometry = titlebar_geometry_add(c->titlebar, finalgeometry); + finalgeometry = titlebar_geometry_add(c->titlebar, c->border, finalgeometry); finalgeometry = placement_fix_offscreen(finalgeometry, c->screen, c->border); - finalgeometry = titlebar_geometry_remove(c->titlebar, finalgeometry); + finalgeometry = titlebar_geometry_remove(c->titlebar, c->border, finalgeometry); return finalgeometry; } diff --git a/titlebar.c b/titlebar.c index 788b1212..fba65666 100644 --- a/titlebar.c +++ b/titlebar.c @@ -163,7 +163,7 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res) break; } res->x = geometry.x + x_offset; - res->y = geometry.y - c->titlebar->height - 2 * c->titlebar->border.width; + res->y = geometry.y - c->titlebar->height - 2 * c->titlebar->border.width + c->border; res->width = width; res->height = c->titlebar->height; break; @@ -184,7 +184,7 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res) break; } res->x = geometry.x + x_offset; - res->y = geometry.y + geometry.height + 2 * c->border; + res->y = geometry.y + geometry.height + c->border; res->width = width; res->height = c->titlebar->height; break; @@ -204,7 +204,7 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res) y_offset = (geometry.height - width) / 2; break; } - res->x = geometry.x - c->titlebar->height; + res->x = geometry.x - c->titlebar->height + c->border; res->y = geometry.y + y_offset; res->width = c->titlebar->height; res->height = width; @@ -225,7 +225,7 @@ titlebar_geometry_compute(client_t *c, area_t geometry, area_t *res) y_offset = (geometry.height - width) / 2; break; } - res->x = geometry.x + geometry.width + 2 * c->border; + res->x = geometry.x + geometry.width + c->border; res->y = geometry.y + y_offset; res->width = c->titlebar->height; res->height = width; diff --git a/titlebar.h b/titlebar.h index 7bd80ba6..b1ea0d56 100644 --- a/titlebar.h +++ b/titlebar.h @@ -34,28 +34,29 @@ int luaA_titlebar_userdata_new(titlebar_t *); /** Add the titlebar geometry to a geometry. * \param t The titlebar + * \param border The client border size. * \param geometry The geometry * \return A new geometry bigger if the titlebar is visible. */ static inline area_t -titlebar_geometry_add(titlebar_t *t, area_t geometry) +titlebar_geometry_add(titlebar_t *t, int border, area_t geometry) { if(t && t->sw) switch(t->position) { case Top: - geometry.y -= t->sw->geometry.height + 2 * t->border.width; - geometry.height += t->sw->geometry.height + 2 * t->border.width; + geometry.y -= t->sw->geometry.height + 2 * t->border.width - border; + geometry.height += t->sw->geometry.height + 2 * t->border.width - border; break; case Bottom: - geometry.height += t->sw->geometry.height + 2 * t->border.width; + geometry.height += t->sw->geometry.height + 2 * t->border.width - border; break; case Left: - geometry.x -= t->sw->geometry.width + 2 * t->border.width; - geometry.width += t->sw->geometry.width + 2 * t->border.width; + geometry.x -= t->sw->geometry.width + 2 * t->border.width - border; + geometry.width += t->sw->geometry.width + 2 * t->border.width - border; break; case Right: - geometry.width += t->sw->geometry.width + 2 * t->border.width; + geometry.width += t->sw->geometry.width + 2 * t->border.width - border; break; default: break; @@ -66,28 +67,29 @@ titlebar_geometry_add(titlebar_t *t, area_t geometry) /** Remove the titlebar geometry to a geometry. * \param t The titlebar. + * \param border The client border size. * \param geometry The geometry. * \return A new geometry smaller if the titlebar is visible. */ static inline area_t -titlebar_geometry_remove(titlebar_t *t, area_t geometry) +titlebar_geometry_remove(titlebar_t *t, int border, area_t geometry) { if(t && t->sw) switch(t->position) { case Top: - geometry.y += t->sw->geometry.height + 2 * t->border.width; - geometry.height -= t->sw->geometry.height + 2 * t->border.width; + geometry.y += t->sw->geometry.height + 2 * t->border.width - border; + geometry.height -= t->sw->geometry.height + 2 * t->border.width - border; break; case Bottom: - geometry.height -= t->sw->geometry.height + 2 * t->border.width; + geometry.height -= t->sw->geometry.height + 2 * t->border.width - border; break; case Left: - geometry.x += t->sw->geometry.width + 2 * t->border.width; - geometry.width -= t->sw->geometry.width + 2 * t->border.width; + geometry.x += t->sw->geometry.width + 2 * t->border.width - border; + geometry.width -= t->sw->geometry.width + 2 * t->border.width - border; break; case Right: - geometry.width -= t->sw->geometry.width + 2 * t->border.width; + geometry.width -= t->sw->geometry.width + 2 * t->border.width - border; break; default: break;