give the focus to the text box after it's closed in an external editor
authorBenjamin Petrenko <benjamin.petrenko@gmail.com>
Mon, 20 Jul 2015 17:55:00 +0000 (20:55 +0300)
committerBenjamin Petrenko <benjamin.petrenko@gmail.com>
Mon, 20 Jul 2015 17:55:00 +0000 (20:55 +0300)
src/dom.c
src/dom.h
src/input.c

index 3e86e81..4ca0a73 100644 (file)
--- a/src/dom.c
+++ b/src/dom.c
@@ -77,6 +77,14 @@ void dom_clear_focus(WebKitWebView *view)
     }
 }
 
+/**
+ * Give the focus to element.
+ */
+void dom_give_focus(Element *element)
+{
+    webkit_dom_element_focus(element);
+}
+
 /**
  * Find the first editable element and set the focus on it and enter input
  * mode.
index 892a2d8..03eaf37 100644 (file)
--- a/src/dom.h
+++ b/src/dom.h
@@ -35,6 +35,7 @@
 void dom_install_focus_blur_callbacks(Document *doc);
 void dom_check_auto_insert(Document *doc);
 void dom_clear_focus(WebKitWebView *view);
+void dom_give_focus(Element *element);
 gboolean dom_focus_input(Document *doc);
 gboolean dom_is_editable(Element *element);
 Element *dom_get_active_element(WebKitWebView *view);
index 00ca557..5292b4e 100644 (file)
@@ -155,7 +155,6 @@ VbResult input_open_editor(void)
 
     /* disable the active element */
     dom_editable_element_set_disable(active, true);
-    dom_clear_focus(vb.gui.webview);
 
     EditorData *data = g_slice_new0(EditorData);
     data->file    = file_path;
@@ -177,6 +176,7 @@ static void resume_editor(GPid pid, int status, EditorData *data)
         g_free(text);
     }
     dom_editable_element_set_disable(data->element, false);
+    dom_give_focus(data->element);
 
     g_unlink(data->file);
     g_free(data->file);