aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-08-07 23:27:56 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-08-07 23:32:25 +1000
commit50f3a7ff5cf2f30b6644dc578723b60ab3f0d26d (patch)
tree00955b8114f5c960f27e2065a7e8478953ec441b
parent1818c58e4060624ccb9102f88dd977702b688008 (diff)
Fix infinite loop when focusing sticky containers via workspace command
In a multi-output setup, if a sticky container is on one output and focus is on the other output, and you run (eg) `workspace 1` to focus the workspace containing the sticky container, an infinite loop would occur. It would loop infinitely because it would remove the sticky container from the workspace, add it back to the same workspace, and then decrement the iterator variable. The fix just wraps the loop in a workspace comparison.
-rw-r--r--sway/tree/workspace.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index 3fcad631..395c6c10 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -411,17 +411,20 @@ bool workspace_switch(struct sway_container *workspace,
struct sway_container *floating =
next_output_prev_ws->sway_workspace->floating;
bool has_sticky = false;
- for (int i = 0; i < floating->children->length; ++i) {
- struct sway_container *floater = floating->children->items[i];
- if (floater->is_sticky) {
- has_sticky = true;
- container_remove_child(floater);
- container_add_child(workspace->sway_workspace->floating, floater);
- if (floater == focus) {
- seat_set_focus(seat, NULL);
- seat_set_focus(seat, floater);
+ if (workspace != next_output_prev_ws) {
+ for (int i = 0; i < floating->children->length; ++i) {
+ struct sway_container *floater = floating->children->items[i];
+ if (floater->is_sticky) {
+ has_sticky = true;
+ container_remove_child(floater);
+ container_add_child(workspace->sway_workspace->floating,
+ floater);
+ if (floater == focus) {
+ seat_set_focus(seat, NULL);
+ seat_set_focus(seat, floater);
+ }
+ --i;
}
- --i;
}
}