From 8d0048c8d5b3774f79fcb0711d63bcc226b78631 Mon Sep 17 00:00:00 2001 From: "D.B" Date: Sat, 30 Jul 2016 15:12:34 +0200 Subject: properly hide top border inside tabbed/stacked When titlebar is hidden, top border of the topmost view inside tabbed/stacked container will not be drawn. This is changed in layout.c On the other hand, top border should be drawn sometimes, for example when titlebar is hidden on a view that is not the topmost inside tabbed/stacked container. This is changed in border.c --- include/border.h | 1 + sway/border.c | 20 ++++++++++++++++++-- sway/layout.c | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/border.h b/include/border.h index eb7fc656..b629ba46 100644 --- a/include/border.h +++ b/include/border.h @@ -20,5 +20,6 @@ void render_view_borders(wlc_handle view); void update_view_border(swayc_t *view); void map_update_view_border(swayc_t *view, void *data); int get_font_text_height(const char *font); +bool should_hide_top_border(swayc_t *con, double y); #endif diff --git a/sway/border.c b/sway/border.c index d17d8d0c..c1a62bc6 100644 --- a/sway/border.c +++ b/sway/border.c @@ -332,10 +332,12 @@ void update_view_border(swayc_t *view) { } }; cr = create_border_buffer(view, g, &surface); + + bool render_top = !should_hide_top_border(view, view->y); if (view == focused) { - render_borders(view, cr, &config->border_colors.focused, false); + render_borders(view, cr, &config->border_colors.focused, render_top); } else { - render_borders(view, cr, &config->border_colors.focused_inactive, false); + render_borders(view, cr, &config->border_colors.focused_inactive, render_top); } // generate container titles @@ -418,3 +420,17 @@ void render_view_borders(wlc_handle view) { wlc_pixels_write(WLC_RGBA8888, &c->border->geometry, c->border->buffer); } } + +bool should_hide_top_border(swayc_t *con, double y) { + // returns true if container is child of tabbed/stacked layout and is + // sharing top border with tabbed titlebar + swayc_t *par = con->parent; + while (par->type != C_WORKSPACE) { + if (par->layout == L_TABBED || par->layout == L_STACKED) { + return con->y == y; + } + con = par; + par = par->parent; + } + return false; +} diff --git a/sway/layout.c b/sway/layout.c index db9787f3..ba9a8864 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -587,7 +587,7 @@ void update_geometry(swayc_t *container) { } if (config->hide_edge_borders == E_VERTICAL || config->hide_edge_borders == E_BOTH) { - if (geometry.origin.y == workspace->y) { + if (geometry.origin.y == workspace->y || should_hide_top_border(container, geometry.origin.y)) { border_top = 0; } -- cgit v1.2.3