diff options
author | Josh Rickmar <jrick@devio.us> | 2012-07-05 10:10:34 -0400 |
---|---|---|
committer | Josh Rickmar <jrick@devio.us> | 2012-07-05 10:10:34 -0400 |
commit | 72ce72c612c1782aa9293e9798768f3ca808e736 (patch) | |
tree | b88f3ba020af7dda51e356bc69e2507efb1de509 /inputfocus.c | |
parent | a5b5e1de045cab38f969984f66addc840a7fb89c (diff) | |
download | xombrero-72ce72c612c1782aa9293e9798768f3ca808e736.tar.gz |
Make the autofocus code a bit smarter by first saving the original
text in the text box and seeing if it's any different from the new text before attempting to enter command mode. Before, there was only a check to see if there was any text. This also only sets t->active if it is not NULL, so only the page's default text entry box is ever used when entering insert_mode, instead of the last text box that was typed into.
Diffstat (limited to 'inputfocus.c')
-rw-r--r-- | inputfocus.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/inputfocus.c b/inputfocus.c index ab69947..951782d 100644 --- a/inputfocus.c +++ b/inputfocus.c @@ -239,8 +239,11 @@ dom_is_input(struct tab *t, char **text) aa = (WebKitDOMHTMLElement*)a; if (WEBKIT_DOM_IS_HTML_ELEMENT(aa) && webkit_dom_html_element_get_is_content_editable(aa)) { - t->active = a; + if (t->active == NULL) + t->active = a; *text = get_element_text((WebKitDOMNode *)a); + if (t->active_text == NULL) + t->active_text = g_strdup(*text); return (1); } break; @@ -251,8 +254,11 @@ dom_is_input(struct tab *t, char **text) if (WEBKIT_DOM_IS_HTML_INPUT_ELEMENT((WebKitDOMNode *)a) || WEBKIT_DOM_IS_HTML_TEXT_AREA_ELEMENT((WebKitDOMNode *)a)) { - t->active = a; + if (t->active == NULL) + t->active = a; *text = get_element_text((WebKitDOMNode *)a); + if (t->active_text == NULL) + t->active_text = g_strdup(*text); return (1); } @@ -302,7 +308,7 @@ input_autofocus(struct tab *t) t->mode = XT_MODE_COMMAND; } else { if (dom_is_input(t, &text)) { - if (text != NULL && g_strcmp0(text, "")) { + if (text != NULL && g_strcmp0(text, t->active_text)) { g_free(text); t->mode = XT_MODE_INSERT; } else if (t->active) { |