From b0e2be9a6b061dd3bd3091bca31d6f3f16039aad Mon Sep 17 00:00:00 2001 From: oblique Date: Fri, 8 Feb 2013 15:23:50 +0200 Subject: [PATCH] Add render_deco_height() --- include/render.h | 5 +++++ src/con.c | 2 +- src/floating.c | 4 ++-- src/render.c | 14 +++++++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/render.h b/include/render.h index 0a5949f9..a0eca01a 100644 --- a/include/render.h +++ b/include/render.h @@ -21,4 +21,9 @@ */ void render_con(Con *con, bool render_fullscreen); +/* + * Returns the height for the decorations + */ +int render_deco_height(void); + #endif diff --git a/src/con.c b/src/con.c index c1e4f593..750b1c13 100644 --- a/src/con.c +++ b/src/con.c @@ -1175,7 +1175,7 @@ void con_set_border_style(Con *con, int border_style, int border_width) { con->current_border_width = border_width; bsr = con_border_style_rect(con); int deco_height = - (con->border_style == BS_NORMAL ? config.font.height + 5 : 0); + (con->border_style == BS_NORMAL ? render_deco_height() : 0); con->rect.x -= bsr.x; con->rect.y -= bsr.y; diff --git a/src/floating.c b/src/floating.c index 761d207d..b37f1675 100644 --- a/src/floating.c +++ b/src/floating.c @@ -165,7 +165,7 @@ void floating_enable(Con *con, bool automatic) { free(name); /* find the height for the decorations */ - int deco_height = config.font.height + 5; + int deco_height = render_deco_height(); DLOG("Original rect: (%d, %d) with %d x %d\n", con->rect.x, con->rect.y, con->rect.width, con->rect.height); DLOG("Geometry = (%d, %d) with %d x %d\n", con->geometry.x, con->geometry.y, con->geometry.width, con->geometry.height); @@ -251,7 +251,7 @@ void floating_enable(Con *con, bool automatic) { /* 5: Subtract the deco_height in order to make the floating window appear * at precisely the position it specified in its original geometry (which * is what applications might remember). */ - deco_height = (con->border_style == BS_NORMAL ? config.font.height + 5 : 0); + deco_height = (con->border_style == BS_NORMAL ? render_deco_height() : 0); nc->rect.y -= deco_height; DLOG("Corrected y = %d (deco_height = %d)\n", nc->rect.y, deco_height); diff --git a/src/render.c b/src/render.c index 9ac4b78e..5027cd21 100644 --- a/src/render.c +++ b/src/render.c @@ -16,6 +16,16 @@ * container (for debugging purposes) */ static bool show_debug_borders = false; +/* + * Returns the height for the decorations + */ +int render_deco_height(void) { + int deco_height = config.font.height + 4; + if (config.font.height & 0x01) + ++deco_height; + return deco_height; +} + /* * Renders a container with layout L_OUTPUT. In this layout, all CT_DOCKAREAs * get the height of their content and the remaining CT_CON gets the rest. @@ -203,9 +213,7 @@ void render_con(Con *con, bool render_fullscreen) { } /* find the height for the decorations */ - int deco_height = config.font.height + 4; - if (config.font.height & 0x01) - ++deco_height; + int deco_height = render_deco_height(); /* precalculate the sizes to be able to correct rounding errors */ int sizes[children];