diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-01-07 14:15:35 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-01-07 14:15:35 +0000 |
commit | f43f84f5ad324be693fdbe1fc493f418a2fa177d (patch) | |
tree | 827c863a8839da45a7f88f5ef3e8f0f5203ad7d1 | |
parent | 0c0f1e4b7a25ba4df1e005a37b1251a8f62ff337 (diff) | |
download | netsurf-f43f84f5ad324be693fdbe1fc493f418a2fa177d.tar.gz netsurf-f43f84f5ad324be693fdbe1fc493f418a2fa177d.tar.bz2 |
Fix redraw of selection hightlight during selection drags.
-rw-r--r-- | desktop/textarea.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/desktop/textarea.c b/desktop/textarea.c index 406231814..35959c8ce 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -162,10 +162,9 @@ static void textarea_normalise_text(struct textarea *ta, */ static bool textarea_select(struct textarea *ta, int c_start, int c_end) { - int swap = -1; + int swap; - /* if start is after end they get swapped, start won't and end will - be selected this way */ + /* Ensure start is the beginning of the selection */ if (c_start > c_end) { swap = c_start; c_start = c_end; @@ -175,13 +174,6 @@ static bool textarea_select(struct textarea *ta, int c_start, int c_end) ta->selection_start = c_start; ta->selection_end = c_end; - if (!(ta->flags & TEXTAREA_READONLY)) { - if (swap == -1) - return textarea_set_caret(ta, c_end); - else - return textarea_set_caret(ta, c_start); - } - ta->redraw_request(ta->data, 0, 0, ta->vis_width, ta->vis_height); return true; @@ -1382,31 +1374,28 @@ bool textarea_mouse_action(struct textarea *ta, browser_mouse_state mouse, /* mouse button pressed above the text area, move caret */ if (mouse & BROWSER_MOUSE_PRESS_1) { - if (!(ta->flags & TEXTAREA_READONLY)) + if (!(ta->flags & TEXTAREA_READONLY)) { textarea_set_caret_xy(ta, x, y); + ta->drag_start_char = textarea_get_xy_offset(ta, x, y); + } if (ta->selection_start != -1) { + /* remove selection */ ta->selection_start = ta->selection_end = -1; ta->redraw_request(ta->data, 0, 0, ta->vis_width, ta->vis_height); } - } - else if (mouse & BROWSER_MOUSE_DOUBLE_CLICK) { + + } else if (mouse & BROWSER_MOUSE_DOUBLE_CLICK) { if (!(ta->flags & TEXTAREA_READONLY)) { textarea_set_caret_xy(ta, x, y); return textarea_select_fragment(ta); } - } - else if (mouse & BROWSER_MOUSE_DRAG_1) { - ta->drag_start_char = textarea_get_xy_offset(ta, x, y); - if (!(ta->flags & TEXTAREA_READONLY)) - return textarea_set_caret(ta, -1); - } - else if (mouse & BROWSER_MOUSE_HOLDING_1) { + + } else if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_HOLDING_1)) { c_start = ta->drag_start_char; c_end = textarea_get_xy_offset(ta, x, y); return textarea_select(ta, c_start, c_end); - } return true; |