From 4e7891eb8d2847e2f6147480321cd883d9455e99 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Sat, 26 Nov 2022 02:17:04 -0500 Subject: [PATCH] ssd: Simplify ssd_create() - Add `active` argument for consistency with `ssd_set_active()` - `assert()` that `ssd_create()` is not called twice without an `ssd_destroy()` in between --- include/ssd.h | 2 +- src/ssd/ssd.c | 11 +++-------- src/view.c | 4 ++-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/include/ssd.h b/include/ssd.h index 06a3e1d3..d26df066 100644 --- a/include/ssd.h +++ b/include/ssd.h @@ -146,7 +146,7 @@ struct ssd_hover_state { }; /* Public SSD API */ -void ssd_create(struct view *view); +void ssd_create(struct view *view, bool active); void ssd_set_active(struct view *view, bool active); void ssd_update_title(struct view *view); void ssd_update_geometry(struct view *view); diff --git a/src/ssd/ssd.c b/src/ssd/ssd.c index fdfc2cc2..673176fa 100644 --- a/src/ssd/ssd.c +++ b/src/ssd/ssd.c @@ -145,14 +145,9 @@ ssd_resize_edges(enum ssd_part_type type) } void -ssd_create(struct view *view) +ssd_create(struct view *view, bool active) { - bool is_active = view->server->focused_view == view; - - if (view->ssd.tree) { - ssd_set_active(view, is_active); - return; - } + assert(!view->ssd.tree); view->ssd.tree = wlr_scene_tree_create(view->scene_tree); wlr_scene_node_lower_to_bottom(&view->ssd.tree->node); @@ -160,7 +155,7 @@ ssd_create(struct view *view) ssd_border_create(view); ssd_titlebar_create(view); view->ssd.margin = ssd_thickness(view); - ssd_set_active(view, is_active); + ssd_set_active(view, active); } void diff --git a/src/view.c b/src/view.c index 16803389..d9d7f10f 100644 --- a/src/view.c +++ b/src/view.c @@ -557,7 +557,7 @@ view_set_decorations(struct view *view, bool decorations) assert(view); if (view->ssd_enabled != decorations && !view->fullscreen) { if (decorations) { - ssd_create(view); + ssd_create(view, view == view->server->focused_view); } else { ssd_destroy(view); } @@ -877,7 +877,7 @@ view_reload_ssd(struct view *view) assert(view); if (view->ssd_enabled) { ssd_destroy(view); - ssd_create(view); + ssd_create(view, view == view->server->focused_view); } }