aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c14
-rw-r--r--sway/tree/layout.c23
-rw-r--r--sway/tree/output.c23
-rw-r--r--sway/tree/workspace.c14
4 files changed, 36 insertions, 38 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index db780270..337245fd 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -270,7 +270,7 @@ static struct sway_container *container_output_destroy(
container_destroy(workspace);
}
- container_sort_workspaces(new_output);
+ output_sort_workspaces(new_output);
}
}
}
@@ -1305,15 +1305,3 @@ bool container_is_fullscreen_or_child(struct sway_container *container) {
return false;
}
-
-struct sway_container *container_wrap_children(struct sway_container *parent) {
- struct sway_container *middle = container_create(C_CONTAINER);
- middle->layout = parent->layout;
- while (parent->children->length) {
- struct sway_container *child = parent->children->items[0];
- container_remove_child(child);
- container_add_child(middle, child);
- }
- container_add_child(parent, middle);
- return middle;
-}
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 2b710403..49ec806e 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -1,5 +1,4 @@
#define _POSIX_C_SOURCE 200809L
-#include <ctype.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -591,28 +590,6 @@ enum sway_container_layout container_get_default_layout(
}
}
-static int sort_workspace_cmp_qsort(const void *_a, const void *_b) {
- struct sway_container *a = *(void **)_a;
- struct sway_container *b = *(void **)_b;
- int retval = 0;
-
- if (isdigit(a->name[0]) && isdigit(b->name[0])) {
- int a_num = strtol(a->name, NULL, 10);
- int b_num = strtol(b->name, NULL, 10);
- retval = (a_num < b_num) ? -1 : (a_num > b_num);
- } else if (isdigit(a->name[0])) {
- retval = -1;
- } else if (isdigit(b->name[0])) {
- retval = 1;
- }
-
- return retval;
-}
-
-void container_sort_workspaces(struct sway_container *output) {
- list_stable_sort(output->children, sort_workspace_cmp_qsort);
-}
-
/**
* Get swayc in the direction of newly entered output.
*/
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 31e3bf9b..ab955359 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 200809L
+#include <ctype.h>
#include <string.h>
#include <strings.h>
#include "sway/ipc-server.h"
@@ -28,7 +29,7 @@ static void restore_workspaces(struct sway_container *output) {
}
}
- container_sort_workspaces(output);
+ output_sort_workspaces(output);
}
struct sway_container *output_create(
@@ -102,3 +103,23 @@ struct sway_container *output_create(
return output;
}
+static int sort_workspace_cmp_qsort(const void *_a, const void *_b) {
+ struct sway_container *a = *(void **)_a;
+ struct sway_container *b = *(void **)_b;
+
+ if (isdigit(a->name[0]) && isdigit(b->name[0])) {
+ int a_num = strtol(a->name, NULL, 10);
+ int b_num = strtol(b->name, NULL, 10);
+ return (a_num < b_num) ? -1 : (a_num > b_num);
+ } else if (isdigit(a->name[0])) {
+ return -1;
+ } else if (isdigit(b->name[0])) {
+ return 1;
+ }
+ return 0;
+}
+
+void output_sort_workspaces(struct sway_container *output) {
+ list_stable_sort(output->children, sort_workspace_cmp_qsort);
+}
+
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index e7383de0..1c0e6515 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -75,7 +75,7 @@ struct sway_container *workspace_create(struct sway_container *output,
workspace_output_add_priority(workspace, output);
container_add_child(output, workspace);
- container_sort_workspaces(output);
+ output_sort_workspaces(output);
container_create_notify(workspace);
return workspace;
@@ -537,3 +537,15 @@ void workspace_detect_urgent(struct sway_container *workspace) {
container_damage_whole(workspace);
}
}
+
+struct sway_container *workspace_wrap_children(struct sway_container *ws) {
+ struct sway_container *middle = container_create(C_CONTAINER);
+ middle->layout = ws->layout;
+ while (ws->children->length) {
+ struct sway_container *child = ws->children->items[0];
+ container_remove_child(child);
+ container_add_child(middle, child);
+ }
+ container_add_child(ws, middle);
+ return middle;
+}