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
This commit is contained in:
John Lindgren 2022-11-26 02:17:04 -05:00 committed by Johan Malm
parent ac9228e7f8
commit 4e7891eb8d
3 changed files with 6 additions and 11 deletions

View file

@ -146,7 +146,7 @@ struct ssd_hover_state {
}; };
/* Public SSD API */ /* 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_set_active(struct view *view, bool active);
void ssd_update_title(struct view *view); void ssd_update_title(struct view *view);
void ssd_update_geometry(struct view *view); void ssd_update_geometry(struct view *view);

View file

@ -145,14 +145,9 @@ ssd_resize_edges(enum ssd_part_type type)
} }
void void
ssd_create(struct view *view) ssd_create(struct view *view, bool active)
{ {
bool is_active = view->server->focused_view == view; assert(!view->ssd.tree);
if (view->ssd.tree) {
ssd_set_active(view, is_active);
return;
}
view->ssd.tree = wlr_scene_tree_create(view->scene_tree); view->ssd.tree = wlr_scene_tree_create(view->scene_tree);
wlr_scene_node_lower_to_bottom(&view->ssd.tree->node); wlr_scene_node_lower_to_bottom(&view->ssd.tree->node);
@ -160,7 +155,7 @@ ssd_create(struct view *view)
ssd_border_create(view); ssd_border_create(view);
ssd_titlebar_create(view); ssd_titlebar_create(view);
view->ssd.margin = ssd_thickness(view); view->ssd.margin = ssd_thickness(view);
ssd_set_active(view, is_active); ssd_set_active(view, active);
} }
void void

View file

@ -557,7 +557,7 @@ view_set_decorations(struct view *view, bool decorations)
assert(view); assert(view);
if (view->ssd_enabled != decorations && !view->fullscreen) { if (view->ssd_enabled != decorations && !view->fullscreen) {
if (decorations) { if (decorations) {
ssd_create(view); ssd_create(view, view == view->server->focused_view);
} else { } else {
ssd_destroy(view); ssd_destroy(view);
} }
@ -877,7 +877,7 @@ view_reload_ssd(struct view *view)
assert(view); assert(view);
if (view->ssd_enabled) { if (view->ssd_enabled) {
ssd_destroy(view); ssd_destroy(view);
ssd_create(view); ssd_create(view, view == view->server->focused_view);
} }
} }