summaryrefslogtreecommitdiff
path: root/desktop/textinput.c
diff options
context:
space:
mode:
Diffstat (limited to 'desktop/textinput.c')
-rw-r--r--desktop/textinput.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/desktop/textinput.c b/desktop/textinput.c
index 8efc71963..b4fda5eef 100644
--- a/desktop/textinput.c
+++ b/desktop/textinput.c
@@ -127,14 +127,10 @@ bool browser_window_key_press(struct browser_window *bw, uint32_t key)
assert(bw->window != NULL);
- /* keys that take effect wherever the caret is positioned */
+ /* safe keys that can be handled whether input claimed or not */
switch (key) {
- case KEY_SELECT_ALL:
- selection_select_all(bw->cur_sel);
- return true;
-
case KEY_COPY_SELECTION:
- gui_copy_to_clipboard(bw->cur_sel);
+ selection_copy_to_clipboard(bw->cur_sel);
return true;
case KEY_CLEAR_SELECTION:
@@ -151,12 +147,20 @@ bool browser_window_key_press(struct browser_window *bw, uint32_t key)
return false;
}
- /* pass on to the appropriate field */
- if (!focus->caret_callback)
- return false;
+ if (focus->caret_callback) {
+ /* Pass keypress onto anything that has claimed input focus */
+ return focus->caret_callback(focus, key,
+ focus->caret_p1, focus->caret_p2);
+ }
- return focus->caret_callback(focus, key,
- focus->caret_p1, focus->caret_p2);
+ /* keys we can't handle here if cursor is in form */
+ switch (key) {
+ case KEY_SELECT_ALL:
+ selection_select_all(bw->cur_sel);
+ return true;
+ }
+
+ return false;
}
@@ -168,6 +172,8 @@ bool browser_window_key_press(struct browser_window *bw, uint32_t key)
* \param utf8_len length (bytes) of text block
* \param last true iff this is the last chunk (update screen too)
* \return true iff successful
+ *
+ * TODO: Remove this function.
*/
bool browser_window_paste_text(struct browser_window *bw, const char *utf8,