diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-02-07 13:58:43 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-02-07 13:58:43 +0000 |
commit | 94be5edbfa2473191c5886f04539731f9f2526df (patch) | |
tree | 7bcb4f90ee1045e809ecabd292a11820f22b4445 | |
parent | 762e1aad733c4d56edbb85c7b21b0951d8f759f2 (diff) | |
download | netsurf-94be5edbfa2473191c5886f04539731f9f2526df.tar.gz netsurf-94be5edbfa2473191c5886f04539731f9f2526df.tar.bz2 |
Native caret not now set in redraw. Prevents endless redraw when textarea has caret.
-rw-r--r-- | desktop/textarea.c | 64 | ||||
-rw-r--r-- | render/box_textarea.c | 5 |
2 files changed, 44 insertions, 25 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c index 679917b21..bfbed4232 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -361,6 +361,18 @@ static void textarea_scrollbar_callback(void *client_data, msg.data.redraw.y1 = ta->vis_height; ta->callback(ta->data, &msg); + + if (!(ta->flags & TEXTAREA_INTERNAL_CARET)) { + /* Tell client where caret should be placed */ + msg.ta = ta; + msg.type = TEXTAREA_MSG_MOVED_CARET; + msg.data.caret.hidden = false; + msg.data.caret.x = ta->caret_x - ta->scroll_x; + msg.data.caret.y = ta->caret_y - ta->scroll_y; + msg.data.caret.height = ta->line_height; + + ta->callback(ta->data, &msg); + } break; case SCROLLBAR_MSG_SCROLL_START: @@ -1209,17 +1221,19 @@ bool textarea_set_caret(struct textarea *ta, int caret) x += ta->border_width + ta->pad_left; ta->caret_x = x; - y = ta->line_height * ta->caret_pos.line; + y = ta->line_height * ta->caret_pos.line + text_y_offset; ta->caret_y = y; - if (!textarea_scroll_visible(ta)) { - /* No scroll, just caret moved, redraw it */ + if (!textarea_scroll_visible(ta) && + ta->flags & TEXTAREA_INTERNAL_CARET) { + /* Didn't scroll, just moved caret. + * Caret is internal caret, redraw it */ x -= ta->scroll_x; y -= ta->scroll_y; x0 = max(x - 1, ta->border_width); - y0 = max(y + text_y_offset, 0); + y0 = max(y, 0); x1 = min(x + 1, ta->vis_width - ta->border_width); - y1 = min(y + ta->line_height + text_y_offset, + y1 = min(y + ta->line_height, ta->vis_height); width = x1 - x0; @@ -1236,6 +1250,26 @@ bool textarea_set_caret(struct textarea *ta, int caret) ta->callback(ta->data, &msg); } } + + if (!(ta->flags & TEXTAREA_INTERNAL_CARET)) { + /* Tell client where caret should be placed */ + msg.ta = ta; + msg.type = TEXTAREA_MSG_MOVED_CARET; + msg.data.caret.hidden = false; + msg.data.caret.x = x - ta->scroll_x; + msg.data.caret.y = y - ta->scroll_y; + msg.data.caret.height = ta->line_height; + + ta->callback(ta->data, &msg); + } + + } else if (!(ta->flags & TEXTAREA_INTERNAL_CARET)) { + /* Caret hidden, and client is responsible: tell client */ + msg.ta = ta; + msg.type = TEXTAREA_MSG_MOVED_CARET; + msg.data.caret.hidden = true; + + ta->callback(ta->data, &msg); } return true; @@ -1268,7 +1302,6 @@ int textarea_get_caret(struct textarea *ta) void textarea_redraw(struct textarea *ta, int x, int y, colour bg, const struct rect *clip, const struct redraw_context *ctx) { - struct textarea_msg msg; const struct plotter_table *plot = ctx->plot; int line0, line1, line, left, right; int chars, text_y_offset, text_y_offset_baseline; @@ -1484,7 +1517,7 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, if ((ta->sel_end == -1 || ta->sel_start == ta->sel_end) && ta->caret_pos.char_off >= 0) { /* There is no selection, and caret visible: show caret */ - int caret_y = y - ta->scroll_y + ta->caret_y + text_y_offset; + int caret_y = y - ta->scroll_y + ta->caret_y; if (ta->flags & TEXTAREA_INTERNAL_CARET) { /* Render our own caret */ @@ -1492,24 +1525,7 @@ void textarea_redraw(struct textarea *ta, int x, int y, colour bg, x - ta->scroll_x + ta->caret_x, caret_y + ta->line_height, &pstyle_stroke_caret); - } else { - /* Tell client where caret should be placed */ - msg.ta = ta; - msg.type = TEXTAREA_MSG_MOVED_CARET; - msg.data.caret.hidden = false; - msg.data.caret.x = x - ta->scroll_x + ta->caret_x; - msg.data.caret.y = caret_y; - msg.data.caret.height = ta->line_height; - - ta->callback(ta->data, &msg); } - } else if (!(ta->flags & TEXTAREA_INTERNAL_CARET)) { - /* Caret hidden, and client is responsible: tell client */ - msg.ta = ta; - msg.type = TEXTAREA_MSG_MOVED_CARET; - msg.data.caret.hidden = true; - - ta->callback(ta->data, &msg); } if (ta->bar_x != NULL) diff --git a/render/box_textarea.c b/render/box_textarea.c index 3d2455f7c..f5a45ec94 100644 --- a/render/box_textarea.c +++ b/render/box_textarea.c @@ -175,8 +175,11 @@ static void box_textarea_callback(void *data, struct textarea_msg *msg) if (msg->data.caret.hidden) { browser_window_remove_caret(html->bw); } else { + int x, y; + box_coords(box, &x, &y); browser_window_place_caret(html->bw, - msg->data.caret.x, msg->data.caret.y, + x + msg->data.caret.x, + y + msg->data.caret.y, msg->data.caret.height, box_textarea_browser_caret_callback, box_textarea_browser_paste_callback, |