From 5c3a4746b7814c2d07b1642bb00858a66a13925a Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 23 May 2026 07:22:50 +0000 Subject: [PATCH 1/4] Some code tidying up. --- layout-custom.c | 2 +- layout.c | 2 +- screen-redraw.c | 83 ++++++++++++++++++++++--------------------------- 3 files changed, 39 insertions(+), 48 deletions(-) diff --git a/layout-custom.c b/layout-custom.c index deced6d8..6c4881ce 100644 --- a/layout-custom.c +++ b/layout-custom.c @@ -288,7 +288,7 @@ layout_parse(struct window *w, const char *layout, char **cause) if (floating_lc != NULL) layout_assign(&wp, floating_lc, PANE_FLOATING); - /* Fix pane Z indexes. */ + /* Fix pane z-indexes. */ while (!TAILQ_EMPTY(&w->z_index)) { wp = TAILQ_FIRST(&w->z_index); TAILQ_REMOVE(&w->z_index, wp, zentry); diff --git a/layout.c b/layout.c index 7c687e51..5ecad949 100644 --- a/layout.c +++ b/layout.c @@ -233,7 +233,7 @@ layout_make_node(struct layout_cell *lc, enum layout_type type) lc->wp = NULL; } -/* Fix Z indexes. */ +/* Fix z-indexes. */ void layout_fix_zindexes(struct window *w, struct layout_cell *lc) { diff --git a/screen-redraw.c b/screen-redraw.c index d6a90a99..996c7ff0 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -711,10 +711,8 @@ screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx) } r = screen_redraw_get_visible_ranges(wp, x, yoff, width, NULL); - if (ctx->statustop) yoff += ctx->statuslines; - for (i = 0; i < r->used; i++) { ri = &r->ranges[i]; if (ri->nx == 0) @@ -1265,7 +1263,6 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px, return (r); } - /* Draw one pane. */ static void screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) @@ -1289,25 +1286,20 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) wp->xoff >= (int)ctx->ox + (int)ctx->sx) return; - /* woy is window y offset in tty. */ if (ctx->statustop) woy = ctx->statuslines; else woy = 0; - for (j = 0; j < wp->sy; j++) { if (wp->yoff + (int)j < (int)ctx->oy || wp->yoff + (int)j >= (int)ctx->oy + (int)ctx->sy) continue; - wy = wp->yoff + j; /* y line within window w. */ - py = woy + wy - ctx->oy; /* y line within tty. */ - if (py > tty->sy) + wy = wp->yoff + j; /* y line within window w */ + py = woy + wy - ctx->oy; /* y line within tty */ + if (py > tty->sy) { /* Continue if this line is off of tty. */ continue; - - /* Note: i is apparenty not used now that the vr array - * returns where in s to read from. - */ + } if (wp->xoff >= (int)ctx->ox && wp->xoff + (int)wp->sx <= (int)ctx->ox + (int)ctx->sx) { /* All visible. */ @@ -1336,22 +1328,15 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) /* Get visible ranges of line before we draw it. */ r = screen_redraw_get_visible_ranges(wp, wx, wy, width, NULL); - tty_default_colours(&defaults, wp); - - for (i=0; i < r->used; i++) { + for (i = 0; i < r->used; i++) { ri = &r->ranges[i]; if (ri->nx == 0) continue; - px = ri->px; - tty_draw_line(tty, s, ri->px - wp->xoff, j, - ri->nx, px, py, &defaults, palette); + tty_draw_line(tty, s, ri->px - wp->xoff, j, ri->nx, + ri->px, py, &defaults, palette); } } - -#ifdef ENABLE_SIXEL - tty_draw_images(c, wp, s); -#endif } /* Draw the panes scrollbars */ @@ -1440,8 +1425,8 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx, struct visible_ranges *r; /* - * Size and offset of window relative to tty. - * Status at top offsets window downward. + * Size and offset of window relative to tty. Status at top offsets + * window downward. */ sx = ctx->sx; sy = tty->sy - ctx->statuslines; @@ -1449,8 +1434,8 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx, oy = ctx->oy; if (ctx->statustop) { sb_y += ctx->statuslines; - sy += ctx->statuslines; /* Height of window in tty. */ - oy += ctx->statuslines; /* Top of window in tty. */ + sy += ctx->statuslines; /* height of window */ + oy += ctx->statuslines; /* top of window */ } gc = sb_style->gc; @@ -1458,17 +1443,20 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx, slgc.fg = gc.bg; slgc.bg = gc.fg; - if (sb_x + (int)sb_w < 0 || sb_x >= sx || sb_y >= sy) - /* Whole sb off screen. */ + if (sb_x + (int)sb_w < 0 || sb_x >= sx || sb_y >= sy) { + /* Whole scrollbar is off screen. */ return; - if (sb_x < 0) - /* Part of sb on screen. */ + } + if (sb_x < 0) { + /* Part of scrollbar on screen. */ imin = - sb_x; + } imax = sb_w + sb_pad; if ((int)imax + sb_x > sx) { - if (sb_x > sx) - /* Whole sb off screen. */ + if (sb_x > sx) { + /* Whole scrollbar off screen. */ return; + } imax = sx - sb_x; } jmax = sb_h; @@ -1482,41 +1470,44 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx, * sb_y is a window coordinate; convert to tty coordinate by * subtracting the pan offset oy. */ - sb_tty_y = sb_y - oy; /* scrollbar top in tty coordinates */ - - if (sb_tty_y > (int)sy) - /* Whole sb off screen. */ + sb_tty_y = sb_y - oy; /* scrollbar top in tty coordinates */ + if (sb_tty_y > (int)sy) { + /* Whole scrollbar is off screen. */ return; - if (sb_tty_y < 0) + } + if (sb_tty_y < 0) { /* Scrollbar starts above visible area; skip those rows. */ jmin = -sb_tty_y; - if (sb_tty_y + (int)sb_h <= 0) - /* Whole sb above visible area. */ + } + if (sb_tty_y + (int)sb_h <= 0) { + /* Whole scrollbar above visible area. */ return; + } jmax = sb_h; - if (sb_tty_y + (int)jmax > (int)sy) + if (sb_tty_y + (int)jmax > (int)sy) { /* Clip to height of tty. */ jmax = sy - sb_tty_y; + } for (j = jmin; j < jmax; j++) { - wy = sb_y + j; /* window y coordinate. */ - py = sb_tty_y + j; /* tty y coordinate. */ + wy = sb_y + j; /* window y coordinate */ + py = sb_tty_y + j;/* tty y coordinate */ r = tty_check_overlay_range(tty, sb_x, wy, imax); r = screen_redraw_get_visible_ranges(wp, sb_x, wy, imax, r); for (i = imin; i < imax; i++) { - px = sb_x + ox + i; /* tty x coordinate. */ - wx = sb_x + i; /* window x coordinate. */ + px = sb_x + ox + i; /* tty x coordinate */ + wx = sb_x + i; /* window x coordinate */ if (wx < xoff - (int)sb_w - (int)sb_pad || px >= sx || px < 0 || wy < yoff - 1 || py >= sy || py < 0 || - ! screen_redraw_is_visible(r, wx)) + !screen_redraw_is_visible(r, wx)) continue; tty_cursor(tty, px, py); if ((sb_pos == PANE_SCROLLBARS_LEFT && i >= sb_w && i < sb_w + sb_pad) || (sb_pos == PANE_SCROLLBARS_RIGHT && - i < sb_pad)) { + i < sb_pad)) { tty_cell(tty, &grid_default_cell, &grid_default_cell, NULL, NULL); } else { From 3cfc96d4de8c616035106b8d1d1fe749afca24db Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 23 May 2026 16:43:04 +0000 Subject: [PATCH 2/4] Add missing argument to %unlinked-window-renamed, reported by Andrew Grangaard. --- tmux.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmux.1 b/tmux.1 index 56bf6386..bd235a70 100644 --- a/tmux.1 +++ b/tmux.1 @@ -8209,7 +8209,7 @@ was created but is not linked to the current session. The window with ID .Ar window\-id , which is not linked to the current session, was closed. -.It Ic %unlinked\-window\-renamed Ar window\-id +.It Ic %unlinked\-window\-renamed Ar window\-id Ar new\-name The window with ID .Ar window\-id , which is not linked to the current session, was renamed. From f047b3f8e70f42128501bf20c2bcfc1b3284d792 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 24 May 2026 08:40:43 +0000 Subject: [PATCH 3/4] Do not crash when freeing layout cell, reported by Jere Viikari. --- layout-custom.c | 3 +-- layout.c | 3 +++ screen-redraw.c | 2 +- window.c | 6 ++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/layout-custom.c b/layout-custom.c index 6c4881ce..b2871f0d 100644 --- a/layout-custom.c +++ b/layout-custom.c @@ -304,8 +304,7 @@ layout_parse(struct window *w, const char *layout, char **cause) layout_print_cell(tiled_lc, __func__, 0); /* Free the floating layout cell, no longer needed. */ - if (floating_lc != NULL) - layout_free_cell(floating_lc); + layout_free_cell(floating_lc); notify_window("window-layout-changed", w); diff --git a/layout.c b/layout.c index 5ecad949..8ee80261 100644 --- a/layout.c +++ b/layout.c @@ -78,6 +78,9 @@ layout_free_cell(struct layout_cell *lc) { struct layout_cell *lcchild; + if (lc == NULL) + return; + switch (lc->type) { case LAYOUT_LEFTRIGHT: case LAYOUT_TOPBOTTOM: diff --git a/screen-redraw.c b/screen-redraw.c index 996c7ff0..020466c6 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1273,7 +1273,7 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) struct screen *s = wp->screen; struct colour_palette *palette = &wp->palette; struct grid_cell defaults; - u_int i, j, woy, wx, wy, px, py, width; + u_int i, j, woy, wx, wy, py, width; struct visible_ranges *r; struct visible_range *ri; diff --git a/window.c b/window.c index e6e6eba7..1d9e84f9 100644 --- a/window.c +++ b/window.c @@ -349,10 +349,8 @@ window_destroy(struct window *w) window_unzoom(w, 0); RB_REMOVE(windows, &windows, w); - if (w->layout_root != NULL) - layout_free_cell(w->layout_root); - if (w->saved_layout_root != NULL) - layout_free_cell(w->saved_layout_root); + layout_free_cell(w->layout_root); + layout_free_cell(w->saved_layout_root); free(w->old_layout); window_destroy_panes(w); From eb330a6df64b80205e3c6c96adf6fbbdea1e768f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 24 May 2026 10:05:41 +0100 Subject: [PATCH 4/4] Restore SIXEL bit. --- screen-redraw.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/screen-redraw.c b/screen-redraw.c index 020466c6..dc96c517 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1337,6 +1337,10 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) ri->px, py, &defaults, palette); } } + +#ifdef ENABLE_SIXEL + tty_draw_images(c, wp, s); +#endif } /* Draw the panes scrollbars */