Blame SOURCES/evolution-3.22.6-composer-dnd.patch

a00a81
diff -up evolution-3.22.6/composer/e-msg-composer.c.composer-dnd evolution-3.22.6/composer/e-msg-composer.c
a00a81
--- evolution-3.22.6/composer/e-msg-composer.c.composer-dnd	2017-04-13 14:06:08.863067766 +0200
a00a81
+++ evolution-3.22.6/composer/e-msg-composer.c	2017-04-13 14:06:08.878067765 +0200
a00a81
@@ -1867,6 +1867,16 @@ msg_composer_drag_drop_cb (GtkWidget *wi
a00a81
 }
a00a81
 
a00a81
 static void
a00a81
+msg_composer_drop_handled_cb (EContentEditor *cnt_editor,
a00a81
+                              EMsgComposer *composer)
a00a81
+{
a00a81
+	if (composer->priv->drag_data_received_handler_id != 0) {
a00a81
+		g_signal_handler_disconnect (cnt_editor, composer->priv->drag_data_received_handler_id);
a00a81
+		composer->priv->drag_data_received_handler_id = 0;
a00a81
+	}
a00a81
+}
a00a81
+
a00a81
+static void
a00a81
 msg_composer_drag_begin_cb (GtkWidget *widget,
a00a81
                             GdkDragContext *context,
a00a81
                             EMsgComposer *composer)
a00a81
@@ -2272,6 +2282,10 @@ msg_composer_constructed (GObject *objec
a00a81
 		G_CALLBACK (msg_composer_drag_begin_cb), composer);
a00a81
 
a00a81
 	g_signal_connect (
a00a81
+		cnt_editor, "drop-handled",
a00a81
+		G_CALLBACK (msg_composer_drop_handled_cb), composer);
a00a81
+
a00a81
+	g_signal_connect (
a00a81
 		composer->priv->gallery_icon_view, "drag-data-get",
a00a81
 		G_CALLBACK (msg_composer_gallery_drag_data_get), NULL);
a00a81
 
a00a81
diff -up evolution-3.22.6/e-util/e-content-editor.c.composer-dnd evolution-3.22.6/e-util/e-content-editor.c
a00a81
--- evolution-3.22.6/e-util/e-content-editor.c.composer-dnd	2016-11-30 20:06:07.000000000 +0100
a00a81
+++ evolution-3.22.6/e-util/e-content-editor.c	2017-04-13 14:06:08.878067765 +0200
a00a81
@@ -36,6 +36,7 @@ enum {
a00a81
 	CONTEXT_MENU_REQUESTED,
a00a81
 	FIND_DONE,
a00a81
 	REPLACE_ALL_DONE,
a00a81
+	DROP_HANDLED,
a00a81
 	LAST_SIGNAL
a00a81
 };
a00a81
 
a00a81
@@ -509,6 +510,20 @@ e_content_editor_default_init (EContentE
a00a81
 		NULL,
a00a81
 		G_TYPE_NONE, 1,
a00a81
 		G_TYPE_UINT);
a00a81
+
a00a81
+	/**
a00a81
+	 * EContentEditor:drop-handled
a00a81
+	 *
a00a81
+	 * Emitted when the content editor successfully handled the drop operation.
a00a81
+	 */
a00a81
+	signals[DROP_HANDLED] = g_signal_new (
a00a81
+		"drop-handled",
a00a81
+		E_TYPE_CONTENT_EDITOR,
a00a81
+		G_SIGNAL_RUN_LAST,
a00a81
+		G_STRUCT_OFFSET (EContentEditorInterface, drop_handled),
a00a81
+		NULL, NULL,
a00a81
+		NULL,
a00a81
+		G_TYPE_NONE, 0);
a00a81
 }
a00a81
 
a00a81
 ESpellChecker *
a00a81
@@ -3581,3 +3596,11 @@ e_content_editor_emit_replace_all_done (
a00a81
 
a00a81
 	g_signal_emit (editor, signals[REPLACE_ALL_DONE], 0, replaced_count);
a00a81
 }
a00a81
+
a00a81
+void
a00a81
+e_content_editor_emit_drop_handled (EContentEditor *editor)
a00a81
+{
a00a81
+	g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
a00a81
+
a00a81
+	g_signal_emit (editor, signals[DROP_HANDLED], 0);
a00a81
+}
a00a81
diff -up evolution-3.22.6/e-util/e-content-editor.h.composer-dnd evolution-3.22.6/e-util/e-content-editor.h
a00a81
--- evolution-3.22.6/e-util/e-content-editor.h.composer-dnd	2016-09-19 10:22:58.000000000 +0200
a00a81
+++ evolution-3.22.6/e-util/e-content-editor.h	2017-04-13 14:06:08.878067765 +0200
a00a81
@@ -437,6 +437,7 @@ struct _EContentEditorInterface {
a00a81
 							 guint match_count);
a00a81
 	void		(*replace_all_done)		(EContentEditor *editor,
a00a81
 							 guint replaced_count);
