summaryrefslogtreecommitdiffstats
path: root/include/sway/tree/node.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sway/tree/node.h')
-rw-r--r--include/sway/tree/node.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/include/sway/tree/node.h b/include/sway/tree/node.h
new file mode 100644
index 00000000..5b8c1909
--- /dev/null
+++ b/include/sway/tree/node.h
@@ -0,0 +1,74 @@
1#ifndef _SWAY_NODE_H
2#define _SWAY_NODE_H
3#include <stdbool.h>
4#include "list.h"
5
6struct sway_root;
7struct sway_output;
8struct sway_workspace;
9struct sway_container;
10struct sway_transaction_instruction;
11struct wlr_box;
12
13enum sway_node_type {
14 N_ROOT,
15 N_OUTPUT,
16 N_WORKSPACE,
17 N_CONTAINER,
18};
19
20struct sway_node {
21 enum sway_node_type type;
22 union {
23 struct sway_root *sway_root;
24 struct sway_output *sway_output;
25 struct sway_workspace *sway_workspace;
26 struct sway_container *sway_container;
27 };
28
29 /**
30 * A unique ID to identify this node.
31 * Primarily used in the get_tree JSON output.
32 */
33 size_t id;
34
35 struct sway_transaction_instruction *instruction;
36 size_t ntxnrefs;
37 bool destroying;
38
39 // If true, indicates that the container has pending state that differs from
40 // the current.
41 bool dirty;
42
43 struct {
44 struct wl_signal destroy;
45 } events;
46};
47
48void node_init(struct sway_node *node, enum sway_node_type type, void *thing);
49
50const char *node_type_to_str(enum sway_node_type type);
51
52/**
53 * Mark a node as dirty if it isn't already. Dirty nodes will be included in the
54 * next transaction then unmarked as dirty.
55 */
56void node_set_dirty(struct sway_node *node);
57
58bool node_is_view(struct sway_node *node);
59
60char *node_get_name(struct sway_node *node);
61
62void node_get_box(struct sway_node *node, struct wlr_box *box);
63
64struct sway_output *node_get_output(struct sway_node *node);
65
66enum sway_container_layout node_get_layout(struct sway_node *node);
67
68struct sway_node *node_get_parent(struct sway_node *node);
69
70list_t *node_get_children(struct sway_node *node);
71
72bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor);
73
74#endif