diff options
author | 2016-07-11 22:27:13 +0300 | |
---|---|---|
committer | 2016-07-15 00:22:53 +0300 | |
commit | c503bf13426aa269779e81567e3b36ada56dabc1 (patch) | |
tree | 320a7d0455f6d433bbce76324ad816e29af803d4 /sway/handlers.c | |
parent | Spawn new views to target ws's focused container (diff) | |
download | sway-c503bf13426aa269779e81567e3b36ada56dabc1.tar.gz sway-c503bf13426aa269779e81567e3b36ada56dabc1.tar.zst sway-c503bf13426aa269779e81567e3b36ada56dabc1.zip |
Suspend destruction of wss when creating views
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index e322c579..4336b6c7 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -198,6 +198,27 @@ static bool client_is_panel(struct wl_client *client) { | |||
198 | return false; | 198 | return false; |
199 | } | 199 | } |
200 | 200 | ||
201 | static void ws_cleanup() { | ||
202 | swayc_t *op, *ws; | ||
203 | int i = 0, j; | ||
204 | if (!root_container.children) | ||
205 | return; | ||
206 | while (i < root_container.children->length) { | ||
207 | op = root_container.children->items[i++]; | ||
208 | if (!op->children) | ||
209 | continue; | ||
210 | j = 0; | ||
211 | while (j < op->children->length) { | ||
212 | ws = op->children->items[j++]; | ||
213 | if (ws->children->length == 0 && ws->floating->length == 0 && ws != op->focused) { | ||
214 | if (destroy_workspace(ws)) { | ||
215 | j--; | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | |||
201 | static bool handle_view_created(wlc_handle handle) { | 222 | static bool handle_view_created(wlc_handle handle) { |
202 | // if view is child of another view, the use that as focused container | 223 | // if view is child of another view, the use that as focused container |
203 | wlc_handle parent = wlc_view_get_parent(handle); | 224 | wlc_handle parent = wlc_view_get_parent(handle); |
@@ -295,6 +316,9 @@ static bool handle_view_created(wlc_handle handle) { | |||
295 | break; | 316 | break; |
296 | } | 317 | } |
297 | 318 | ||
319 | // Prevent current ws from being destroyed, if empty | ||
320 | suspend_workspace_cleanup = true; | ||
321 | |||
298 | if (newview) { | 322 | if (newview) { |
299 | set_focused_container(newview); | 323 | set_focused_container(newview); |
300 | swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT); | 324 | swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT); |
@@ -343,6 +367,9 @@ static bool handle_view_created(wlc_handle handle) { | |||
343 | workspace_switch(current_ws); | 367 | workspace_switch(current_ws); |
344 | set_focused_container(current_ws->focused); | 368 | set_focused_container(current_ws->focused); |
345 | } | 369 | } |
370 | |||
371 | suspend_workspace_cleanup = false; | ||
372 | ws_cleanup(); | ||
346 | return true; | 373 | return true; |
347 | } | 374 | } |
348 | 375 | ||