From 476c6e89adf3c1242fb7b3e1e3caba755bf45562 Mon Sep 17 00:00:00 2001 From: Michael Grant Date: Wed, 11 Feb 2026 09:30:48 +0000 Subject: [PATCH] Check the overlay visible ranges when we have a tty and check the panes visible ranges when we have a wp. Overlays checked at tty level (for most part) and pane overlays checked at screen level where possible to keep separation of abstraction relatively clean. --- screen-redraw.c | 8 ++++---- tty-draw.c | 2 +- tty.c | 9 +-------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/screen-redraw.c b/screen-redraw.c index 5350e64a..d130cc83 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -1239,10 +1239,11 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px, then split range into 2 ranges. */ else if (lb > ri->px && rb < ri->px + ri->nx) { - server_client_ensure_ranges(r, r->size + 1); + server_client_ensure_ranges(r, r->used + 1); for (s=r->used; s>i; s--) - memcpy(&r->ranges[s-1], &r->ranges[s], + memcpy(&r->ranges[s], &r->ranges[s-1], sizeof (struct visible_range)); + ri = &r->ranges[i]; r->ranges[i+1].px = rb + 1; r->ranges[i+1].nx = ri->px + ri->nx - (rb + 1); /* ri->px was copied, unchanged. */ @@ -1338,8 +1339,7 @@ screen_redraw_draw_pane(struct screen_redraw_ctx *ctx, struct window_pane *wp) __func__, c->name, wp->id, i, j, wx, wy, width); /* Get visible ranges of line before we draw it. */ - r = tty_check_overlay_range(tty, px, py, width); - r = screen_redraw_get_visible_ranges(wp, wx, wy, width, r); + r = screen_redraw_get_visible_ranges(wp, wx, wy, width, NULL); tty_default_colours(&defaults, wp); diff --git a/tty-draw.c b/tty-draw.c index eac92a8f..e10e2f19 100644 --- a/tty-draw.c +++ b/tty-draw.c @@ -122,7 +122,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx, char buf[1000]; size_t len; enum tty_draw_line_state current_state, next_state; - +/* xxx maybe check overlay here? */ /* * py is the line in the screen to draw. px is the start x and nx is * the width to draw. atx,aty is the line on the terminal to draw it. diff --git a/tty.c b/tty.c index a8044a56..878575c4 100644 --- a/tty.c +++ b/tty.c @@ -1209,7 +1209,6 @@ tty_clear_pane_line(struct tty *tty, const struct tty_ctx *ctx, u_int py, u_int px, u_int nx, u_int bg) { struct client *c = tty->client; - struct window_pane *wp = ctx->arg; struct visible_ranges *r; struct visible_range *ri; u_int i, l, x, rx, ry; @@ -1218,7 +1217,6 @@ tty_clear_pane_line(struct tty *tty, const struct tty_ctx *ctx, u_int py, if (tty_clamp_line(tty, ctx, px, py, nx, &l, &x, &rx, &ry)) { r = tty_check_overlay_range(tty, x, ry, rx); - r = screen_redraw_get_visible_ranges(wp, x, ry, rx, r); for (i=0; i < r->used; i++) { ri = &r->ranges[i]; if (ri->nx == 0) @@ -1382,7 +1380,6 @@ tty_clear_area(struct tty *tty, const struct tty_ctx *ctx, u_int py, /* Couldn't use an escape sequence, loop over the lines. */ for (yy = py; yy < py + ny; yy++) { r = tty_check_overlay_range(tty, px, yy - oy, nx); - r = screen_redraw_get_visible_ranges(wp, px, yy - oy, nx, r); for (i=0; i < r->used; i++) { ri = &r->ranges[i]; if (ri->nx == 0) continue; @@ -1419,8 +1416,6 @@ tty_draw_pane(struct tty *tty, const struct tty_ctx *ctx, u_int py) if (!ctx->bigger) { if (wp) { r = tty_check_overlay_range(tty, 0, ctx->yoff + py, nx); - r = screen_redraw_get_visible_ranges(wp, 0, ctx->yoff + - py, nx, r); for (i=0; i < r->used; i++) { ri = &r->ranges[i]; if (ri->nx == 0) continue; @@ -1437,7 +1432,6 @@ tty_draw_pane(struct tty *tty, const struct tty_ctx *ctx, u_int py) if (tty_clamp_line(tty, ctx, 0, py, nx, &px, &x, &rx, &ry)) { if (wp) { r = tty_check_overlay_range(tty, i, py, rx); - r = screen_redraw_get_visible_ranges(wp, i, py, rx, r); for (i=0; i < r->used; i++) { ri = &r->ranges[i]; if (ri->nx == 0) @@ -1916,8 +1910,7 @@ tty_cmd_scrollup(struct tty *tty, const struct tty_ctx *ctx) !tty_term_has(tty->term, TTYC_CSR) || ctx->sx == 1 || ctx->sy == 1 || - c->overlay_check != NULL || - tty_is_obscured(ctx)) { + c->overlay_check != NULL) { tty_redraw_region(tty, ctx); return; }