From dbe50934b1cef66417de663f82bdda9728a8d0a6 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 30 Jun 2026 07:41:02 +0100 Subject: [PATCH] Add caching of scrollbar options to 3.7a branch. --- cmd-resize-pane.c | 12 +++---- layout.c | 19 ++++------- options.c | 7 +++- screen-redraw.c | 85 ++++++++++++++++++++++------------------------- server-client.c | 23 ++++++------- tmux.h | 5 ++- window.c | 20 +++++------ 7 files changed, 80 insertions(+), 91 deletions(-) diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c index d1a8f6723..8ad2655d2 100644 --- a/cmd-resize-pane.c +++ b/cmd-resize-pane.c @@ -181,7 +181,7 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m) struct window_pane *wp; struct layout_cell *lc; int y, ly, x, lx, sx, sy, new_sx, new_sy; - int scrollbars, sb_pos, left, right; + int left, right; int new_xoff, new_yoff, resizes = 0; wp = cmd_mouse_pane(m, NULL, &wl); @@ -193,15 +193,13 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m) lc = wp->layout_cell; sx = wp->sx; sy = wp->sy; - scrollbars = options_get_number(w->options, "pane-scrollbars"); - sb_pos = options_get_number(w->options, "pane-scrollbars-position"); left = wp->xoff - 1; right = wp->xoff + sx; - if (window_pane_show_scrollbar(wp, scrollbars) && - sb_pos == PANE_SCROLLBARS_LEFT) { + if (window_pane_show_scrollbar(wp) && + w->sb_pos == PANE_SCROLLBARS_LEFT) { left -= wp->scrollbar_style.width + wp->scrollbar_style.pad; - } else if (window_pane_show_scrollbar(wp, scrollbars) && - sb_pos == PANE_SCROLLBARS_RIGHT) { + } else if (window_pane_show_scrollbar(wp) && + w->sb_pos == PANE_SCROLLBARS_RIGHT) { right += wp->scrollbar_style.width + wp->scrollbar_style.pad; } diff --git a/layout.c b/layout.c index da98b590e..70226d6af 100644 --- a/layout.c +++ b/layout.c @@ -359,12 +359,10 @@ layout_fix_panes(struct window *w, struct window_pane *skip) { struct window_pane *wp; struct layout_cell *lc; - int status, scrollbars, sb_pos, sb_w, sb_pad; + int status, sb_w, sb_pad; u_int sx, sy; status = options_get_number(w->options, "pane-border-status"); - scrollbars = options_get_number(w->options, "pane-scrollbars"); - sb_pos = options_get_number(w->options, "pane-scrollbars-position"); TAILQ_FOREACH(wp, &w->panes, entry) { if ((lc = wp->layout_cell) == NULL || wp == skip) @@ -382,14 +380,14 @@ layout_fix_panes(struct window *w, struct window_pane *skip) sy--; } - if (window_pane_show_scrollbar(wp, scrollbars)) { + if (window_pane_show_scrollbar(wp)) { sb_w = wp->scrollbar_style.width; sb_pad = wp->scrollbar_style.pad; if (sb_w < 1) sb_w = 1; if (sb_pad < 0) sb_pad = 0; - if (sb_pos == PANE_SCROLLBARS_LEFT) { + if (w->sb_pos == PANE_SCROLLBARS_LEFT) { if ((int)sx - sb_w < PANE_MINIMUM) { wp->xoff = wp->xoff + (int)sx - PANE_MINIMUM; @@ -398,7 +396,7 @@ layout_fix_panes(struct window *w, struct window_pane *skip) sx = sx - sb_w - sb_pad; wp->xoff = wp->xoff + sb_w + sb_pad; } - } else /* sb_pos == PANE_SCROLLBARS_RIGHT */ + } else /* w->sb_pos == PANE_SCROLLBARS_RIGHT */ if ((int)sx - sb_w - sb_pad < PANE_MINIMUM) sx = PANE_MINIMUM; else @@ -438,16 +436,15 @@ layout_resize_check(struct window *w, struct layout_cell *lc, struct layout_cell *lcchild; struct style *sb_style = &w->active->scrollbar_style; u_int available, minimum; - int status, scrollbars; + int status; status = options_get_number(w->options, "pane-border-status"); - scrollbars = options_get_number(w->options, "pane-scrollbars"); if (lc->type == LAYOUT_WINDOWPANE) { /* Space available in this cell only. */ if (type == LAYOUT_LEFTRIGHT) { available = lc->sx; - if (scrollbars) + if (w->sb != PANE_SCROLLBARS_OFF) minimum = PANE_MINIMUM + sb_style->width + sb_style->pad; else @@ -1003,7 +1000,6 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size, u_int sx, sy, xoff, yoff, size1, size2, minimum; u_int new_size, saved_size, resize_first = 0; int full_size = (flags & SPAWN_FULLSIZE), status; - int scrollbars; /* * If full_size is specified, add a new cell at the top of the window @@ -1014,7 +1010,6 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size, else lc = wp->layout_cell; status = options_get_number(wp->window->options, "pane-border-status"); - scrollbars = options_get_number(wp->window->options, "pane-scrollbars"); /* Copy the old cell size. */ sx = lc->sx; @@ -1025,7 +1020,7 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size, /* Check there is enough space for the two new panes. */ switch (type) { case LAYOUT_LEFTRIGHT: - if (scrollbars) { + if (wp->window->sb != PANE_SCROLLBARS_OFF) { minimum = PANE_MINIMUM * 2 + sb_style->width + sb_style->pad; } else diff --git a/options.c b/options.c index a847ad9c1..e38056c34 100644 --- a/options.c +++ b/options.c @@ -1237,8 +1237,13 @@ options_push_changes(const char *name) if (strcmp(name, "pane-border-status") == 0 || strcmp(name, "pane-scrollbars") == 0 || strcmp(name, "pane-scrollbars-position") == 0) { - RB_FOREACH(w, windows, &windows) + RB_FOREACH(w, windows, &windows) { + w->sb = options_get_number(w->options, + "pane-scrollbars"); + w->sb_pos = options_get_number(w->options, + "pane-scrollbars-position"); layout_fix_panes(w, NULL); + } } if (strcmp(name, "pane-scrollbars-style") == 0) { RB_FOREACH(wp, window_pane_tree, &all_window_panes) { diff --git a/screen-redraw.c b/screen-redraw.c index 17085a411..e1d8c6289 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -123,31 +123,28 @@ static enum screen_redraw_border_type screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp, int px, int py) { - struct options *oo = wp->window->options; + struct window *w = wp->window; + struct options *oo = w->options; int ex = wp->xoff + wp->sx, ey = wp->yoff + wp->sy; int hsplit = 0, vsplit = 0, pane_status = ctx->pane_status; - int pane_scrollbars = ctx->pane_scrollbars, sb_w = 0; - int sb_pos, sx = wp->sx, sy = wp->sy, left, right; + int sb_w = 0; + int sx = wp->sx, sy = wp->sy, left, right; enum layout_type split_type; - if (pane_scrollbars != 0) - sb_pos = ctx->pane_scrollbars_pos; - else - sb_pos = 0; - /* Inside pane. */ if (px >= wp->xoff && px < ex && py >= wp->yoff && py < ey) return (SCREEN_REDRAW_INSIDE); /* Are scrollbars enabled? */ - if (window_pane_show_scrollbar(wp, pane_scrollbars)) + if (window_pane_show_scrollbar(wp)) sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; /* Floating pane borders. */ if (window_pane_is_floating(wp)) { left = wp->xoff - 1; right = wp->xoff + sx; - if (sb_pos == PANE_SCROLLBARS_LEFT) + if (w->sb != PANE_SCROLLBARS_OFF && + w->sb_pos == PANE_SCROLLBARS_LEFT) left -= sb_w; else right += sb_w; @@ -182,7 +179,8 @@ screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp, * active window's border when there are two panes. */ if ((wp->yoff == 0 || py >= wp->yoff - 1) && py <= ey) { - if (sb_pos == PANE_SCROLLBARS_LEFT) { + if (w->sb != PANE_SCROLLBARS_OFF && + w->sb_pos == PANE_SCROLLBARS_LEFT) { if (wp->xoff - sb_w == 0 && px == sx + sb_w) { if (!hsplit || (hsplit && py <= sy / 2)) return (SCREEN_REDRAW_BORDER_RIGHT); @@ -194,7 +192,7 @@ screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp, if (px == wp->xoff + sx + sb_w - 1) return (SCREEN_REDRAW_BORDER_RIGHT); } - } else { /* sb_pos == PANE_SCROLLBARS_RIGHT or disabled */ + } else { /* w->sb_pos == PANE_SCROLLBARS_RIGHT or disabled */ if (wp->xoff == 0 && px == sx + sb_w) { if (!hsplit || (hsplit && py <= sy / 2)) return (SCREEN_REDRAW_BORDER_RIGHT); @@ -216,7 +214,8 @@ screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp, if (wp->yoff != 0 && py == wp->yoff - 1 && px > sx / 2) return (SCREEN_REDRAW_BORDER_TOP); } else { - if (sb_pos == PANE_SCROLLBARS_LEFT) { + if (w->sb != PANE_SCROLLBARS_OFF && + w->sb_pos == PANE_SCROLLBARS_LEFT) { if ((wp->xoff - sb_w == 0 || px >= wp->xoff - sb_w) && (px <= ex || (sb_w != 0 && px < ex + sb_w))) { if (pane_status != PANE_STATUS_BOTTOM && @@ -225,7 +224,7 @@ screen_redraw_pane_border(struct screen_redraw_ctx *ctx, struct window_pane *wp, if (pane_status != PANE_STATUS_TOP && py == ey) return (SCREEN_REDRAW_BORDER_BOTTOM); } - } else { /* sb_pos == PANE_SCROLLBARS_RIGHT */ + } else { /* w->sb_pos == PANE_SCROLLBARS_RIGHT */ if ((wp->xoff == 0 || px >= wp->xoff) && (px <= ex || (sb_w != 0 && px < ex + sb_w))) { if (pane_status != PANE_STATUS_BOTTOM && @@ -278,17 +277,15 @@ screen_redraw_cell_border(struct screen_redraw_ctx *ctx, struct window_pane *wp, struct client *c = ctx->c; struct window *w = c->session->curw->window; struct window_pane *wp2; - int sx = w->sx, sy = w->sy, sb_w, sb_pos, n; + int sx = w->sx, sy = w->sy, sb_w, n; - if (ctx->pane_scrollbars != 0) - sb_pos = ctx->pane_scrollbars_pos; - else - sb_pos = 0; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; /* For floating panes, only check the pane itself. */ if (window_pane_is_floating(wp)) { - n = screen_redraw_cell_border1(ctx, sb_pos, sb_w, wp, px, py); + n = screen_redraw_cell_border1(ctx, + w->sb != PANE_SCROLLBARS_OFF ? w->sb_pos : 0, + sb_w, wp, px, py); if (n == -1) return (0); return (n); @@ -311,7 +308,9 @@ screen_redraw_cell_border(struct screen_redraw_ctx *ctx, struct window_pane *wp, TAILQ_FOREACH(wp2, &w->z_index, zentry) { if (!window_pane_visible(wp2) || window_pane_is_floating(wp2)) continue; - n = screen_redraw_cell_border1(ctx, sb_pos, sb_w, wp2, px, py); + n = screen_redraw_cell_border1(ctx, + w->sb != PANE_SCROLLBARS_OFF ? w->sb_pos : 0, + sb_w, wp2, px, py); if (n != -1) return (n); } @@ -435,9 +434,9 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, int px, int py, struct window_pane *wp, *start; int sx = w->sx, sy = w->sy; int pane_status = ctx->pane_status; - int border, pane_scrollbars = ctx->pane_scrollbars; + int border; int pane_status_line, tiled_only = 0, left, right; - int sb_pos = ctx->pane_scrollbars_pos, sb_w; + int sb_w; *wpp = NULL; @@ -452,7 +451,8 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, int px, int py, continue; } sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; - if (sb_pos == PANE_SCROLLBARS_LEFT) { + if (w->sb != PANE_SCROLLBARS_OFF && + w->sb_pos == PANE_SCROLLBARS_LEFT) { if ((px >= wp->xoff - 1 - sb_w && px <= wp->xoff + (int)wp->sx) && (py >= wp->yoff - 1 && @@ -492,7 +492,8 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, int px, int py, *wpp = wp; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; - if (sb_pos == PANE_SCROLLBARS_LEFT) { + if (w->sb != PANE_SCROLLBARS_OFF && + w->sb_pos == PANE_SCROLLBARS_LEFT) { if ((px < wp->xoff - 1 - sb_w || px > wp->xoff + (int)wp->sx) && (py < wp->yoff - 1 || @@ -524,7 +525,7 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, int px, int py, } /* Check if CELL_SCROLLBAR. */ - if (window_pane_show_scrollbar(wp, pane_scrollbars)) { + if (window_pane_show_scrollbar(wp)) { /* * Check if py could lie within a scrollbar. If the * pane is at the top then py == 0 to sy; if the pane @@ -536,10 +537,10 @@ screen_redraw_check_cell(struct screen_redraw_ctx *ctx, int px, int py, (py >= wp->yoff && py < wp->yoff + (int)wp->sy)) { /* Check if px lies within a scrollbar. */ - if ((sb_pos == PANE_SCROLLBARS_RIGHT && + if ((w->sb_pos == PANE_SCROLLBARS_RIGHT && (px >= wp->xoff + (int)wp->sx && px < wp->xoff + (int)wp->sx + sb_w)) || - (sb_pos == PANE_SCROLLBARS_LEFT && + (w->sb_pos == PANE_SCROLLBARS_LEFT && (px >= wp->xoff - sb_w && px < wp->xoff))) return (CELL_SCROLLBAR); @@ -593,13 +594,12 @@ screen_redraw_make_pane_status(struct client *c, struct window_pane *wp, struct style_line_entry *sle = &wp->border_status_line; char *expanded; int pane_status = rctx->pane_status, sb_w = 0; - int pane_scrollbars = rctx->pane_scrollbars; int max_width; u_int width, i, cell_type, px, py; struct screen_write_ctx ctx; struct screen old; - if (window_pane_show_scrollbar(wp, pane_scrollbars)) + if (window_pane_show_scrollbar(wp)) sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; ft = format_create(c, NULL, FORMAT_PANE|wp->id, FORMAT_STATUS); @@ -791,10 +791,6 @@ screen_redraw_set_context(struct client *c, struct screen_redraw_ctx *ctx) ctx->pane_status = options_get_number(wo, "pane-border-status"); ctx->pane_lines = options_get_number(wo, "pane-border-lines"); - ctx->pane_scrollbars = options_get_number(wo, "pane-scrollbars"); - ctx->pane_scrollbars_pos = options_get_number(wo, - "pane-scrollbars-position"); - tty_window_offset(&c->tty, &ctx->ox, &ctx->oy, &ctx->sx, &ctx->sy); log_debug("%s: %s @%u ox=%u oy=%u sx=%u sy=%u %u/%d", __func__, c->name, @@ -863,7 +859,7 @@ screen_redraw_pane(struct client *c, struct window_pane *wp, if (!redraw_scrollbar_only) screen_redraw_draw_pane(&ctx, wp); - if (window_pane_show_scrollbar(wp, ctx.pane_scrollbars)) + if (window_pane_show_scrollbar(wp)) screen_redraw_draw_pane_scrollbar(&ctx, wp); tty_reset(&c->tty); @@ -1142,7 +1138,7 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, int px, struct window *w; struct visible_range *ri; static struct visible_ranges sr = { NULL, 0, 0 }; - int found_self, sb, sb_w, sb_pos; + int found_self, sb_w; int lb, rb, tb, bb, sx, ex; u_int i, s; @@ -1182,9 +1178,6 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, int px, r->used = 1; } - sb = options_get_number(w->options, "pane-scrollbars"); - sb_pos = options_get_number(w->options, "pane-scrollbars-position"); - found_self = 0; TAILQ_FOREACH_REVERSE(wp, &w->z_index, window_panes_zindex, zentry) { if (wp == base_wp) { @@ -1203,12 +1196,12 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, int px, continue; sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; - if (!window_pane_show_scrollbar(wp, sb)) - sb_w = sb_pos = 0; + if (!window_pane_show_scrollbar(wp)) + sb_w = 0; for (i = 0; i < r->used; i++) { ri = &r->ranges[i]; - if (sb_pos == PANE_SCROLLBARS_LEFT) { + if (w->sb_pos == PANE_SCROLLBARS_LEFT) { if (wp->xoff > sb_w) lb = wp->xoff - 1 - sb_w; else @@ -1219,7 +1212,7 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, int px, else lb = 0; } - if (sb_pos == PANE_SCROLLBARS_LEFT) + if (w->sb_pos == PANE_SCROLLBARS_LEFT) rb = wp->xoff + wp->sx; else /* PANE_SCROLLBARS_RIGHT or none. */ rb = wp->xoff + wp->sx + sb_w; @@ -1407,7 +1400,7 @@ screen_redraw_draw_pane_scrollbars(struct screen_redraw_ctx *ctx) log_debug("%s: %s @%u", __func__, c->name, w->id); TAILQ_FOREACH(wp, &w->panes, entry) { - if (window_pane_show_scrollbar(wp, ctx->pane_scrollbars) && + if (window_pane_show_scrollbar(wp) && window_pane_visible(wp)) screen_redraw_draw_pane_scrollbar(ctx, wp); } @@ -1420,8 +1413,8 @@ screen_redraw_draw_pane_scrollbar(struct screen_redraw_ctx *ctx, { struct screen *s = wp->screen; double percent_view; - u_int sb = ctx->pane_scrollbars, total_height, sb_h = wp->sy; - u_int sb_pos = ctx->pane_scrollbars_pos, slider_h, slider_y; + u_int sb = wp->window->sb, total_height, sb_h = wp->sy; + u_int sb_pos = wp->window->sb_pos, slider_h, slider_y; int sb_w = wp->scrollbar_style.width; int sb_pad = wp->scrollbar_style.pad; int cm_y, cm_size, xoff = wp->xoff; diff --git a/server-client.c b/server-client.c index cf1e824c7..52886f014 100644 --- a/server-client.c +++ b/server-client.c @@ -603,17 +603,14 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py, u_int *sl_mpos) { struct window *w = wp->window; - struct options *wo = w->options; struct window_pane *fwp; - int pane_status, sb, sb_pos, sb_w, sb_pad; + int pane_status, sb_w, sb_pad; int pane_status_line, sl_top, sl_bottom; int bdr_bottom, bdr_top, bdr_left, bdr_right; - sb = options_get_number(wo, "pane-scrollbars"); - sb_pos = options_get_number(wo, "pane-scrollbars-position"); - pane_status = options_get_number(wo, "pane-border-status"); + pane_status = options_get_number(w->options, "pane-border-status"); - if (window_pane_show_scrollbar(wp, sb)) { + if (window_pane_show_scrollbar(wp)) { sb_w = wp->scrollbar_style.width; sb_pad = wp->scrollbar_style.pad; } else { @@ -628,7 +625,7 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py, else pane_status_line = -1; /* not used */ bdr_left = wp->xoff - 1; - if (sb_pos == PANE_SCROLLBARS_LEFT) + if (w->sb_pos == PANE_SCROLLBARS_LEFT) bdr_left -= sb_pad + sb_w; /* Check if point is within the pane or scrollbar. */ @@ -636,15 +633,15 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py, py != pane_status_line && py != wp->yoff + (int)wp->sy) || (wp->yoff == 0 && py < (int)wp->sy) || (py >= wp->yoff && py < wp->yoff + (int)wp->sy)) && - ((sb_pos == PANE_SCROLLBARS_RIGHT && + ((w->sb_pos == PANE_SCROLLBARS_RIGHT && px < wp->xoff + (int)wp->sx + sb_pad + sb_w) || - (sb_pos == PANE_SCROLLBARS_LEFT && + (w->sb_pos == PANE_SCROLLBARS_LEFT && px < wp->xoff + (int)wp->sx - sb_pad - sb_w))) { /* Check if in the scrollbar. */ - if ((sb_pos == PANE_SCROLLBARS_RIGHT && + if ((w->sb_pos == PANE_SCROLLBARS_RIGHT && (px >= wp->xoff + (int)wp->sx + sb_pad && px < wp->xoff + (int)wp->sx + sb_pad + sb_w)) || - (sb_pos == PANE_SCROLLBARS_LEFT && + (w->sb_pos == PANE_SCROLLBARS_LEFT && (px >= wp->xoff - sb_pad - sb_w && px < wp->xoff - sb_pad))) { /* Check where inside the scrollbar. */ @@ -674,7 +671,7 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py, if ((w->flags & WINDOW_ZOOMED) && (~fwp->flags & PANE_ZOOMED)) continue; - if (window_pane_show_scrollbar(fwp, sb)) { + if (window_pane_show_scrollbar(fwp)) { sb_w = fwp->scrollbar_style.width; sb_pad = fwp->scrollbar_style.pad; } else { @@ -684,7 +681,7 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py, bdr_top = fwp->yoff - 1; bdr_bottom = fwp->yoff + fwp->sy; bdr_left = fwp->xoff - 1; - if (sb_pos == PANE_SCROLLBARS_LEFT) { + if (w->sb_pos == PANE_SCROLLBARS_LEFT) { bdr_left -= sb_pad + sb_w; bdr_right = fwp->xoff + fwp->sx; } else { diff --git a/tmux.h b/tmux.h index 0fbc4424e..5dc86b2b1 100644 --- a/tmux.h +++ b/tmux.h @@ -1390,6 +1390,9 @@ struct window { u_int last_new_pane_x; u_int last_new_pane_y; + int sb; + int sb_pos; + struct utf8_data *fill_character; int flags; #define WINDOW_BELL 0x1 @@ -3495,7 +3498,7 @@ void window_pane_update_used_data(struct window_pane *, void window_set_fill_character(struct window *); void window_pane_default_cursor(struct window_pane *); int window_pane_mode(struct window_pane *); -int window_pane_show_scrollbar(struct window_pane *, int); +int window_pane_show_scrollbar(struct window_pane *); int window_pane_get_bg(struct window_pane *); int window_pane_get_fg(struct window_pane *); int window_pane_get_fg_control_client(struct window_pane *); diff --git a/window.c b/window.c index 45d8d2f68..00ed1a079 100644 --- a/window.c +++ b/window.c @@ -1471,20 +1471,16 @@ window_pane_full_size_offset(struct window_pane *wp, int *xoff, int *yoff, u_int *sx, u_int *sy) { struct window *w = wp->window; - int pane_scrollbars; - u_int sb_w, sb_pos; + u_int sb_w; - pane_scrollbars = options_get_number(w->options, "pane-scrollbars"); - sb_pos = options_get_number(w->options, "pane-scrollbars-position"); - - if (window_pane_show_scrollbar(wp, pane_scrollbars)) + if (window_pane_show_scrollbar(wp)) sb_w = wp->scrollbar_style.width + wp->scrollbar_style.pad; else sb_w = 0; - if (sb_pos == PANE_SCROLLBARS_LEFT) { + if (w->sb_pos == PANE_SCROLLBARS_LEFT) { *xoff = wp->xoff - sb_w; *sx = wp->sx + sb_w; - } else { /* sb_pos == PANE_SCROLLBARS_RIGHT */ + } else { /* w->sb_pos == PANE_SCROLLBARS_RIGHT */ *xoff = wp->xoff; *sx = wp->sx + sb_w; } @@ -1899,12 +1895,14 @@ window_pane_mode(struct window_pane *wp) /* Return 1 if scrollbar is or should be displayed. */ int -window_pane_show_scrollbar(struct window_pane *wp, int sb_option) +window_pane_show_scrollbar(struct window_pane *wp) { + struct window *w = wp->window; + if (SCREEN_IS_ALTERNATE(&wp->base)) return (0); - if (sb_option == PANE_SCROLLBARS_ALWAYS || - (sb_option == PANE_SCROLLBARS_MODAL && + if (w->sb == PANE_SCROLLBARS_ALWAYS || + (w->sb == PANE_SCROLLBARS_MODAL && window_pane_mode(wp) != WINDOW_PANE_NO_MODE)) return (1); return (0);