Fix some int/u_int bugs and added some logging.

This commit is contained in:
Michael Grant
2026-03-17 17:05:57 +00:00
parent 6c9e2f7e6c
commit c42a939e98
3 changed files with 23 additions and 8 deletions

View File

@@ -461,16 +461,16 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, u_int px, u_int py,
wp->scrollbar_style.pad;
if (sb_pos == PANE_SCROLLBARS_LEFT) {
if (~wp->flags & PANE_MINIMISED &&
((int)px >= wp->xoff - 1 - sb_w &&
((int)px >= (int)wp->xoff - 1 - sb_w &&
(int)px <= wp->xoff + (int)wp->sx) &&
((int)py >= wp->yoff - 1 &&
((int)py >= (int)wp->yoff - 1 &&
(int)py <= wp->yoff + (int)wp->sy))
break;
} else { /* PANE_SCROLLBARS_RIGHT or none. */
if (~wp->flags & PANE_MINIMISED &&
((int)px >= wp->xoff - 1 &&
((int)px >= (int)wp->xoff - 1 &&
(int)px <= wp->xoff + (int)wp->sx + sb_w) &&
((int)py >= wp->yoff - 1 &&
((int)py >= (int)wp->yoff - 1 &&
(int)py <= wp->yoff + (int)wp->sy))
break;
}
@@ -1178,7 +1178,7 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px,
continue;
}
tb = wp->yoff - 1;
tb = (wp->yoff > 0) ? wp->yoff - 1 : 0;
bb = wp->yoff + wp->sy;
if (!found_self ||
!window_pane_visible(wp) ||

View File

@@ -1991,9 +1991,14 @@ screen_write_pane_obscured(struct window_pane *base_wp)
((wp->xoff >= base_wp->xoff &&
wp->xoff <= base_wp->xoff + (int)base_wp->sx) ||
(wp->xoff + (int)wp->sx >= base_wp->xoff &&
wp->xoff + wp->sx <= base_wp->xoff + base_wp->sx)))
wp->xoff + wp->sx <= base_wp->xoff + base_wp->sx))) {
log_debug("%s: base %%%u obscured by %%%u "
"(xoff=%u sx=%u vs base xoff=%u sx=%u)", __func__,
base_wp->id, wp->id,
wp->xoff, wp->sx, base_wp->xoff, base_wp->sx);
return (1);
}
}
return (0);
}
@@ -2037,7 +2042,12 @@ screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only,
ttyctx.num = ctx->scrolled;
ttyctx.bg = ctx->bg;
ttyctx.obscured = screen_write_pane_obscured(wp);
log_debug("%s: obscured=%d for pane %%%u", __func__,
ttyctx.obscured, wp != NULL ? wp->id : 0);
tty_write(tty_cmd_scrollup, &ttyctx);
if (wp != NULL)
log_debug("%s: after scrollup, PANE_REDRAW=%d for %%%u",
__func__, !!(wp->flags & PANE_REDRAW), wp->id);
if (wp != NULL)
ctx->wp->flags |= PANE_REDRAWSCROLLBAR;

9
tty.c
View File

@@ -1095,12 +1095,17 @@ tty_redraw_region(struct tty *tty, const struct tty_ctx *ctx)
* If region is large, schedule a redraw. In most cases this is likely
* to be followed by some more scrolling.
*/
log_debug("%s: %s orlower=%u orupper=%u sy=%u large=%d", __func__,
c->name, ctx->orlower, ctx->orupper, ctx->sy,
tty_large_region(tty, ctx));
if (tty_large_region(tty, ctx)) {
log_debug("%s: %s large redraw", __func__, c->name);
ctx->redraw_cb(ctx);
return;
}
log_debug("%s: %s small redraw, drawing rows %u-%u", __func__,
c->name, ctx->orupper, ctx->orlower);
for (i = ctx->orupper; i <= ctx->orlower; i++)
tty_draw_pane(tty, ctx, i);
}
@@ -1314,9 +1319,9 @@ tty_clear_area(struct tty *tty, const struct tty_ctx *ctx, u_int py,
TAILQ_FOREACH(wpl, &w->z_index, zentry) {
if (wpl == wp || ~wpl->flags & PANE_FLOATING)
continue;
if (wpl->xoff - 1 > (int)(px + nx) || wpl->xoff + wpl->sx + 1 < px)
if ((int)wpl->xoff - 1 > (int)(px + nx) || wpl->xoff + wpl->sx + 1 < px)
continue;
if (wpl->yoff - 1 > (int)(py + ny) || wpl->yoff + wpl->sy + 1 < py)
if ((int)wpl->yoff - 1 > (int)(py + ny) || wpl->yoff + wpl->sy + 1 < py)
continue;
overlap++;
if (overlap > 0) break;