From 9b37b9285e822e83cc1a003000ab24fb4eaa57f1 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 2 Apr 2025 09:12:05 +0000 Subject: [PATCH 1/2] Popup window should not be draggable while mouse still pressed, and do not try to work out theme if no pane. From Michael Grant in GitHub issue 4330. --- popup.c | 2 +- window.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/popup.c b/popup.c index ebe1fc98..be981a39 100644 --- a/popup.c +++ b/popup.c @@ -531,7 +531,7 @@ popup_key_cb(struct client *c, void *data, struct key_event *event) (border == LEFT || border == TOP)) goto menu; if (((m->b & MOUSE_MASK_MODIFIERS) == MOUSE_MASK_META) || - border != NONE) { + (border != NONE && !MOUSE_DRAG(m->lb))) { if (!MOUSE_DRAG(m->b)) goto out; if (MOUSE_BUTTONS(m->lb) == MOUSE_BUTTON_1) diff --git a/window.c b/window.c index b1691ac6..2429d7b7 100644 --- a/window.c +++ b/window.c @@ -1877,11 +1877,15 @@ window_pane_get_fg_control_client(struct window_pane *wp) enum client_theme window_pane_get_theme(struct window_pane *wp) { - struct window *w = wp->window; + struct window *w; struct client *loop; enum client_theme theme; int found_light = 0, found_dark = 0; + if (wp == NULL) + return (THEME_UNKNOWN); + w = wp->window; + /* * Derive theme from pane background color, if it's not the default * colour. From 4bf38da4d4c73388aa5c5c24f1542d62713efeba Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 2 Apr 2025 09:31:00 +0000 Subject: [PATCH 2/2] Only align panes and windows, not sessions, from David Mandelberg in GitHub issue 4444. --- mode-tree.c | 22 +++++++++++++++++----- tmux.h | 1 + window-tree.c | 6 +++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/mode-tree.c b/mode-tree.c index 508e870c..1d929952 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -102,6 +102,7 @@ struct mode_tree_item { int draw_as_parent; int no_tag; + int align; struct mode_tree_list children; TAILQ_ENTRY(mode_tree_item) entry; @@ -667,6 +668,16 @@ mode_tree_no_tag(struct mode_tree_item *mti) mti->no_tag = 1; } +/* + * Set the alignment of mti->name: -1 to align left, 0 (default) to not align, + * or 1 to align right. + */ +void +mode_tree_align(struct mode_tree_item *mti, int align) +{ + mti->align = align; +} + void mode_tree_remove(struct mode_tree_data *mtd, struct mode_tree_item *mti) { @@ -693,7 +704,7 @@ mode_tree_draw(struct mode_tree_data *mtd) char *text, *start, *key; const char *tag, *symbol; size_t size, n; - int keylen, pad, namelen[mtd->maxdepth + 1]; + int keylen, pad, alignlen[mtd->maxdepth + 1]; if (mtd->line_size == 0) return; @@ -718,12 +729,13 @@ mode_tree_draw(struct mode_tree_data *mtd) } for (i = 0; i < mtd->maxdepth + 1; i++) - namelen[i] = 0; + alignlen[i] = 0; for (i = 0; i < mtd->line_size; i++) { line = &mtd->line_list[i]; mti = line->item; - if ((int)strlen(mti->name) > namelen[line->depth]) - namelen[line->depth] = strlen(mti->name); + if (mti->align && + (int)strlen(mti->name) > alignlen[line->depth]) + alignlen[line->depth] = strlen(mti->name); } for (i = 0; i < mtd->line_size; i++) { @@ -776,7 +788,7 @@ mode_tree_draw(struct mode_tree_data *mtd) else tag = ""; xasprintf(&text, "%-*s%s%*s%s%s", keylen, key, start, - namelen[line->depth], mti->name, tag, + mti->align * alignlen[line->depth], mti->name, tag, (mti->text != NULL) ? ": " : "" ); width = utf8_cstrwidth(text); if (width > w) diff --git a/tmux.h b/tmux.h index 5852b2db..f6483fc9 100644 --- a/tmux.h +++ b/tmux.h @@ -3306,6 +3306,7 @@ struct mode_tree_item *mode_tree_add(struct mode_tree_data *, const char *, int); void mode_tree_draw_as_parent(struct mode_tree_item *); void mode_tree_no_tag(struct mode_tree_item *); +void mode_tree_align(struct mode_tree_item *, int); void mode_tree_remove(struct mode_tree_data *, struct mode_tree_item *); void mode_tree_draw(struct mode_tree_data *); int mode_tree_key(struct mode_tree_data *, struct client *, key_code *, diff --git a/window-tree.c b/window-tree.c index bffbeec3..a6ec43a0 100644 --- a/window-tree.c +++ b/window-tree.c @@ -300,6 +300,7 @@ window_tree_build_pane(struct session *s, struct winlink *wl, { struct window_tree_modedata *data = modedata; struct window_tree_itemdata *item; + struct mode_tree_item *mti; char *name, *text; u_int idx; struct format_tree *ft; @@ -318,9 +319,11 @@ window_tree_build_pane(struct session *s, struct winlink *wl, xasprintf(&name, "%u", idx); format_free(ft); - mode_tree_add(data->data, parent, item, (uint64_t)wp, name, text, -1); + mti = mode_tree_add(data->data, parent, item, (uint64_t)wp, name, text, + -1); free(text); free(name); + mode_tree_align(mti, 1); } static int @@ -375,6 +378,7 @@ window_tree_build_window(struct session *s, struct winlink *wl, expanded); free(text); free(name); + mode_tree_align(mti, 1); if ((wp = TAILQ_FIRST(&wl->window->panes)) == NULL) goto empty;