Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions sway/input/seat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1133,8 +1133,6 @@ static void seat_set_workspace_focus(struct sway_seat *seat, struct sway_node *n
return;
}

struct sway_workspace *last_workspace = seat_get_focused_workspace(seat);

if (node == NULL) {
seat_send_unfocus(last_focus, seat);
sway_input_method_relay_set_focus(&seat->im_relay, NULL);
Expand All @@ -1157,17 +1155,15 @@ static void seat_set_workspace_focus(struct sway_seat *seat, struct sway_node *n
return;
}

// Find the output's last workspace, which might have to be removed if empty
struct sway_output *new_output =
new_workspace ? new_workspace->output : NULL;

struct sway_workspace *last_workspace =
new_output ? output_get_active_workspace(new_output) : NULL;
if (last_workspace != new_workspace && new_output) {
node_set_dirty(&new_output->node);
}

// find new output's old workspace, which might have to be removed if empty
struct sway_workspace *new_output_last_ws =
new_output ? output_get_active_workspace(new_output) : NULL;

// Unfocus the previous focus
if (last_focus) {
seat_send_unfocus(last_focus, seat);
Expand Down Expand Up @@ -1211,11 +1207,11 @@ static void seat_set_workspace_focus(struct sway_seat *seat, struct sway_node *n
}

// Move sticky containers to new workspace
if (new_workspace && new_output_last_ws
&& new_workspace != new_output_last_ws) {
for (int i = 0; i < new_output_last_ws->floating->length; ++i) {
if (new_workspace && last_workspace
&& new_workspace != last_workspace) {
for (int i = 0; i < last_workspace->floating->length; ++i) {
struct sway_container *floater =
new_output_last_ws->floating->items[i];
last_workspace->floating->items[i];
if (container_is_sticky(floater)) {
container_detach(floater);
workspace_add_floating(new_workspace, floater);
Expand Down Expand Up @@ -1244,13 +1240,9 @@ static void seat_set_workspace_focus(struct sway_seat *seat, struct sway_node *n
}
}

if (new_output_last_ws) {
workspace_consider_destroy(new_output_last_ws);
}
if (last_workspace && last_workspace != new_output_last_ws) {
if (last_workspace) {
workspace_consider_destroy(last_workspace);
}

seat->has_focus = true;

if (config->smart_gaps && new_workspace) {
Expand Down