mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
Add node-descriptor for wlr_scene_nodes
Support identification of wlr_scene_node role to enable simplification of codebase including the avoidance of iterating over lists of layer-surface, menuitems, and so on. Use node-descriptors for xdg toplevels and popups
This commit is contained in:
parent
4c981b845f
commit
2891ff245e
7 changed files with 92 additions and 6 deletions
37
src/node-descriptor.c
Normal file
37
src/node-descriptor.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
#include <stdlib.h>
|
||||
#include "node-descriptor.h"
|
||||
|
||||
static void
|
||||
descriptor_destroy(struct node_descriptor *node_descriptor)
|
||||
{
|
||||
if (!node_descriptor) {
|
||||
return;
|
||||
}
|
||||
wl_list_remove(&node_descriptor->destroy.link);
|
||||
free(node_descriptor);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_notify(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct node_descriptor *node_descriptor =
|
||||
wl_container_of(listener, node_descriptor, destroy);
|
||||
descriptor_destroy(node_descriptor);
|
||||
}
|
||||
|
||||
void
|
||||
node_descriptor_create(struct wlr_scene_node *node,
|
||||
enum node_descriptor_type type, void *data)
|
||||
{
|
||||
struct node_descriptor *node_descriptor =
|
||||
calloc(1, sizeof(struct node_descriptor));
|
||||
if (!node_descriptor) {
|
||||
return;
|
||||
}
|
||||
node_descriptor->type = type;
|
||||
node_descriptor->data = data;
|
||||
node_descriptor->destroy.notify = destroy_notify;
|
||||
wl_signal_add(&node->events.destroy, &node_descriptor->destroy);
|
||||
node->data = node_descriptor;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue