From 3403891f63dd8842bfac48626e3ccb569893aa21 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 20 Mar 2013 17:53:38 +0000 Subject: Avoid redraw of scrollbars when they've not changed. --- desktop/textarea.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/desktop/textarea.c b/desktop/textarea.c index 42870c3cc..d3a848fa0 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -481,15 +481,17 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end, msg.ta = ta; msg.type = TEXTAREA_MSG_REDRAW_REQUEST; + msg.data.redraw.x0 = ta->border_width; + msg.data.redraw.x1 = ta->vis_width - ta->border_width - + ((ta->bar_y == NULL) ? 0 : SCROLLBAR_WIDTH); if (force_redraw || !pre_existing_selection || (ta->sel_start != b_start && ta->sel_end != b_end)) { /* Asked to redraw everything, or there's a new selection, or * both ends of the selection have moved */ - msg.data.redraw.x0 = 0; - msg.data.redraw.y0 = 0; - msg.data.redraw.x1 = ta->vis_width; - msg.data.redraw.y1 = ta->vis_height; + msg.data.redraw.y0 = ta->border_width; + msg.data.redraw.y1 = ta->vis_height - ta->border_width - + ((ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH); } else { /* Redraw to cover change in selection start or change in * selection end */ @@ -523,11 +525,11 @@ static bool textarea_select(struct textarea *ta, int b_start, int b_end, if (ta->lines[line_end + 1].b_start > b_high) break; - msg.data.redraw.x0 = 0; - msg.data.redraw.y0 = max(0, ta->line_height * line_start + + msg.data.redraw.y0 = max(ta->border_width, + ta->line_height * line_start + ta->text_y_offset - ta->scroll_y); - msg.data.redraw.x1 = ta->vis_width; - msg.data.redraw.y1 = min(ta->vis_height, + msg.data.redraw.y1 = min(ta->vis_height - ta->border_width - + ((ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH), ta->line_height * line_end + ta->text_y_offset + ta->line_height - ta->scroll_y); } @@ -2365,10 +2367,12 @@ bool textarea_keypress(struct textarea *ta, uint32_t key) if (redraw) { msg.ta = ta; msg.type = TEXTAREA_MSG_REDRAW_REQUEST; - msg.data.redraw.x0 = 0; - msg.data.redraw.y0 = 0; - msg.data.redraw.x1 = ta->vis_width; - msg.data.redraw.y1 = ta->vis_height; + msg.data.redraw.x0 = ta->border_width; + msg.data.redraw.y0 = ta->border_width; + 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); } @@ -2587,10 +2591,12 @@ bool textarea_clear_selection(struct textarea *ta) msg.ta = ta; msg.type = TEXTAREA_MSG_REDRAW_REQUEST; - msg.data.redraw.x0 = 0; - msg.data.redraw.y0 = 0; - msg.data.redraw.x1 = ta->vis_width; - msg.data.redraw.y1 = ta->vis_height; + msg.data.redraw.x0 = ta->border_width; + msg.data.redraw.y0 = ta->border_width; + 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