[evolution/wip/webkit2] Bug 724651 - Undo, redo implementation broke input methods
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] Bug 724651 - Undo, redo implementation broke input methods
- Date: Wed, 22 Apr 2015 13:18:28 +0000 (UTC)
commit 8d116d3c026ba72c3a53cd4bb840a5cdd517661f
Author: Tomas Popela <tpopela redhat com>
Date: Wed Apr 22 14:39:48 2015 +0200
Bug 724651 - Undo, redo implementation broke input methods
When using input methods to type characters in composer we have to
save just the final character when the its editing ends.
e-util/e-html-editor-view.c | 29 +++++++++++++++-
web-extensions/e-html-editor-view-dom-functions.c | 26 ++++++++------
web-extensions/e-html-editor-view-dom-functions.h | 8 ++++
web-extensions/e-html-editor-web-extension.c | 38 +++++++++++++++++++++
web-extensions/e-html-editor-web-extension.h | 3 ++
5 files changed, 91 insertions(+), 13 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 81dd55f..ed3629d 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -1566,12 +1566,30 @@ html_editor_view_drag_end_cb (EHTMLEditorView *view,
}
static void
+im_context_preedit_start_cb (GtkIMContext *context,
+ EHTMLEditorView *view)
+{
+ e_html_editor_view_call_simple_extension_function_sync (
+ view, "DOMIMContextPreEditStart");
+}
+
+static void
+im_context_preedit_end_cb (GtkIMContext *context,
+ EHTMLEditorView *view)
+{
+ e_html_editor_view_call_simple_extension_function_sync (
+ view, "DOMIMContextPreEditEnd");
+}
+
+static void
e_html_editor_view_init (EHTMLEditorView *view)
{
WebKitSettings *settings;
GSettings *g_settings;
GSettingsSchema *settings_schema;
-// ESpellChecker *checker;
+/* FIXME WK2
+ GtkIMContext *im_context;
+ ESpellChecker *checker;*/
gchar **languages;
gchar *comma_separated;
@@ -1661,6 +1679,15 @@ e_html_editor_view_init (EHTMLEditorView *view)
view->priv->is_message_from_edit_as_new = FALSE;
view->priv->remove_initial_input_line = FALSE;
view->priv->convert_in_situ = FALSE;
+
+/* FIXME WK2
+ g_object_get (WEBKIT_WEB_VIEW (view), "im-context", &im_context, NULL);
+ g_signal_connect (
+ im_context, "preedit-start",
+ G_CALLBACK (im_context_preedit_start_cb), view);
+ g_signal_connect (
+ im_context, "preedit-end",
+ G_CALLBACK (im_context_preedit_end_cb), view);*/
}
void
diff --git a/web-extensions/e-html-editor-view-dom-functions.c
b/web-extensions/e-html-editor-view-dom-functions.c
index e7612c6..642d9b1 100644
--- a/web-extensions/e-html-editor-view-dom-functions.c
+++ b/web-extensions/e-html-editor-view-dom-functions.c
@@ -2185,9 +2185,9 @@ body_input_event_cb (WebKitDOMElement *element,
}
}
-static void
-remove_input_event_listener_from_body (WebKitDOMDocument *document,
- EHTMLEditorWebExtension *extension)
+void
+dom_remove_input_event_listener_from_body (WebKitDOMDocument *document,
+ EHTMLEditorWebExtension *extension)
{
if (!e_html_editor_web_extension_get_body_input_event_removed (extension)) {
webkit_dom_event_target_remove_event_listener (
@@ -2201,9 +2201,9 @@ remove_input_event_listener_from_body (WebKitDOMDocument *document,
}
}
-static void
-register_input_event_listener_on_body (WebKitDOMDocument *document,
- EHTMLEditorWebExtension *extension)
+void
+dom_register_input_event_listener_on_body (WebKitDOMDocument *document,
+ EHTMLEditorWebExtension *extension)
{
if (e_html_editor_web_extension_get_body_input_event_removed (extension)) {
webkit_dom_event_target_add_event_listener (
@@ -2282,7 +2282,9 @@ body_keyup_event_cb (WebKitDOMElement *element,
WebKitDOMDocument *document;
document = webkit_dom_node_get_owner_document (WEBKIT_DOM_NODE (element));
- register_input_event_listener_on_body (document, extension);
+ if (!e_html_editor_web_extension_is_im_input_in_progress (extension))
+ dom_register_input_event_listener_on_body (document, extension);
+
if (!dom_selection_is_collapsed (document))
return;
@@ -4337,7 +4339,7 @@ dom_convert_and_insert_html_into_selection (WebKitDOMDocument *document,
WebKitDOMElement *selection_start_marker, *selection_end_marker, *element;
WebKitDOMNode *node, *current_block;
- remove_input_event_listener_from_body (document, extension);
+ dom_remove_input_event_listener_from_body (document, extension);
dom_selection_save (document);
selection_start_marker = webkit_dom_document_get_element_by_id (
@@ -4724,7 +4726,7 @@ dom_convert_and_insert_html_into_selection (WebKitDOMDocument *document,
dom_force_spell_check (document, extension);
dom_scroll_to_caret (document);
- register_input_event_listener_on_body (document, extension);
+ dom_register_input_event_listener_on_body (document, extension);
}
static gint
@@ -6452,7 +6454,7 @@ dom_process_content_after_load (WebKitDOMDocument *document,
}
/* Register on input event that is called when the content (body) is modified */
- register_input_event_listener_on_body (document, extension);
+ dom_register_input_event_listener_on_body (document, extension);
register_html_events_handlers (body, extension);
if (e_html_editor_web_extension_get_html_mode (extension))
@@ -7199,7 +7201,7 @@ dom_process_on_key_press (WebKitDOMDocument *document,
* not break the citation automatically, so we need to use
* the special command to do it. */
if (dom_selection_is_citation (document)) {
- remove_input_event_listener_from_body (document, extension);
+ dom_remove_input_event_listener_from_body (document, extension);
return split_citation (document, extension);
}
@@ -7224,7 +7226,7 @@ dom_process_on_key_press (WebKitDOMDocument *document,
}
dom_selection_restore (document);
} else
- remove_input_event_listener_from_body (document, extension);
+ dom_remove_input_event_listener_from_body (document, extension);
/* BackSpace in indented block decrease indent level by one */
if (dom_selection_is_indented (document) &&
diff --git a/web-extensions/e-html-editor-view-dom-functions.h
b/web-extensions/e-html-editor-view-dom-functions.h
index d0e4960..f931785 100644
--- a/web-extensions/e-html-editor-view-dom-functions.h
+++ b/web-extensions/e-html-editor-view-dom-functions.h
@@ -47,6 +47,14 @@ void dom_embed_style_sheet (WebKitDOMDocument *document,
void dom_remove_embed_style_sheet (WebKitDOMDocument *document);
+void dom_register_input_event_listener_on_body
+ (WebKitDOMDocument *document,
+ EHTMLEditorWebExtension *extension);
+
+void dom_remove_input_event_listener_from_body
+ (WebKitDOMDocument *document,
+ EHTMLEditorWebExtension *extension);
+
void dom_quote_and_insert_text_into_selection
(WebKitDOMDocument *document,
EHTMLEditorWebExtension *extension,
diff --git a/web-extensions/e-html-editor-web-extension.c b/web-extensions/e-html-editor-web-extension.c
index e5c065c..9847bdd 100644
--- a/web-extensions/e-html-editor-web-extension.c
+++ b/web-extensions/e-html-editor-web-extension.c
@@ -93,6 +93,7 @@ struct _EHTMLEditorWebExtensionPrivate {
gboolean is_message_from_selection;
gboolean remove_initial_input_line;
gboolean dont_save_history_in_body_input;
+ gboolean im_input_in_progress;
GHashTable *inline_images;
@@ -534,6 +535,12 @@ static const char introspection_xml[] =
" <arg type='i' name='y' direction='in'/>"
" <arg type='b' name='cancel_if_not_collapsed' direction='in'/>"
" </method>"
+" <method name='DOMIMContextPreEditStart'>"
+" <arg type='t' name='page_id' direction='in'/>"
+" </method>"
+" <method name='DOMIMContextPreEditEnd'>"
+" <arg type='t' name='page_id' direction='in'/>"
+" </method>"
"<!-- ********************************************************* -->"
"<!-- Functions that are used in EHTMLEditorSelection -->"
"<!-- ********************************************************* -->"
@@ -1885,6 +1892,30 @@ handle_method_call (GDBusConnection *connection,
document = webkit_web_page_get_dom_document (web_page);
dom_drag_and_drop_end (document, extension);
g_dbus_method_invocation_return_value (invocation, NULL);
+ } else if (g_strcmp0 (method_name, "DOMIMContextPreEditStart") == 0) {
+ g_variant_get (parameters, "(t)", &page_id);
+
+ web_page = get_webkit_web_page_or_return_dbus_error (
+ invocation, web_extension, page_id);
+ if (!web_page)
+ return;
+
+ extension->priv->im_input_in_progress = TRUE;
+ document = webkit_web_page_get_dom_document (web_page);
+ dom_remove_input_event_listener_from_body (document, extension);
+ g_dbus_method_invocation_return_value (invocation, NULL);
+ } else if (g_strcmp0 (method_name, "DOMIMContextPreEditEnd") == 0) {
+ g_variant_get (parameters, "(t)", &page_id);
+
+ web_page = get_webkit_web_page_or_return_dbus_error (
+ invocation, web_extension, page_id);
+ if (!web_page)
+ return;
+
+ extension->priv->im_input_in_progress = FALSE;
+ document = webkit_web_page_get_dom_document (web_page);
+ dom_register_input_event_listener_on_body (document, extension);
+ g_dbus_method_invocation_return_value (invocation, NULL);
} else if (g_strcmp0 (method_name, "DOMMoveSelectionOnPoint") == 0) {
gboolean cancel_if_not_collapsed;
gint x, y;
@@ -2546,6 +2577,7 @@ e_html_editor_web_extension_init (EHTMLEditorWebExtension *extension)
extension->priv->is_message_from_selection = FALSE;
extension->priv->remove_initial_input_line = FALSE;
extension->priv->dont_save_history_in_body_input = FALSE;
+ extension->priv->im_input_in_progress = FALSE;
extension->priv->node_under_mouse_click = NULL;
@@ -3076,3 +3108,9 @@ e_html_editor_web_extension_get_undo_redo_manager (EHTMLEditorWebExtension *exte
return extension->priv->undo_redo_manager;
}
+
+gboolean
+e_html_editor_web_extension_is_im_input_in_progress (EHTMLEditorWebExtension *extension)
+{
+ return extension->priv->im_input_in_progress;
+}
diff --git a/web-extensions/e-html-editor-web-extension.h b/web-extensions/e-html-editor-web-extension.h
index 45a6d6f..8c0e42a 100644
--- a/web-extensions/e-html-editor-web-extension.h
+++ b/web-extensions/e-html-editor-web-extension.h
@@ -200,4 +200,7 @@ void e_html_editor_web_extension_set_dont_save_history_in_body_input
struct _EHTMLEditorUndoRedoManager *
e_html_editor_web_extension_get_undo_redo_manager
(EHTMLEditorWebExtension *extension);
+
+gboolean e_html_editor_web_extension_is_im_input_in_progress
+ (EHTMLEditorWebExtension *extension);
#endif /* E_HTML_EDITOR_WEB_EXTENSION_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]