summaryrefslogtreecommitdiff
path: root/sway/tree/output.c
diff options
context:
space:
mode:
authorBrian Ashworth <[email protected]>2018-06-08 13:06:29 -0400
committerBrian Ashworth <[email protected]>2018-06-08 13:08:00 -0400
commite2b2fb0a0e3e7db3046aeef485621ff3f490cd61 (patch)
tree1ef7bdd44c5b7684e2c5e7118d5b7ffdda1e4ba6 /sway/tree/output.c
parent5c9a917df9453f0463040b1164ba639b430f7833 (diff)
Switch restore workspaces to a nested for-loop
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r--sway/tree/output.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 1ab8bed2..ed7e941e 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -8,26 +8,30 @@
#include "sway/tree/workspace.h"
#include "log.h"
-static void restore_workspace(struct sway_container *ws, void *output) {
- if (ws->parent == output) {
- return;
- }
-
- struct sway_container *highest = workspace_output_get_highest_available(
- ws, NULL);
- if (!highest) {
- return;
- }
+static void restore_workspaces(struct sway_container *output) {
+ for (int i = 0; i < root_container.children->length; i++) {
+ struct sway_container *other = root_container.children->items[i];
+ if (other == output) {
+ continue;
+ }
- if (highest == output) {
- struct sway_container *other = container_remove_child(ws);
- container_add_child(output, ws);
- ipc_event_workspace(ws, NULL, "move");
+ for (int j = 0; j < other->children->length; j++) {
+ struct sway_container *ws = other->children->items[j];
+ struct sway_container *highest =
+ workspace_output_get_highest_available(ws, NULL);
+ if (highest == output) {
+ container_remove_child(ws);
+ container_add_child(output, ws);
+ ipc_event_workspace(ws, NULL, "move");
+ j--;
+ }
+ }
- container_sort_workspaces(output);
- arrange_output(output);
arrange_output(other);
}
+
+ container_sort_workspaces(output);
+ arrange_output(output);
}
struct sway_container *output_create(
@@ -80,8 +84,7 @@ struct sway_container *output_create(
output->width = size.width;
output->height = size.height;
- container_descendants(&root_container, C_WORKSPACE, restore_workspace,
- output);
+ restore_workspaces(output);
if (!output->children->length) {
// Create workspace