aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-07 23:27:56 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-07 23:32:25 +1000
commit50f3a7ff5cf2f30b6644dc578723b60ab3f0d26d (patch)
tree00955b8114f5c960f27e2065a7e8478953ec441b /sway/tree/workspace.c
parentMerge pull request #2430 from ianyfan/socketpath-leaks (diff)
downloadsway-50f3a7ff5cf2f30b6644dc578723b60ab3f0d26d.tar.gz
sway-50f3a7ff5cf2f30b6644dc578723b60ab3f0d26d.tar.zst
sway-50f3a7ff5cf2f30b6644dc578723b60ab3f0d26d.zip
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.
Diffstat (limited to 'sway/tree/workspace.c')
-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,
411 struct sway_container *floating = 411 struct sway_container *floating =
412 next_output_prev_ws->sway_workspace->floating; 412 next_output_prev_ws->sway_workspace->floating;
413 bool has_sticky = false; 413 bool has_sticky = false;
414 for (int i = 0; i < floating->children->length; ++i) { 414 if (workspace != next_output_prev_ws) {
415 struct sway_container *floater = floating->children->items[i]; 415 for (int i = 0; i < floating->children->length; ++i) {
416 if (floater->is_sticky) { 416 struct sway_container *floater = floating->children->items[i];
417 has_sticky = true; 417 if (floater->is_sticky) {
418 container_remove_child(floater); 418 has_sticky = true;
419 container_add_child(workspace->sway_workspace->floating, floater); 419 container_remove_child(floater);
420 if (floater == focus) { 420 container_add_child(workspace->sway_workspace->floating,
421 seat_set_focus(seat, NULL); 421 floater);
422 seat_set_focus(seat, floater); 422 if (floater == focus) {
423 seat_set_focus(seat, NULL);
424 seat_set_focus(seat, floater);
425 }
426 --i;
423 } 427 }
424 --i;
425 } 428 }
426 } 429 }
427 430