Stop destroying empty workspaces

Otherwise information about assigned output is lost
This commit is contained in:
Jan Palus 2021-02-16 21:19:49 +01:00
parent 28cadf5580
commit 6c9995b859
9 changed files with 2 additions and 52 deletions

View file

@ -56,8 +56,6 @@ void workspace_destroy(struct sway_workspace *workspace);
void workspace_begin_destroy(struct sway_workspace *workspace); void workspace_begin_destroy(struct sway_workspace *workspace);
void workspace_consider_destroy(struct sway_workspace *ws);
char *workspace_next_name(const char *output_name); char *workspace_next_name(const char *output_name);
bool workspace_switch(struct sway_workspace *workspace, bool workspace_switch(struct sway_workspace *workspace,

View file

@ -601,15 +601,13 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
// clean-up, destroying parents if the container was the last child // clean-up, destroying parents if the container was the last child
if (old_parent) { if (old_parent) {
container_reap_empty(old_parent); container_reap_empty(old_parent);
} else if (old_ws) {
workspace_consider_destroy(old_ws);
} }
// arrange windows // arrange windows
if (root->fullscreen_global) { if (root->fullscreen_global) {
arrange_root(); arrange_root();
} else { } else {
if (old_ws && !old_ws->node.destroying) { if (old_ws) {
arrange_workspace(old_ws); arrange_workspace(old_ws);
} }
arrange_node(node_get_parent(destination)); arrange_node(node_get_parent(destination));
@ -643,8 +641,6 @@ static void workspace_move_to_output(struct sway_workspace *workspace,
seat_set_raw_focus(seat, &ws->node); seat_set_raw_focus(seat, &ws->node);
} }
workspace_consider_destroy(new_output_old_ws);
output_sort_workspaces(output); output_sort_workspaces(output);
struct sway_node *focus = seat_get_focus_inactive(seat, &workspace->node); struct sway_node *focus = seat_get_focus_inactive(seat, &workspace->node);
seat_set_focus(seat, focus); seat_set_focus(seat, focus);
@ -740,8 +736,6 @@ static struct cmd_results *cmd_move_in_direction(
// clean-up, destroying parents if the container was the last child // clean-up, destroying parents if the container was the last child
if (old_parent) { if (old_parent) {
container_reap_empty(old_parent); container_reap_empty(old_parent);
} else if (old_ws) {
workspace_consider_destroy(old_ws);
} }
struct sway_workspace *new_ws = container->workspace; struct sway_workspace *new_ws = container->workspace;

View file

@ -36,12 +36,10 @@ struct cmd_results *cmd_sticky(int argc, char **argv) {
"Expected output to have a workspace"); "Expected output to have a workspace");
} }
if (container->workspace != active_workspace) { if (container->workspace != active_workspace) {
struct sway_workspace *old_workspace = container->workspace;
container_detach(container); container_detach(container);
workspace_add_floating(active_workspace, container); workspace_add_floating(active_workspace, container);
container_handle_fullscreen_reparent(container); container_handle_fullscreen_reparent(container);
arrange_workspace(active_workspace); arrange_workspace(active_workspace);
workspace_consider_destroy(old_workspace);
} }
} }

View file

@ -1194,13 +1194,6 @@ void seat_set_focus(struct sway_seat *seat, struct sway_node *node) {
} }
} }
if (new_output_last_ws) {
workspace_consider_destroy(new_output_last_ws);
}
if (last_workspace && last_workspace != new_output_last_ws) {
workspace_consider_destroy(last_workspace);
}
seat->has_focus = true; seat->has_focus = true;
if (config->smart_gaps && new_workspace) { if (config->smart_gaps && new_workspace) {

View file

@ -121,7 +121,6 @@ void container_reap_empty(struct sway_container *con) {
if (con->view) { if (con->view) {
return; return;
} }
struct sway_workspace *ws = con->workspace;
while (con) { while (con) {
if (con->children->length) { if (con->children->length) {
return; return;
@ -130,9 +129,6 @@ void container_reap_empty(struct sway_container *con) {
container_begin_destroy(con); container_begin_destroy(con);
con = parent; con = parent;
} }
if (ws) {
workspace_consider_destroy(ws);
}
} }
struct sway_container *container_flatten(struct sway_container *container) { struct sway_container *container_flatten(struct sway_container *container) {

View file

@ -216,12 +216,6 @@ static void output_evacuate(struct sway_output *output) {
output_add_workspace(new_output, workspace); output_add_workspace(new_output, workspace);
output_sort_workspaces(new_output); output_sort_workspaces(new_output);
ipc_event_workspace(NULL, workspace, "move"); ipc_event_workspace(NULL, workspace, "move");
// If there is an old workspace (the noop output may not have one),
// check to see if it is empty and should be destroyed.
if (new_output_ws) {
workspace_consider_destroy(new_output_ws);
}
} }
} }

View file

@ -131,7 +131,6 @@ void root_scratchpad_show(struct sway_container *con) {
// Show the container // Show the container
if (old_ws) { if (old_ws) {
container_detach(con); container_detach(con);
workspace_consider_destroy(old_ws);
} else { } else {
// Act on the ancestor of scratchpad hidden split containers // Act on the ancestor of scratchpad hidden split containers
while (con->parent) { while (con->parent) {

View file

@ -843,14 +843,12 @@ void view_unmap(struct sway_view *view) {
container_begin_destroy(view->container); container_begin_destroy(view->container);
if (parent) { if (parent) {
container_reap_empty(parent); container_reap_empty(parent);
} else if (ws) {
workspace_consider_destroy(ws);
} }
if (root->fullscreen_global) { if (root->fullscreen_global) {
// Container may have been a child of the root fullscreen container // Container may have been a child of the root fullscreen container
arrange_root(); arrange_root();
} else if (ws && !ws->node.destroying) { } else if (ws) {
arrange_workspace(ws); arrange_workspace(ws);
workspace_detect_urgent(ws); workspace_detect_urgent(ws);
} }

View file

@ -151,26 +151,6 @@ void workspace_begin_destroy(struct sway_workspace *workspace) {
node_set_dirty(&workspace->node); node_set_dirty(&workspace->node);
} }
void workspace_consider_destroy(struct sway_workspace *ws) {
if (ws->tiling->length || ws->floating->length) {
return;
}
if (ws->output && output_get_active_workspace(ws->output) == ws) {
return;
}
struct sway_seat *seat;
wl_list_for_each(seat, &server.input->seats, link) {
struct sway_node *node = seat_get_focus_inactive(seat, &root->node);
if (node == &ws->node) {
return;
}
}
workspace_begin_destroy(ws);
}
static bool workspace_valid_on_output(const char *output_name, static bool workspace_valid_on_output(const char *output_name,
const char *ws_name) { const char *ws_name) {
struct workspace_config *wsc = workspace_find_config(ws_name); struct workspace_config *wsc = workspace_find_config(ws_name);