aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsgowman <richard.gowman@gmail.com>2024-02-06 14:28:20 -0500
committerGitHub <noreply@github.com>2024-02-06 20:28:20 +0100
commit6a530de22049d7ce8575d1fdd393654260a25234 (patch)
tree6e1184fad02a2cc3149abd3e5f2eba57f89ee867
parent063916718505162b5ebe22268e413787cba32642 (diff)
downloadi3-6a530de22049d7ce8575d1fdd393654260a25234.tar.gz
i3-6a530de22049d7ce8575d1fdd393654260a25234.zip
Create new workspaces to the right of existing ones with the same number
i.e. creating workspaces named "1", "2:a", "2:b", "3" should result in that same order rather than "1", "2:b", "2:a", "3".
-rw-r--r--release-notes/bugfixes/3-numbered-workspace-order1
-rw-r--r--src/con.c4
-rw-r--r--testcases/t/503-workspace.t14
-rw-r--r--testcases/t/528-workspace-next-prev-reversed.t15
-rw-r--r--testcases/t/535-workspace-next-prev.t15
5 files changed, 16 insertions, 33 deletions
diff --git a/release-notes/bugfixes/3-numbered-workspace-order b/release-notes/bugfixes/3-numbered-workspace-order
new file mode 100644
index 00000000..399f202d
--- /dev/null
+++ b/release-notes/bugfixes/3-numbered-workspace-order
@@ -0,0 +1 @@
+make order of numbered workspace consistent with non-numbered
diff --git a/src/con.c b/src/con.c
index 917e797a..abcc4fba 100644
--- a/src/con.c
+++ b/src/con.c
@@ -116,14 +116,14 @@ static void _con_attach(Con *con, Con *parent, Con *previous, bool ignore_focus)
/* we need to insert the container at the beginning */
TAILQ_INSERT_HEAD(nodes_head, con, nodes);
} else {
- while (current->num != -1 && con->num > current->num) {
+ while (current->num != -1 && con->num >= current->num) {
current = TAILQ_NEXT(current, nodes);
if (current == TAILQ_END(nodes_head)) {
current = NULL;
break;
}
}
- /* we need to insert con after current, if current is not NULL */
+ /* we need to insert con before current, if current is not NULL */
if (current) {
TAILQ_INSERT_BEFORE(current, con, nodes);
} else {
diff --git a/testcases/t/503-workspace.t b/testcases/t/503-workspace.t
index 8a4aab9f..983c25a2 100644
--- a/testcases/t/503-workspace.t
+++ b/testcases/t/503-workspace.t
@@ -54,16 +54,12 @@ cmd 'workspace 5';
# ensure workspace 5 stays open
open_window;
-# numbered w/ name workspaces must be created in reverse order compared to
-# other workspace types (because a new numbered w/ name workspace is prepended
-# to the list of similarly numbered workspaces).
-
-cmd 'workspace 6:b';
-# ensure workspace 5 stays open
+cmd 'workspace 6:a';
+# ensure workspace 6:a stays open
open_window;
-cmd 'workspace 6:a';
-# ensure workspace 5 stays open
+cmd 'workspace 6:b';
+# ensure workspace 6:b stays open
open_window;
################################################################################
@@ -101,7 +97,7 @@ cmd 'workspace next';
# later in time and mess up our subsequent tests.
sync_with_i3;
-is(focused_ws, '6:b', 'workspace 6:b focused');
+is(focused_ws, '6:b', 'workspace 6:a focused');
cmd 'workspace next';
# We need to sync after changing focus to a different output to wait for the
# EnterNotify to be processed, otherwise it will be processed at some point
diff --git a/testcases/t/528-workspace-next-prev-reversed.t b/testcases/t/528-workspace-next-prev-reversed.t
index f5e11466..bf592bf3 100644
--- a/testcases/t/528-workspace-next-prev-reversed.t
+++ b/testcases/t/528-workspace-next-prev-reversed.t
@@ -68,11 +68,8 @@ cmd 'workspace D'; open_window;
cmd 'workspace 4'; open_window;
cmd 'workspace 5'; open_window;
cmd 'workspace E'; open_window;
-# numbered w/ name workspaces must be created in reverse order compared to
-# other workspace types (because a new numbered w/ name workspace is prepended
-# to the list of similarly numbered workspaces).
-cmd 'workspace 8:e'; open_window;
cmd 'workspace 8:d'; open_window;
+cmd 'workspace 8:e'; open_window;
cmd 'focus output right';
cmd 'workspace 1'; open_window;
@@ -83,19 +80,15 @@ cmd 'workspace F'; open_window;
cmd 'workspace 6'; open_window;
cmd 'workspace C'; open_window;
cmd 'workspace 7'; open_window;
-# numbered w/ name workspaces must be created in reverse order compared to
-# other workspace types (because a new numbered w/ name workspace is prepended
-# to the list of similarly numbered workspaces).
-cmd 'workspace 8:c'; open_window;
-cmd 'workspace 8:b'; open_window;
cmd 'workspace 8:a'; open_window;
+cmd 'workspace 8:b'; open_window;
+cmd 'workspace 8:c'; open_window;
################################################################################
# Use workspace next and verify the correct order.
# numbered -> numerical sort
# numbered w/ names -> numerical sort. Workspaces with the same number but
-# different names sort by output, followed by reverse creation time on each
-# output.
+# different names sort by output, followed by creation time on each output.
# named -> sort by creation time
################################################################################
cmd 'workspace 1';
diff --git a/testcases/t/535-workspace-next-prev.t b/testcases/t/535-workspace-next-prev.t
index 8510370c..e7c48508 100644
--- a/testcases/t/535-workspace-next-prev.t
+++ b/testcases/t/535-workspace-next-prev.t
@@ -68,11 +68,8 @@ cmd 'workspace D'; open_window;
cmd 'workspace 4'; open_window;
cmd 'workspace 5'; open_window;
cmd 'workspace E'; open_window;
-# numbered w/ name workspaces must be created in reverse order compared to
-# other workspace types (because a new numbered w/ name workspace is prepended
-# to the list of similarly numbered workspaces).
-cmd 'workspace 8:e'; open_window;
cmd 'workspace 8:d'; open_window;
+cmd 'workspace 8:e'; open_window;
cmd 'focus output left';
cmd 'workspace 1'; open_window;
@@ -83,19 +80,15 @@ cmd 'workspace F'; open_window;
cmd 'workspace 6'; open_window;
cmd 'workspace C'; open_window;
cmd 'workspace 7'; open_window;
-# numbered w/ name workspaces must be created in reverse order compared to
-# other workspace types (because a new numbered w/ name workspace is prepended
-# to the list of similarly numbered workspaces).
-cmd 'workspace 8:c'; open_window;
-cmd 'workspace 8:b'; open_window;
cmd 'workspace 8:a'; open_window;
+cmd 'workspace 8:b'; open_window;
+cmd 'workspace 8:c'; open_window;
################################################################################
# Use workspace next and verify the correct order.
# numbered -> numerical sort
# numbered w/ names -> numerical sort. Workspaces with the same number but
-# different names sort by output, followed by reverse creation time on each
-# output.
+# different names sort by output, followed by creation time on each output.
# named -> sort by creation time
################################################################################
cmd 'workspace 1';