Add render_deco_height()

This commit is contained in:
oblique 2013-02-08 15:23:50 +02:00 committed by Michael Stapelberg
parent b565bfca13
commit b0e2be9a6b
4 changed files with 19 additions and 6 deletions

View File

@ -21,4 +21,9 @@
*/ */
void render_con(Con *con, bool render_fullscreen); void render_con(Con *con, bool render_fullscreen);
/*
* Returns the height for the decorations
*/
int render_deco_height(void);
#endif #endif

View File

@ -1175,7 +1175,7 @@ void con_set_border_style(Con *con, int border_style, int border_width) {
con->current_border_width = border_width; con->current_border_width = border_width;
bsr = con_border_style_rect(con); bsr = con_border_style_rect(con);
int deco_height = 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.x -= bsr.x;
con->rect.y -= bsr.y; con->rect.y -= bsr.y;

View File

@ -165,7 +165,7 @@ void floating_enable(Con *con, bool automatic) {
free(name); free(name);
/* find the height for the decorations */ /* 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("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); 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 /* 5: Subtract the deco_height in order to make the floating window appear
* at precisely the position it specified in its original geometry (which * at precisely the position it specified in its original geometry (which
* is what applications might remember). */ * 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; nc->rect.y -= deco_height;
DLOG("Corrected y = %d (deco_height = %d)\n", nc->rect.y, deco_height); DLOG("Corrected y = %d (deco_height = %d)\n", nc->rect.y, deco_height);

View File

@ -16,6 +16,16 @@
* container (for debugging purposes) */ * container (for debugging purposes) */
static bool show_debug_borders = false; 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 * 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. * 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 */ /* find the height for the decorations */
int deco_height = config.font.height + 4; int deco_height = render_deco_height();
if (config.font.height & 0x01)
++deco_height;
/* precalculate the sizes to be able to correct rounding errors */ /* precalculate the sizes to be able to correct rounding errors */
int sizes[children]; int sizes[children];