[gtk/gtk-4-6: 3/5] droptarget: Provide a unique action for gdk_drop_finish




commit a730012006696ce015d67315a2c00a44a9a18a46
Author: Mat <mail mathias is>
Date:   Sun Jul 17 19:11:34 2022 +0300

    droptarget: Provide a unique action for gdk_drop_finish
    
    gdk_drop_finish() requires a unique drop action. Reuse the existing
    make_action_unique() function to get one.
    
    Fixes #5051

 gtk/gtkdroptarget.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkdroptarget.c b/gtk/gtkdroptarget.c
index 477f167580..e249198f39 100644
--- a/gtk/gtkdroptarget.c
+++ b/gtk/gtkdroptarget.c
@@ -208,6 +208,21 @@ gtk_drop_target_end_drop (GtkDropTarget *self)
   g_object_thaw_notify (G_OBJECT (self));
 }
 
+static GdkDragAction
+make_action_unique (GdkDragAction actions)
+{
+  if (actions & GDK_ACTION_COPY)
+    return GDK_ACTION_COPY;
+
+  if (actions & GDK_ACTION_MOVE)
+    return GDK_ACTION_MOVE;
+
+  if (actions & GDK_ACTION_LINK)
+    return GDK_ACTION_LINK;
+
+  return 0;
+}
+
 static void
 gtk_drop_target_do_drop (GtkDropTarget *self)
 {
@@ -219,7 +234,7 @@ gtk_drop_target_do_drop (GtkDropTarget *self)
   g_signal_emit (self, signals[DROP], 0, &self->value, self->coords.x, self->coords.y, &success);
 
   if (success)
-    gdk_drop_finish (self->drop, gdk_drop_get_actions (self->drop));
+    gdk_drop_finish (self->drop, make_action_unique (self->actions & gdk_drop_get_actions (self->drop)));
   else
     gdk_drop_finish (self->drop, 0);
 
@@ -348,21 +363,6 @@ gtk_drop_target_accept (GtkDropTarget *self,
   return gdk_content_formats_match_gtype (self->formats, gdk_drop_get_formats (drop)) != G_TYPE_INVALID;
 }
 
-static GdkDragAction
-make_action_unique (GdkDragAction actions)
-{
-  if (actions & GDK_ACTION_COPY)
-    return GDK_ACTION_COPY;
-
-  if (actions & GDK_ACTION_MOVE)
-    return GDK_ACTION_MOVE;
-
-  if (actions & GDK_ACTION_LINK)
-    return GDK_ACTION_LINK;
-
-  return 0;
-}
-
 static GdkDragAction
 gtk_drop_target_enter (GtkDropTarget  *self,
                        double          x,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]