mirror of
https://github.com/labwc/labwc.git
synced 2026-04-07 08:21:20 -04:00
ssd: unify struct ssd_part with struct node_descriptor
struct ssd_part and struct node_descriptor seem to have essentially the same purpose: tag a wlr_scene_node with some extra data indicating what we're using it for. Also, as with enum ssd_part_type (now lab_node_type), ssd_part is used for several types of nodes that are not part of SSD. So instead of the current chaining (node_descriptor -> ssd_part), let's flatten/unify the two structs. In detail: - First, merge node_descriptor_type into lab_node_type. - Add a separate view pointer in node_descriptor, since in the case of SSD buttons we need separate view and button data pointers. - Rename ssd_part_button to simply ssd_button. It no longer contains an ssd_part as base. - Add node_try_ssd_button_from_node() which replaces node_ssd_part_from_node() + button_try_from_ssd_part(). - Factor out ssd_button_free() to be called in node descriptor destroy. - Finally, get_cursor_context() needs a little reorganization to handle the unified structs. Overall, this simplifies the code a bit, and in my opinion makes it easier to understand. No functional change intended.
This commit is contained in:
parent
ba426e2271
commit
f129571779
22 changed files with 169 additions and 239 deletions
|
|
@ -14,6 +14,7 @@
|
|||
#include "common/scene-helpers.h"
|
||||
#include "config/rcxml.h"
|
||||
#include "labwc.h"
|
||||
#include "node.h"
|
||||
#include "ssd-internal.h"
|
||||
#include "theme.h"
|
||||
#include "view.h"
|
||||
|
|
@ -145,7 +146,8 @@ ssd_create(struct view *view, bool active)
|
|||
|
||||
ssd->view = view;
|
||||
ssd->tree = wlr_scene_tree_create(view->scene_tree);
|
||||
attach_ssd_part(LAB_NODE_NONE, view, &ssd->tree->node);
|
||||
node_descriptor_create(&ssd->tree->node,
|
||||
LAB_NODE_NONE, view, /*data*/ NULL);
|
||||
wlr_scene_node_lower_to_bottom(&ssd->tree->node);
|
||||
ssd->titlebar.height = view->server->theme->titlebar_height;
|
||||
ssd_shadow_create(ssd);
|
||||
|
|
@ -265,7 +267,8 @@ ssd_destroy(struct ssd *ssd)
|
|||
/* Maybe reset hover view */
|
||||
struct view *view = ssd->view;
|
||||
struct server *server = view->server;
|
||||
if (server->hovered_button && server->hovered_button->base.view == view) {
|
||||
if (server->hovered_button && node_view_from_node(
|
||||
server->hovered_button->node) == view) {
|
||||
server->hovered_button = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -343,18 +346,6 @@ ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable)
|
|||
wlr_scene_rect_set_color(ssd->border.subtrees[SSD_ACTIVE].top, color);
|
||||
}
|
||||
|
||||
enum lab_node_type
|
||||
ssd_part_get_type(const struct ssd_part *part)
|
||||
{
|
||||
return part ? part->type : LAB_NODE_NONE;
|
||||
}
|
||||
|
||||
struct view *
|
||||
ssd_part_get_view(const struct ssd_part *part)
|
||||
{
|
||||
return part ? part->view : NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
ssd_debug_is_root_node(const struct ssd *ssd, struct wlr_scene_node *node)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue