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

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