ssd: Allocate struct ssd and struct ssd_hover_state separately

- Store a pointer to the `struct view` in `struct ssd`
- Pass `struct ssd *` instead of `struct view *` to ssd functions
- Add `ssd_get_margin()` convenience function
This commit is contained in:
John Lindgren 2022-11-26 16:46:28 -05:00 committed by Johan Malm
parent cfa51ab628
commit 1e8b0414fe
15 changed files with 112 additions and 65 deletions

View file

@ -80,6 +80,7 @@ struct ssd_state_title_width {
};
struct ssd {
struct view *view;
struct wlr_scene_tree *tree;
/*
@ -144,12 +145,23 @@ struct ssd_hover_state {
struct wlr_scene_node *node;
};
/* Public SSD API */
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);
void ssd_destroy(struct view *view);
/*
* Public SSD API
*
* For convenience in dealing with non-SSD views, this API allows NULL
* ssd/button/node arguments and attempts to do something sensible in
* that case (e.g. no-op/return default values).
*
* NULL scene/view arguments are not allowed.
*/
struct ssd *ssd_create(struct view *view, bool active);
struct border ssd_get_margin(const struct ssd *ssd);
void ssd_set_active(struct ssd *ssd, bool active);
void ssd_update_title(struct ssd *ssd);
void ssd_update_geometry(struct ssd *ssd);
void ssd_destroy(struct ssd *ssd);
struct ssd_hover_state *ssd_hover_state_new(void);
void ssd_update_button_hover(struct wlr_scene_node *node,
struct ssd_hover_state *hover_state);