a00a81
+	void		(*drop_handled)			(EContentEditor *editor);
a00a81
 };
a00a81
 
a00a81
 /* Properties */
a00a81
@@ -1015,6 +1016,8 @@ void		e_content_editor_emit_find_done	(E
a00a81
 void		e_content_editor_emit_replace_all_done
a00a81
 						(EContentEditor *editor,
a00a81
 						 guint replaced_count);
a00a81
+void		e_content_editor_emit_drop_handled
a00a81
+						(EContentEditor *editor);
a00a81
 
a00a81
 G_END_DECLS
a00a81
 
a00a81
diff -up evolution-3.22.6/modules/webkit-editor/e-webkit-editor.c.composer-dnd evolution-3.22.6/modules/webkit-editor/e-webkit-editor.c
a00a81
--- evolution-3.22.6/modules/webkit-editor/e-webkit-editor.c.composer-dnd	2017-04-13 14:06:08.875067765 +0200
a00a81
+++ evolution-3.22.6/modules/webkit-editor/e-webkit-editor.c	2017-04-13 14:06:28.256067497 +0200
a00a81
@@ -5913,10 +5913,16 @@ webkit_editor_drag_data_received_cb (Gtk
a00a81
 	    info == E_DND_TARGET_TYPE_UTF8_STRING || info == E_DND_TARGET_TYPE_STRING ||
a00a81
 	    info == E_DND_TARGET_TYPE_TEXT_PLAIN || info == E_DND_TARGET_TYPE_TEXT_PLAIN_UTF8) {
a00a81
 		gdk_drag_status (context, gdk_drag_context_get_selected_action(context), time);
a00a81
-		GTK_WIDGET_CLASS (e_webkit_editor_parent_class)->drag_drop (widget, context, x, y, time);
a00a81
-		g_signal_stop_emission_by_name (widget, "drag-data-received");
a00a81
-		if (!is_move)
a00a81
-			webkit_editor_call_simple_extension_function (wk_editor, "DOMLastDropOperationDidCopy");
a00a81
+		if (!GTK_WIDGET_CLASS (e_webkit_editor_parent_class)->drag_drop (widget, context, x, y, time)) {
a00a81
+			g_warning ("Drop failed in WebKit");
a00a81
+			goto process_ourselves;
a00a81
+		} else {
a00a81
+			GTK_WIDGET_CLASS (e_webkit_editor_parent_class)->drag_leave(widget, context, time);
a00a81
+			g_signal_stop_emission_by_name (widget, "drag-data-received");
a00a81
+			if (!is_move)
a00a81
+				webkit_editor_call_simple_extension_function (wk_editor, "DOMLastDropOperationDidCopy");
a00a81
+			e_content_editor_emit_drop_handled (E_CONTENT_EDITOR (widget));
a00a81
+		}
a00a81
 		return;
a00a81
 	}
a00a81
 
a00a81
@@ -5926,6 +5932,7 @@ webkit_editor_drag_data_received_cb (Gtk
a00a81
 		gint list_len, len;
a00a81
 		gchar *text;
a00a81
 
a00a81
+ process_ourselves:
a00a81
 		data = gtk_selection_data_get_data (selection);
a00a81
 		length = gtk_selection_data_get_length (selection);
a00a81
 
a00a81
@@ -5949,10 +5956,21 @@ webkit_editor_drag_data_received_cb (Gtk
a00a81
 
a00a81
 		gtk_drag_finish (context, TRUE, is_move, time);
a00a81
 		g_signal_stop_emission_by_name (widget, "drag-data-received");
a00a81
+		e_content_editor_emit_drop_handled (E_CONTENT_EDITOR (widget));
a00a81
 		return;
a00a81
 	}
a00a81
 }
a00a81
 
a00a81
+static void
a00a81
+webkit_editor_drag_leave_cb (EWebKitEditor *wk_editor,
a00a81
+                             GdkDragContext *context,
a00a81
+                             guint time)
a00a81
+{
a00a81
+	/* Don't pass drag-leave to WebKit otherwise the drop won't be handled by it.
a00a81
+	 * We will emit it later when WebKit is expecting it. */
a00a81
+	g_signal_stop_emission_by_name (GTK_WIDGET (wk_editor), "drag-leave");
a00a81
+}
a00a81
+
a00a81
 static gboolean
a00a81
 webkit_editor_drag_drop_cb (EWebKitEditor *wk_editor,
a00a81
                             GdkDragContext *context,
a00a81
@@ -6255,6 +6273,10 @@ e_webkit_editor_init (EWebKitEditor *wk_
a00a81
 		G_CALLBACK (webkit_editor_drag_end_cb), NULL);
a00a81
 
a00a81
 	g_signal_connect (
a00a81
+		wk_editor, "drag-leave",
a00a81
+		G_CALLBACK (webkit_editor_drag_leave_cb), NULL);
a00a81
+
a00a81
+	g_signal_connect (
a00a81
 		wk_editor, "drag-drop",
a00a81
 		G_CALLBACK (webkit_editor_drag_drop_cb), NULL);
a00a81