mirror of
https://github.com/swaywm/sway.git
synced 2026-04-22 06:46:27 -04:00
scene_graph: Introduce sway_scene_descriptor
Across a wayland compositor, there are multiple shells: It can be a toplevel, or a layer_shell, or even something more meta like a drag icon or highlight indicators when dragging windows around. This object lets us store values that represent these modes of operation and keep track of what object is being represented.
This commit is contained in:
parent
be54b77886
commit
8eb7ec53d4
3 changed files with 53 additions and 0 deletions
19
include/sway/scene_descriptor.h
Normal file
19
include/sway/scene_descriptor.h
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef _SWAY_SCENE_DESCRIPTOR_H
|
||||||
|
#define _SWAY_SCENE_DESCRIPTOR_H
|
||||||
|
#include <wlr/types/wlr_scene.h>
|
||||||
|
|
||||||
|
enum sway_scene_descriptor_type {
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sway_scene_descriptor {
|
||||||
|
struct wlr_scene_node *node;
|
||||||
|
enum sway_scene_descriptor_type type;
|
||||||
|
void *data;
|
||||||
|
|
||||||
|
struct wl_listener destroy;
|
||||||
|
};
|
||||||
|
|
||||||
|
void scene_descriptor_assign(struct wlr_scene_node *node,
|
||||||
|
enum sway_scene_descriptor_type type, void *data);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -8,6 +8,7 @@ sway_sources = files(
|
||||||
'lock.c',
|
'lock.c',
|
||||||
'main.c',
|
'main.c',
|
||||||
'realtime.c',
|
'realtime.c',
|
||||||
|
'scene_descriptor.c',
|
||||||
'server.c',
|
'server.c',
|
||||||
'swaynag.c',
|
'swaynag.c',
|
||||||
'xdg_activation_v1.c',
|
'xdg_activation_v1.c',
|
||||||
|
|
|
||||||
33
sway/scene_descriptor.c
Normal file
33
sway/scene_descriptor.c
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "log.h"
|
||||||
|
#include "sway/scene_descriptor.h"
|
||||||
|
|
||||||
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
struct sway_scene_descriptor *desc =
|
||||||
|
wl_container_of(listener, desc, destroy);
|
||||||
|
|
||||||
|
desc->node->data = NULL;
|
||||||
|
wl_list_remove(&desc->destroy.link);
|
||||||
|
|
||||||
|
free(desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void scene_descriptor_assign(struct wlr_scene_node *node,
|
||||||
|
enum sway_scene_descriptor_type type, void *data) {
|
||||||
|
struct sway_scene_descriptor *desc =
|
||||||
|
calloc(1, sizeof(struct sway_scene_descriptor));
|
||||||
|
|
||||||
|
if (!desc) {
|
||||||
|
sway_log(SWAY_ERROR, "Could not allocate a scene descriptor");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
desc->type = type;
|
||||||
|
desc->data = data;
|
||||||
|
desc->node = node;
|
||||||
|
|
||||||
|
desc->destroy.notify = handle_destroy;
|
||||||
|
wl_signal_add(&node->events.destroy, &desc->destroy);
|
||||||
|
|
||||||
|
node->data = desc;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue