From 23b0c6ac5d23ac7faea0806e11129fe8f5b4c34a Mon Sep 17 00:00:00 2001 From: Pontus Andersson Date: Sun, 11 Feb 2024 17:42:00 +0100 Subject: [PATCH] output: Fallback to sorting workspaces alphabetically Currently the order of unnumbered workspaces is the order they were created. This is a bit unintuitive for workflows where workspaces are created and named dynamically. Instead of treating all unnumbered workspaces equal, fallback to sorting them alphabetically based on the name of the workspace. This will make the ordering more deterministic regardless of the order they were created. --- sway/tree/output.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sway/tree/output.c b/sway/tree/output.c index cd7bf0c279..ce5c411d4a 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c @@ -10,6 +10,7 @@ #include "sway/tree/workspace.h" #include "sway/server.h" #include "log.h" +#include "stringop.h" #include "util.h" enum wlr_direction opposite_direction(enum wlr_direction d) { @@ -404,7 +405,7 @@ static int sort_workspace_cmp_qsort(const void *_a, const void *_b) { } else if (isdigit(b->name[0])) { return 1; } - return 0; + return lenient_strcmp(a->name, b->name); } void output_sort_workspaces(struct sway_output *output) {