summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Mykyta Holubakha <hilobakho@gmail.com>2016-07-11 22:27:13 +0300
committerLibravatar Mykyta Holubakha <hilobakho@gmail.com>2016-07-15 00:22:53 +0300
commitc503bf13426aa269779e81567e3b36ada56dabc1 (patch)
tree320a7d0455f6d433bbce76324ad816e29af803d4 /sway
parentSpawn new views to target ws's focused container (diff)
downloadsway-c503bf13426aa269779e81567e3b36ada56dabc1.tar.gz
sway-c503bf13426aa269779e81567e3b36ada56dabc1.tar.zst
sway-c503bf13426aa269779e81567e3b36ada56dabc1.zip
Suspend destruction of wss when creating views
Diffstat (limited to 'sway')
-rw-r--r--sway/focus.c3
-rw-r--r--sway/handlers.c27
2 files changed, 29 insertions, 1 deletions
diff --git a/sway/focus.c b/sway/focus.c
index 1d21ac35..0d9ee7e3 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -11,6 +11,7 @@
11 11
12bool locked_container_focus = false; 12bool locked_container_focus = false;
13bool locked_view_focus = false; 13bool locked_view_focus = false;
14bool suspend_workspace_cleanup = false;
14 15
15// switches parent focus to c. will switch it accordingly 16// switches parent focus to c. will switch it accordingly
16static void update_focus(swayc_t *c) { 17static void update_focus(swayc_t *c) {
@@ -40,7 +41,7 @@ static void update_focus(swayc_t *c) {
40 ipc_event_workspace(prev, c, "focus"); 41 ipc_event_workspace(prev, c, "focus");
41 42
42 // if the old workspace has no children, destroy it 43 // if the old workspace has no children, destroy it
43 if(prev->children->length == 0 && prev->floating->length == 0){ 44 if(prev->children->length == 0 && prev->floating->length == 0 && !suspend_workspace_cleanup) {
44 destroy_workspace(prev); 45 destroy_workspace(prev);
45 } else { 46 } else {
46 // update visibility of old workspace 47 // update visibility of old workspace
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
201static 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
201static bool handle_view_created(wlc_handle handle) { 222static 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