]> git.sur5r.net Git - i3/i3/blobdiff - src/output.c
Merge pull request #1962 from Airblader/bug-move-to-output-criteria
[i3/i3] / src / output.c
index ec5d5f4791643af05a96df7238a819f72a3dc571..62b146a74150fa65e094e09a6b4e4570552700b1 100644 (file)
@@ -46,3 +46,41 @@ Output *get_output_from_string(Output *current_output, const char *output_str) {
 
     return output;
 }
+
+/*
+ * Iterates over all outputs and pushes sticky windows to the currently visible
+ * workspace on that output.
+ *
+ */
+void output_push_sticky_windows(Con *to_focus) {
+    Con *output;
+    TAILQ_FOREACH(output, &(croot->focus_head), focused) {
+        Con *workspace, *visible_ws = NULL;
+        GREP_FIRST(visible_ws, output_get_content(output), workspace_is_visible(child));
+
+        /* We use this loop instead of TAILQ_FOREACH to avoid problems if the
+         * sticky window was the last window on that workspace as moving it in
+         * this case will close the workspace. */
+        for (workspace = TAILQ_FIRST(&(output_get_content(output)->focus_head));
+             workspace != TAILQ_END(&(output_get_content(output)->focus_head));) {
+            Con *current_ws = workspace;
+            workspace = TAILQ_NEXT(workspace, focused);
+
+            /* Since moving the windows actually removes them from the list of
+             * floating windows on this workspace, here too we need to use
+             * another loop than TAILQ_FOREACH. */
+            Con *child;
+            for (child = TAILQ_FIRST(&(current_ws->focus_head));
+                 child != TAILQ_END(&(current_ws->focus_head));) {
+                Con *current = child;
+                child = TAILQ_NEXT(child, focused);
+                if (current->type != CT_FLOATING_CON)
+                    continue;
+
+                if (con_is_sticky(current)) {
+                    con_move_to_workspace(current, visible_ws, true, false, current != to_focus->parent);
+                }
+            }
+        }
+    }
+}