37 lines
1.5 KiB
C
37 lines
1.5 KiB
C
#define _POSIX_C_SOURCE 200112L
|
|
#include <stdlib.h>
|
|
#include <assert.h>
|
|
#include "node.h"
|
|
|
|
static void destroy_notify(struct wl_listener *listener, void *data)
|
|
{
|
|
struct diyac_node_descriptor *node_descriptor =
|
|
wl_container_of(listener, node_descriptor, destroy);
|
|
wl_list_remove(&node_descriptor->destroy.link);
|
|
free(node_descriptor);
|
|
}
|
|
|
|
void diyac_node_descriptor_create(struct wlr_scene_node *scene_node, enum diyac_node_descriptor_type type, void *data)
|
|
{
|
|
struct diyac_node_descriptor *node_descriptor = calloc(1, sizeof(*node_descriptor));
|
|
node_descriptor->type = type;
|
|
node_descriptor->data = data;
|
|
node_descriptor->destroy.notify = destroy_notify;
|
|
wl_signal_add(&scene_node->events.destroy, &node_descriptor->destroy);
|
|
scene_node->data = node_descriptor;
|
|
}
|
|
|
|
struct diyac_layer_surface *diyac_layer_surface_from_node(struct wlr_scene_node *wlr_scene_node)
|
|
{
|
|
assert(wlr_scene_node->data);
|
|
struct diyac_node_descriptor *node_descriptor = wlr_scene_node->data;
|
|
assert(node_descriptor->type == DIYAC_NODE_LAYER_SURFACE);
|
|
return (struct diyac_layer_surface *)node_descriptor->data;
|
|
}
|
|
struct diyac_view *diyac_view_from_node(struct wlr_scene_node *wlr_scene_node)
|
|
{
|
|
assert(wlr_scene_node->data);
|
|
struct diyac_node_descriptor *node_descriptor = wlr_scene_node->data;
|
|
assert(node_descriptor->type == DIYAC_NODE_VIEW || node_descriptor->type == DIYAC_NODE_XDG_POPUP);
|
|
return (struct diyac_view *)node_descriptor->data;
|
|
} |