Suspend destruction of wss when creating views

This commit is contained in:
Mykyta Holubakha 2016-07-11 22:27:13 +03:00
parent a2bb280172
commit c503bf1342
3 changed files with 31 additions and 1 deletions

View file

@ -198,6 +198,27 @@ static bool client_is_panel(struct wl_client *client) {
return false;
}
static void ws_cleanup() {
swayc_t *op, *ws;
int i = 0, j;
if (!root_container.children)
return;
while (i < root_container.children->length) {
op = root_container.children->items[i++];
if (!op->children)
continue;
j = 0;
while (j < op->children->length) {
ws = op->children->items[j++];
if (ws->children->length == 0 && ws->floating->length == 0 && ws != op->focused) {
if (destroy_workspace(ws)) {
j--;
}
}
}
}
}
static bool handle_view_created(wlc_handle handle) {
// if view is child of another view, the use that as focused container
wlc_handle parent = wlc_view_get_parent(handle);
@ -295,6 +316,9 @@ static bool handle_view_created(wlc_handle handle) {
break;
}
// Prevent current ws from being destroyed, if empty
suspend_workspace_cleanup = true;
if (newview) {
set_focused_container(newview);
swayc_t *output = swayc_parent_by_type(newview, C_OUTPUT);
@ -343,6 +367,9 @@ static bool handle_view_created(wlc_handle handle) {
workspace_switch(current_ws);
set_focused_container(current_ws->focused);
}
suspend_workspace_cleanup = false;
ws_cleanup();
return true;
}