diff options
Diffstat (limited to 'sway/tree/node.c')
-rw-r--r-- | sway/tree/node.c | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/sway/tree/node.c b/sway/tree/node.c index ffa7f2cc..213cf0a6 100644 --- a/sway/tree/node.c +++ b/sway/tree/node.c | |||
@@ -18,13 +18,13 @@ void node_init(struct sway_node *node, enum sway_node_type type, void *thing) { | |||
18 | const char *node_type_to_str(enum sway_node_type type) { | 18 | const char *node_type_to_str(enum sway_node_type type) { |
19 | switch (type) { | 19 | switch (type) { |
20 | case N_ROOT: | 20 | case N_ROOT: |
21 | return "N_ROOT"; | 21 | return "root"; |
22 | case N_OUTPUT: | 22 | case N_OUTPUT: |
23 | return "N_OUTPUT"; | 23 | return "output"; |
24 | case N_WORKSPACE: | 24 | case N_WORKSPACE: |
25 | return "N_WORKSPACE"; | 25 | return "workspace"; |
26 | case N_CONTAINER: | 26 | case N_CONTAINER: |
27 | return "N_CONTAINER"; | 27 | return "container"; |
28 | } | 28 | } |
29 | return ""; | 29 | return ""; |
30 | } | 30 | } |
@@ -75,7 +75,7 @@ void node_get_box(struct sway_node *node, struct wlr_box *box) { | |||
75 | struct sway_output *node_get_output(struct sway_node *node) { | 75 | struct sway_output *node_get_output(struct sway_node *node) { |
76 | switch (node->type) { | 76 | switch (node->type) { |
77 | case N_CONTAINER: { | 77 | case N_CONTAINER: { |
78 | struct sway_workspace *ws = node->sway_container->workspace; | 78 | struct sway_workspace *ws = node->sway_container->pending.workspace; |
79 | return ws ? ws->output : NULL; | 79 | return ws ? ws->output : NULL; |
80 | } | 80 | } |
81 | case N_WORKSPACE: | 81 | case N_WORKSPACE: |
@@ -91,7 +91,7 @@ struct sway_output *node_get_output(struct sway_node *node) { | |||
91 | enum sway_container_layout node_get_layout(struct sway_node *node) { | 91 | enum sway_container_layout node_get_layout(struct sway_node *node) { |
92 | switch (node->type) { | 92 | switch (node->type) { |
93 | case N_CONTAINER: | 93 | case N_CONTAINER: |
94 | return node->sway_container->layout; | 94 | return node->sway_container->pending.layout; |
95 | case N_WORKSPACE: | 95 | case N_WORKSPACE: |
96 | return node->sway_workspace->layout; | 96 | return node->sway_workspace->layout; |
97 | case N_OUTPUT: | 97 | case N_OUTPUT: |
@@ -105,11 +105,11 @@ struct sway_node *node_get_parent(struct sway_node *node) { | |||
105 | switch (node->type) { | 105 | switch (node->type) { |
106 | case N_CONTAINER: { | 106 | case N_CONTAINER: { |
107 | struct sway_container *con = node->sway_container; | 107 | struct sway_container *con = node->sway_container; |
108 | if (con->parent) { | 108 | if (con->pending.parent) { |
109 | return &con->parent->node; | 109 | return &con->pending.parent->node; |
110 | } | 110 | } |
111 | if (con->workspace) { | 111 | if (con->pending.workspace) { |
112 | return &con->workspace->node; | 112 | return &con->pending.workspace->node; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | return NULL; | 115 | return NULL; |
@@ -131,7 +131,7 @@ struct sway_node *node_get_parent(struct sway_node *node) { | |||
131 | list_t *node_get_children(struct sway_node *node) { | 131 | list_t *node_get_children(struct sway_node *node) { |
132 | switch (node->type) { | 132 | switch (node->type) { |
133 | case N_CONTAINER: | 133 | case N_CONTAINER: |
134 | return node->sway_container->children; | 134 | return node->sway_container->pending.children; |
135 | case N_WORKSPACE: | 135 | case N_WORKSPACE: |
136 | return node->sway_workspace->tiling; | 136 | return node->sway_workspace->tiling; |
137 | case N_OUTPUT: | 137 | case N_OUTPUT: |
@@ -143,7 +143,7 @@ list_t *node_get_children(struct sway_node *node) { | |||
143 | 143 | ||
144 | bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) { | 144 | bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) { |
145 | if (ancestor->type == N_ROOT && node->type == N_CONTAINER && | 145 | if (ancestor->type == N_ROOT && node->type == N_CONTAINER && |
146 | node->sway_container->fullscreen_mode == FULLSCREEN_GLOBAL) { | 146 | node->sway_container->pending.fullscreen_mode == FULLSCREEN_GLOBAL) { |
147 | return true; | 147 | return true; |
148 | } | 148 | } |
149 | struct sway_node *parent = node_get_parent(node); | 149 | struct sway_node *parent = node_get_parent(node); |
@@ -152,10 +152,39 @@ bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor) { | |||
152 | return true; | 152 | return true; |
153 | } | 153 | } |
154 | if (ancestor->type == N_ROOT && parent->type == N_CONTAINER && | 154 | if (ancestor->type == N_ROOT && parent->type == N_CONTAINER && |
155 | parent->sway_container->fullscreen_mode == FULLSCREEN_GLOBAL) { | 155 | parent->sway_container->pending.fullscreen_mode == FULLSCREEN_GLOBAL) { |
156 | return true; | 156 | return true; |
157 | } | 157 | } |
158 | parent = node_get_parent(parent); | 158 | parent = node_get_parent(parent); |
159 | } | 159 | } |
160 | return false; | 160 | return false; |
161 | } | 161 | } |
162 | |||
163 | void scene_node_disown_children(struct wlr_scene_tree *tree) { | ||
164 | // this function can be called as part of destruction code that will be invoked | ||
165 | // upon an allocation failure. Let's not crash on NULL due to an allocation error. | ||
166 | if (!tree) { | ||
167 | return; | ||
168 | } | ||
169 | |||
170 | struct wlr_scene_node *child, *tmp_child; | ||
171 | wl_list_for_each_safe(child, tmp_child, &tree->children, link) { | ||
172 | wlr_scene_node_reparent(child, root->staging); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | struct wlr_scene_tree *alloc_scene_tree(struct wlr_scene_tree *parent, | ||
177 | bool *failed) { | ||
178 | // fallthrough | ||
179 | if (*failed) { | ||
180 | return NULL; | ||
181 | } | ||
182 | |||
183 | struct wlr_scene_tree *tree = wlr_scene_tree_create(parent); | ||
184 | if (!tree) { | ||
185 | sway_log(SWAY_ERROR, "Failed to allocate a scene node"); | ||
186 | *failed = true; | ||
187 | } | ||
188 | |||
189 | return tree; | ||
190 | } | ||