]> git.mdlowis.com Git - proto/labwc.git/commitdiff
ssd: Simplify ssd_create()
authorJohn Lindgren <john@jlindgren.net>
Sat, 26 Nov 2022 07:17:04 +0000 (02:17 -0500)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 26 Nov 2022 18:02:24 +0000 (18:02 +0000)
- 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
src/ssd/ssd.c
src/view.c

index 06a3e1d3ac56f918a8a8077b08bab636dcf3f155..d26df066a52c85ef643b5325cec1648db6ee4857 100644 (file)
@@ -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);
index fdfc2cc23271a80c8ab6342e36471fbee796b97e..673176fa1db285d47037926589b4e7e89c43ed35 100644 (file)
@@ -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
index 168033890a290a0ec816649efd1cc3fad4536350..d9d7f10f3db04245cbea51a88addd771181bc9e9 100644 (file)
@@ -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);
        }
 }