summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2021-07-16 23:25:22 +0100
committerAntónio Fernandes <antoniojpfernandes@gmail.com>2022-03-19 16:48:54 +0000
commit9f36eaa6f4e7757b7cdf41a54cfc9f03eaa0ce89 (patch)
treee2be2d6605709b3877cfdfc8be755ece49c689cd
parent51594105bc59f6197e2b176b6c132a3ac8a156c0 (diff)
downloadnautilus-9f36eaa6f4e7757b7cdf41a54cfc9f03eaa0ce89.tar.gz
window-slot-dnd: Ignore data not received on hover
Sometimes, after having called gtk_drag_get_data() on ::drag-motion, we only get the data after ::drag-leave. This is fine if the ::drag-leave is followed by ::drag-drop. Otherwise, as ::drag-leave is responsible for cleanup, data arriving afterwards is leaking into the next time content is dragged hover the widget, even if the dragged content is no longer the same. Instead, keep track of the hover status and don't save data that's no longer relevant.
-rw-r--r--src/nautilus-window-slot-dnd.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nautilus-window-slot-dnd.c b/src/nautilus-window-slot-dnd.c
index ec0134e46..772a8bb88 100644
--- a/src/nautilus-window-slot-dnd.c
+++ b/src/nautilus-window-slot-dnd.c
@@ -36,6 +36,7 @@ typedef struct
gboolean have_data;
gboolean have_valid_data;
+ gboolean is_hover;
gboolean drop_occurred;
unsigned int info;
@@ -170,6 +171,8 @@ slot_proxy_drag_motion (GtkWidget *widget,
drag_info = user_data;
+ drag_info->is_hover = TRUE;
+
action = 0;
valid_text_drag = FALSE;
valid_xds_drag = FALSE;
@@ -335,6 +338,7 @@ slot_proxy_drag_leave (GtkWidget *widget,
drag_info = user_data;
+ drag_info->is_hover = FALSE;
gtk_drag_unhighlight (widget);
drag_info_clear (drag_info);
}
@@ -474,6 +478,13 @@ slot_proxy_drag_data_received (GtkWidget *widget,
g_assert (!drag_info->have_data);
drag_info->waiting_for_data = FALSE;
+ if (!drag_info->is_hover && !drag_info->drop_occurred)
+ {
+ /* Ignore data arriving after ::drag-leave, except if followed by
+ * ::drag-drop. */
+ return;
+ }
+
if (gtk_selection_data_get_length (data) < 0)
{
/* Data retrieval failed. */