summaryrefslogtreecommitdiff
path: root/desktop/textarea.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-04-12 10:30:20 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2012-04-12 10:30:20 +0000
commit387c85ae0b76fc32e23569bf5c5f452e9dd24c43 (patch)
tree5422ef592407d8c00aa9182d7a8c2585d6b6783c /desktop/textarea.c
parent87dbbe12600980e163a019ec72d885bc70aa82d7 (diff)
downloadnetsurf-387c85ae0b76fc32e23569bf5c5f452e9dd24c43.tar.gz
netsurf-387c85ae0b76fc32e23569bf5c5f452e9dd24c43.tar.bz2
Pass correct width/height values to textarea redraw callback when setting caret position. Reduces flicker.
svn path=/trunk/netsurf/; revision=13851
Diffstat (limited to 'desktop/textarea.c')
-rw-r--r--desktop/textarea.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c
index 6fa7739bd..ff9e47043 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -407,6 +407,7 @@ bool textarea_set_caret(struct text_area *ta, int caret)
int x, y;
int x0, y0, x1, y1;
int text_y_offset;
+ int width, height;
if (ta->flags & TEXTAREA_READONLY)
return true;
@@ -454,8 +455,12 @@ bool textarea_set_caret(struct text_area *ta, int caret)
/* set the caret coordinate beyond the redraw rectangle */
ta->caret_x = x - 2;
- ta->redraw_request(ta->data, x - 1, y + text_y_offset, x + 1,
- y + ta->line_height + text_y_offset);
+ x0 = x - 1;
+ y0 = y + text_y_offset;
+ width = 2;
+ height = ta->line_height;
+
+ ta->redraw_request(ta->data, x0, y0, width, height);
}
/* check if the caret has to be drawn at all */
@@ -501,16 +506,24 @@ bool textarea_set_caret(struct text_area *ta, int caret)
y = ta->line_height * ta->caret_pos.line - ta->scroll_y;
ta->caret_y = y;
- if (textarea_scroll_visible(ta))
+ if (textarea_scroll_visible(ta)) {
ta->redraw_request(ta->data, 0, 0,
ta->vis_width,
ta->vis_height);
- else {
+ } else {
x0 = max(x - 1, MARGIN_LEFT);
y0 = max(y + text_y_offset, 0);
x1 = min(x + 1, ta->vis_width - MARGIN_RIGHT);
- y1 = min(y + ta->line_height + text_y_offset, ta->vis_height);
- ta->redraw_request(ta->data, x0, y0, x1, y1);
+ y1 = min(y + ta->line_height + text_y_offset,
+ ta->vis_height);
+
+ width = x1 - x0;
+ height = y1 - y0;
+
+ if (width > 0 && height > 0) {
+ ta->redraw_request(ta->data, x0, y0,
+ width, height);
+ }
}
}