[evolution] Dropping text/* content to the editor is not handled by WebKit
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Dropping text/* content to the editor is not handled by WebKit
- Date: Thu, 13 Apr 2017 07:13:47 +0000 (UTC)
commit aba471941b94ff926930d7586f7567bdfae9fd6c
Author: Tomas Popela <tpopela redhat com>
Date: Wed Apr 12 10:54:33 2017 +0200
Dropping text/* content to the editor is not handled by WebKit
The problem was that the WebKit failed to process the drag-drop signal as
it internally failed to found its corresponding object to the
GdkDragContext that was passed to it. The problem was that the
corresponding object was removed when the drag-leave signal was
processed by WebKit as it internally tries to postpone the drag-leave
signal after the drag-drop is processed. As a solution we need to
connect to the drag-leave signal, stop its emission and emit at after
the drag-drop.
In case where the drop is not handled by WebKit warn to the console (as
this is not supposed to happen) and try to handle the drop ourselves.
src/modules/webkit-editor/e-webkit-editor.c | 30 ++++++++++++++++++++++----
1 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index c907a8a..92f6751 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -5912,11 +5912,16 @@ webkit_editor_drag_data_received_cb (GtkWidget *widget,
info == E_DND_TARGET_TYPE_UTF8_STRING || info == E_DND_TARGET_TYPE_STRING ||
info == E_DND_TARGET_TYPE_TEXT_PLAIN || info == E_DND_TARGET_TYPE_TEXT_PLAIN_UTF8) {
gdk_drag_status (context, gdk_drag_context_get_selected_action(context), time);
- GTK_WIDGET_CLASS (e_webkit_editor_parent_class)->drag_drop (widget, context, x, y, time);
- g_signal_stop_emission_by_name (widget, "drag-data-received");
- if (!is_move)
- webkit_editor_call_simple_extension_function (wk_editor,
"DOMLastDropOperationDidCopy");
- e_content_editor_emit_drop_handled (E_CONTENT_EDITOR (widget));
+ if (!GTK_WIDGET_CLASS (e_webkit_editor_parent_class)->drag_drop (widget, context, x, y,
time)) {
+ g_warning ("Drop failed in WebKit");
+ goto process_ourselves;
+ } else {
+ GTK_WIDGET_CLASS (e_webkit_editor_parent_class)->drag_leave(widget, context, time);
+ g_signal_stop_emission_by_name (widget, "drag-data-received");
+ if (!is_move)
+ webkit_editor_call_simple_extension_function (wk_editor,
"DOMLastDropOperationDidCopy");
+ e_content_editor_emit_drop_handled (E_CONTENT_EDITOR (widget));
+ }
return;
}
@@ -5926,6 +5931,7 @@ webkit_editor_drag_data_received_cb (GtkWidget *widget,
gint list_len, len;
gchar *text;
+ process_ourselves:
data = gtk_selection_data_get_data (selection);
length = gtk_selection_data_get_length (selection);
@@ -5954,6 +5960,16 @@ webkit_editor_drag_data_received_cb (GtkWidget *widget,
}
}
+static void
+webkit_editor_drag_leave_cb (EWebKitEditor *wk_editor,
+ GdkDragContext *context,
+ guint time)
+{
+ /* Don't pass drag-leave to WebKit otherwise the drop won't be handled by it.
+ * We will emit it later when WebKit is expecting it. */
+ g_signal_stop_emission_by_name (GTK_WIDGET (wk_editor), "drag-leave");
+}
+
static gboolean
webkit_editor_drag_drop_cb (EWebKitEditor *wk_editor,
GdkDragContext *context,
@@ -6283,6 +6299,10 @@ e_webkit_editor_init (EWebKitEditor *wk_editor)
G_CALLBACK (webkit_editor_drag_end_cb), NULL);
g_signal_connect (
+ wk_editor, "drag-leave",
+ G_CALLBACK (webkit_editor_drag_leave_cb), NULL);
+
+ g_signal_connect (
wk_editor, "drag-drop",
G_CALLBACK (webkit_editor_drag_drop_cb), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]