summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnaƫl Beutot <abeutot@oserror.org>2020-12-29 21:45:39 +0100
committerMichael Stapelberg <michael@stapelberg.de>2021-02-01 08:53:36 +0100
commit0c09bc24ffad9a662537c5cd94550ef0e14b36bd (patch)
tree5e8161bcdee5f85f5e585f7cfab17a4599586011
parente6af0a5427296947522a42b30b8a042fd0b68b33 (diff)
downloadi3-0c09bc24ffad9a662537c5cd94550ef0e14b36bd.tar.gz
i3-0c09bc24ffad9a662537c5cd94550ef0e14b36bd.zip
Fix workspace assignements after output changes
Fix #4261 The previous method was modifying the same list it was iterating upon causing an erronous iteration and thus not every workspace got assigned back to were they should (only the first one).
-rw-r--r--src/randr.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/randr.c b/src/randr.c
index 8e000ca6..b4d1d094 100644
--- a/src/randr.c
+++ b/src/randr.c
@@ -439,28 +439,31 @@ void init_ws_for_output(Output *output) {
Con *previous_focus = con_get_workspace(focused);
/* Iterate over all workspaces and check if any of them should be assigned
- * to this output. */
- Con *output_con;
- TAILQ_FOREACH (output_con, &(croot->nodes_head), nodes) {
- if (con_is_internal(output_con)) {
+ * to this output.
+ * Note: in order to do that we iterate over all_cons and not using another
+ * list that would be updated during iteration by the
+ * workspace_move_to_output function. */
+ Con *workspace;
+ TAILQ_FOREACH (workspace, &all_cons, all_cons) {
+ if (workspace->type != CT_WORKSPACE || con_is_internal(workspace)) {
continue;
}
- Con *workspace;
- TAILQ_FOREACH (workspace, &(output_get_content(output_con)->nodes_head), nodes) {
- Con *workspace_out = get_assigned_output(workspace->name, workspace->num);
- if (output->con != workspace_out) {
- continue;
- }
+ Con *workspace_out = get_assigned_output(workspace->name, workspace->num);
- DLOG("Moving workspace \"%s\" from output \"%s\" to \"%s\" due to assignment\n",
- workspace->name, workspace_out->name, output_primary_name(output));
- /* Need to copy output's rect since content is not yet rendered. We
- * can't call render_con here because render_output only proceeds
- * if a workspace exists. */
- content->rect = output->con->rect;
- workspace_move_to_output(workspace, output);
+ if (output->con != workspace_out) {
+ continue;
}
+
+ DLOG("Moving workspace \"%s\" from output \"%s\" to \"%s\" due to assignment\n",
+ workspace->name, output_primary_name(get_output_for_con(workspace)),
+ output_primary_name(output));
+
+ /* Need to copy output's rect since content is not yet rendered. We
+ * can't call render_con here because render_output only proceeds
+ * if a workspace exists. */
+ content->rect = output->con->rect;
+ workspace_move_to_output(workspace, output);
}
/* Temporarily set the focused container, might not be initialized yet. */