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