From 9831175a2d9228efd75cb08849b8954b61feda39 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 13 Jul 2025 06:16:28 +0000 Subject: [PATCH 1/2] Use window index not ID for sorting, reported by naru at naruaway dot com in GitHub issue 4551. --- format.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/format.c b/format.c index 5f91e0ce..2c37938f 100644 --- a/format.c +++ b/format.c @@ -4486,7 +4486,6 @@ format_cmp_window(const void *a0, const void *b0) switch (sc->field) { case FORMAT_LOOP_BY_INDEX: - result = wa->id - wb->id; break; case FORMAT_LOOP_BY_TIME: if (timercmp(&wa->activity_time, &wb->activity_time, >)) { @@ -4512,15 +4511,16 @@ format_cmp_window(const void *a0, const void *b0) static char * format_loop_windows(struct format_expand_state *es, const char *fmt) { - struct format_tree *ft = es->ft; - struct client *c = ft->client; - struct cmdq_item *item = ft->item; - struct format_tree *nft; - struct format_expand_state next; - char *all, *active, *use, *expanded, *value; - size_t valuelen; - struct winlink *wl; - struct window *w; + struct format_loop_sort_criteria *sc = &format_loop_sort_criteria; + struct format_tree *ft = es->ft; + struct client *c = ft->client; + struct cmdq_item *item = ft->item; + struct format_tree *nft; + struct format_expand_state next; + char *all, *active, *use, *expanded, *value; + size_t valuelen; + struct winlink *wl; + struct window *w; int i, n, last = 0; static struct winlink **l = NULL; static int lsz = 0; @@ -4544,7 +4544,18 @@ format_loop_windows(struct format_expand_state *es, const char *fmt) l[n++] = wl; } - qsort(l, n, sizeof *l, format_cmp_window); + if (sc->field != FORMAT_LOOP_BY_INDEX) + qsort(l, n, sizeof *l, format_cmp_window); + else { + /* Use order in the tree as index order. */ + if (sc->reversed) { + for (i = 0; i < n / 2; i++) { + wl = l[i]; + l[i] = l[n - 1 - i]; + l[n - 1 - i] = wl; + } + } + } value = xcalloc(1, 1); valuelen = 1; @@ -4731,7 +4742,7 @@ format_loop_clients(struct format_expand_state *es, const char *fmt) if (sc->field != FORMAT_LOOP_BY_INDEX) qsort(l, n, sizeof *l, format_cmp_client); else { - /* Use order in the TAILQ as "index" order. */ + /* Use order in the list as index order. */ if (sc->reversed) { for (i = 0; i < n / 2; i++) { c = l[i]; From e6bac234dbfbbd8709ac91f40dc9788e09daa028 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 13 Jul 2025 06:32:34 +0000 Subject: [PATCH 2/2] Increase delay for foreground and background queries as well as device attributes, GitHub issue 4541. --- tmux.h | 8 +++++--- tty-keys.c | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tmux.h b/tmux.h index f3d0252e..5ca6370d 100644 --- a/tmux.h +++ b/tmux.h @@ -1529,13 +1529,15 @@ struct tty { #define TTY_OPENED 0x20 #define TTY_OSC52QUERY 0x40 #define TTY_BLOCK 0x80 -#define TTY_HAVEDA 0x100 /* Primary DA. */ +#define TTY_HAVEDA 0x100 #define TTY_HAVEXDA 0x200 #define TTY_SYNCING 0x400 -#define TTY_HAVEDA2 0x800 /* Secondary DA. */ +#define TTY_HAVEDA2 0x800 #define TTY_WINSIZEQUERY 0x1000 +#define TTY_HAVEFG 0x2000 +#define TTY_HAVEBG 0x4000 #define TTY_ALL_REQUEST_FLAGS \ - (TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA) + (TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA|TTY_HAVEFG|TTY_HAVEBG) int flags; struct tty_term *term; diff --git a/tty-keys.c b/tty-keys.c index 0e4dad2c..e36e7b65 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -938,7 +938,7 @@ partial_key: if (delay == 0) delay = 1; if ((tty->flags & TTY_ALL_REQUEST_FLAGS) != TTY_ALL_REQUEST_FLAGS) { - log_debug("%s: increasing delay for active DA query", c->name); + log_debug("%s: increasing delay for active query", c->name); if (delay < 500) delay = 500; } @@ -1031,7 +1031,7 @@ tty_keys_extended_key(struct tty *tty, const char *buf, size_t len, cc_t bspace; key_code nkey, onlykey; struct utf8_data ud; - utf8_char uc; + utf8_char uc; *size = 0; @@ -1682,12 +1682,14 @@ tty_keys_colours(struct tty *tty, const char *buf, size_t len, size_t *size, else log_debug("fg is %s", colour_tostring(n)); *fg = n; + tty->flags |= TTY_HAVEFG; } else if (n != -1) { if (c != NULL) log_debug("%s bg is %s", c->name, colour_tostring(n)); else log_debug("bg is %s", colour_tostring(n)); *bg = n; + tty->flags |= TTY_HAVEBG; } return (0);