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".
This commit is contained in:
rsgowman 2024-02-06 14:28:20 -05:00 committed by GitHub
parent 0639167185
commit 6a530de220
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 33 deletions

View File

@ -0,0 +1 @@
make order of numbered workspace consistent with non-numbered

View File

@ -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 {

View File

@ -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

View File

@ -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';

View File

@ -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';