From b39249508f458e302d843c440db8f992e1d545ca Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sun, 31 Jul 2016 20:32:40 -0400 Subject: [PATCH] Refactor functions to update container borders Replace `update_view_border()` with `update_container_border()`. The latter should handle both the case where the container is a view or if the container has children. --- include/border.h | 1 - sway/border.c | 14 +++++++------- sway/commands.c | 2 +- sway/handlers.c | 4 ++-- sway/layout.c | 8 ++++---- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/include/border.h b/include/border.h index b61b0f8a..b72dc5dc 100644 --- a/include/border.h +++ b/include/border.h @@ -22,7 +22,6 @@ void border_clear(struct border *border); void update_container_border(swayc_t *container); 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); diff --git a/sway/border.c b/sway/border.c index c3e1004a..f681e4f1 100644 --- a/sway/border.c +++ b/sway/border.c @@ -201,12 +201,6 @@ static void render_title_bar(swayc_t *view, cairo_t *cr, struct wlc_geometry *b, } } -void map_update_view_border(swayc_t *view, void *data) { - if (view->type == C_VIEW) { - update_view_border(view); - } -} - /** * Generate nested container title for tabbed/stacked layouts */ @@ -293,7 +287,7 @@ void update_tabbed_stacked_titlebars(swayc_t *c, cairo_t *cr, struct wlc_geometr } } -void update_view_border(swayc_t *view) { +static void update_view_border(swayc_t *view) { if (!view->visible) { return; } @@ -417,6 +411,12 @@ void update_container_border(swayc_t *container) { } } +void map_update_view_border(swayc_t *view, void *data) { + if (view->type == C_VIEW) { + update_view_border(view); + } +} + void render_view_borders(wlc_handle view) { swayc_t *c = swayc_by_handle(view); diff --git a/sway/commands.c b/sway/commands.c index 28dcc996..a65e0a01 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -2340,7 +2340,7 @@ static struct cmd_results *_do_split(int argc, char **argv, int layout) { // update container title if tabbed/stacked if (swayc_tabbed_stacked_ancestor(focused)) { - update_view_border(focused); + update_container_border(focused); swayc_t *output = swayc_parent_by_type(focused, C_OUTPUT); // schedule render to make changes take effect right away, // otherwise we would have to wait for the view to render, diff --git a/sway/handlers.c b/sway/handlers.c index bdcdcaa4..87b7253b 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -553,9 +553,9 @@ static void handle_view_properties_updated(wlc_handle view, uint32_t mask) { swayc_t *p = swayc_tabbed_stacked_ancestor(c); if (p) { // TODO: we only got the topmost tabbed/stacked container, update borders of all containers on the path - update_view_border(get_focused_view(p)); + update_container_border(get_focused_view(p)); } else if (c->border_type == B_NORMAL) { - update_view_border(c); + update_container_border(c); } ipc_event_window(c, "title"); } diff --git a/sway/layout.c b/sway/layout.c index 6502d930..42954ebc 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -441,7 +441,7 @@ static void update_border_geometry_floating(swayc_t *c, struct wlc_geometry *geo c->border_geometry = g; *geometry = c->actual_geometry; - update_view_border(c); + update_container_border(c); } void update_layout_geometry(swayc_t *parent, enum swayc_layouts prev_layout) { @@ -688,7 +688,7 @@ void update_geometry(swayc_t *container) { container->actual_geometry = geometry; if (container->type == C_VIEW) { - update_view_border(container); + update_container_border(container); } } @@ -867,7 +867,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { // update focused view border last because it may // depend on the title bar geometry of its siblings. if (focused && container->children->length > 1) { - update_view_border(focused); + update_container_border(focused); } } break; @@ -911,7 +911,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) { // update focused view border last because it may // depend on the title bar geometry of its siblings. if (focused && container->children->length > 1) { - update_view_border(focused); + update_container_border(focused); } } break;