wayland: Fix drop operations for new semantics
authorBenjamin Otte <otte@redhat.com>
Sun, 20 May 2018 18:22:02 +0000 (20:22 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 18 Jun 2018 21:49:52 +0000 (23:49 +0200)
gdk/wayland/gdkdnd-wayland.c

index 90058bef45ebc7c42dc3b9f6236ba094388421be..ea3159f64a315da09e43e56fd694a8030af0334f 100644 (file)
@@ -190,20 +190,26 @@ static void
 gdk_wayland_drag_context_commit_status (GdkWaylandDragContext *wayland_context)
 {
   GdkDisplay *display;
-  uint32_t dnd_actions, all_actions = 0;
+  uint32_t dnd_actions;
 
   display = gdk_drop_get_display (GDK_DROP (wayland_context));
 
   dnd_actions = gdk_to_wl_actions (wayland_context->selected_action);
 
-  if (dnd_actions != 0)
-    all_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY |
-      WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE |
-      WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
-
   if (GDK_WAYLAND_DISPLAY (display)->data_device_manager_version >=
       WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION)
-    wl_data_offer_set_actions (wayland_context->offer, all_actions, dnd_actions);
+    {
+      if (gdk_drag_action_is_unique (wayland_context->selected_action))
+        {
+          wl_data_offer_set_actions (wayland_context->offer, dnd_actions, dnd_actions);
+        }
+      else
+        {
+          wl_data_offer_set_actions (wayland_context->offer,
+                                     dnd_actions | WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK,
+                                     WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK);
+        }
+    }
 
   gdk_wayland_drop_context_set_status (wayland_context, wayland_context->selected_action != 0);
 }
@@ -228,6 +234,8 @@ gdk_wayland_drag_context_finish (GdkDrop       *drop,
   GdkDisplay *display = gdk_drop_get_display (drop);
   GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
 
+  wayland_context->selected_action = action;
+
   if (action)
     {
       gdk_wayland_drag_context_commit_status (wayland_context);