about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--inputfocus.c12
-rw-r--r--xombrero.c4
-rw-r--r--xombrero.h1
3 files changed, 14 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) {
diff --git a/xombrero.c b/xombrero.c
index 3802e0e..0b5c10d 100644
--- a/xombrero.c
+++ b/xombrero.c
@@ -4122,6 +4122,10 @@ notify_load_status_cb(WebKitWebView* wview, GParamSpec* pspec, struct tab *t)
 
 		/* DOM is changing, unreference the previous focused element */
 		t->active = NULL;
+		if (t->active_text) {
+			g_free(t->active_text);
+			t->active_text = NULL;
+		}
 
 		/* take focus if we are visible */
 		focus_webview(t);
diff --git a/xombrero.h b/xombrero.h
index feb0d4c..9971804 100644
--- a/xombrero.h
+++ b/xombrero.h
@@ -288,6 +288,7 @@ struct tab {
 
 	/* focused text entry */
 	WebKitDOMElement	*active;
+	char			*active_text;
 };
 TAILQ_HEAD(tab_list, tab);