From 048b344a438dba1ff588c7a6fb3f9b67a1c7561e Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 9 Feb 2013 13:34:28 +0000 Subject: Take account of scrollbar-occupied regions. --- desktop/textarea.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'desktop') diff --git a/desktop/textarea.c b/desktop/textarea.c index 134d34b78..9ba5f1e65 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -264,16 +264,18 @@ static bool textarea_scroll_visible(struct textarea *ta) int xs = ta->scroll_x; int ys = ta->scroll_y; int vis; + int scrollbar_width; bool scrolled = false; if (ta->caret_pos.char_off == -1) return false; + scrollbar_width = (ta->bar_y == NULL) ? 0 : SCROLLBAR_WIDTH; x0 = ta->border_width + ta->pad_left; x1 = ta->vis_width - (ta->border_width + ta->pad_right); /* Adjust scroll pos for reduced extents */ - vis = ta->vis_width - 2 * ta->border_width; + vis = ta->vis_width - 2 * ta->border_width - scrollbar_width; if (ta->h_extent - xs < vis) xs -= vis - (ta->h_extent - xs); @@ -311,12 +313,13 @@ static bool textarea_scroll_visible(struct textarea *ta) /* check and change vertical scroll */ if (ta->flags & TEXTAREA_MULTILINE) { + scrollbar_width = (ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH; y0 = 0; y1 = ta->vis_height - 2 * ta->border_width - ta->pad_top - ta->pad_bottom; /* Adjust scroll pos for reduced extents */ - vis = ta->vis_height - 2 * ta->border_width; + vis = ta->vis_height - 2 * ta->border_width - scrollbar_width; if (ta->v_extent - ys < vis) ys -= vis - (ta->v_extent - ys); -- cgit v1.2.3