From 8e360ff0403523409a7c2edcea9acdf46f4b8605 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 20 Mar 2013 19:52:10 +0000 Subject: Robust detection of scroll changes. --- desktop/textarea.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'desktop') diff --git a/desktop/textarea.c b/desktop/textarea.c index 212cc5b03..d23a021ca 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -1963,11 +1963,15 @@ bool textarea_keypress(struct textarea *ta, uint32_t key) struct textarea_msg msg; char utf8[6]; unsigned int caret, length, b_off, b_len; + int h_extent = ta->h_extent; + int v_extent = ta->v_extent; int line; int byte_delta = 0; int x, y; bool redraw = false; bool readonly; + bool bar_x = ta->bar_x; + bool bar_y = ta->bar_y; /* Word separators */ static const char *sep = " .\n"; @@ -2361,16 +2365,23 @@ bool textarea_keypress(struct textarea *ta, uint32_t key) redraw &= ~textarea_set_caret_internal(ta, caret); /* TODO: redraw only the bit that changed */ - if (redraw) { - msg.ta = ta; - msg.type = TEXTAREA_MSG_REDRAW_REQUEST; - msg.data.redraw.x0 = ta->border_width; - msg.data.redraw.y0 = ta->border_width; + msg.ta = ta; + msg.type = TEXTAREA_MSG_REDRAW_REQUEST; + msg.data.redraw.x0 = ta->border_width; + msg.data.redraw.y0 = ta->border_width; + + if (bar_x != (ta->bar_x != NULL) || bar_y != (ta->bar_y != NULL) || + h_extent != ta->h_extent || v_extent != ta->v_extent) { + /* Must redraw since scrollbars have changed */ + msg.data.redraw.x1 = ta->vis_width - ta->border_width; + msg.data.redraw.y1 = ta->vis_height - ta->border_width; + ta->callback(ta->data, &msg); + + } else if (redraw) { msg.data.redraw.x1 = ta->vis_width - ta->border_width - ((ta->bar_y == NULL) ? 0 : SCROLLBAR_WIDTH); msg.data.redraw.y1 = ta->vis_height - ta->border_width - ((ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH); - ta->callback(ta->data, &msg); } -- cgit v1.2.3