wayland: Don't artificially prefer ASK
authorMatthias Clasen <mclasen@redhat.com>
Sat, 4 Jan 2020 16:07:54 +0000 (11:07 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 4 Jan 2020 17:51:32 +0000 (12:51 -0500)
We were always adding ASK to the list of possible
actions, and preferring it. This was causing the
ask cursor to show up when both the source and
the target support ASK, even though it is only
meant to happen if you hold the Alt modifier.

Instead, use one of the supported actions as
preferred action.

gdk/wayland/gdkdrop-wayland.c

index 2648660b4a898efc2e5e599cf9b7692f08181502..c0c82036ddd34fe93622f0165a380226f93930d1 100644 (file)
@@ -119,25 +119,27 @@ gdk_wayland_drop_commit_status (GdkWaylandDrop *wayland_drop,
                                 GdkDragAction   actions)
 {
   GdkDisplay *display;
-  uint32_t dnd_actions;
 
   display = gdk_drop_get_display (GDK_DROP (wayland_drop));
 
-  dnd_actions = gdk_to_wl_actions (actions);
-
   if (GDK_WAYLAND_DISPLAY (display)->data_device_manager_version >=
       WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION)
     {
-      if (gdk_drag_action_is_unique (actions))
-        {
-          wl_data_offer_set_actions (wayland_drop->offer, dnd_actions, dnd_actions);
-        }
+      uint32_t dnd_actions;
+      uint32_t preferred_action;
+
+      dnd_actions = gdk_to_wl_actions (actions);
+
+      if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
+        preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
+      else if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
+        preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
+      else if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
+        preferred_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
       else
-        {
-          wl_data_offer_set_actions (wayland_drop->offer,
-                                     dnd_actions | WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK,
-                                     WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK);
-        }
+        preferred_action = 0;
+
+      wl_data_offer_set_actions (wayland_drop->offer, dnd_actions, preferred_action);
     }
 
   gdk_wayland_drop_drop_set_status (wayland_drop, actions != 0);