wayland: Store the current drag operation
authorBenjamin Otte <otte@redhat.com>
Thu, 31 May 2018 19:15:59 +0000 (21:15 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 18 Jun 2018 21:49:52 +0000 (23:49 +0200)
Use it to detect local drags when creating drop objects.

gdk/wayland/gdkdevice-wayland.c
gdk/wayland/gdkdnd-wayland.c
gdk/wayland/gdkdrop-wayland.c
gdk/wayland/gdkprivate-wayland.h

index cbcf86bddace4579c2172ba3cb07a492ef9a0850..585887dc078fa7c79c6a9279166d30808de8e4dc 100644 (file)
@@ -246,6 +246,7 @@ struct _GdkWaylandSeat
   GdkClipboard *clipboard;
   GdkClipboard *primary_clipboard;
   struct wl_data_device *data_device;
+  GdkDragContext *drag;
   GdkDrop *drop;
 
   /* Source/dest for non-local dnd */
@@ -1263,7 +1264,7 @@ data_device_enter (void                  *data,
   seat->pending_builder = NULL;
   seat->pending_offer = NULL;
 
-  seat->drop = gdk_wayland_drop_new (device, formats, dest_surface, offer, serial);
+  seat->drop = gdk_wayland_drop_new (device, seat->drag, formats, dest_surface, offer, serial);
 
   gdk_wayland_seat_discard_pending_offer (seat);
 
@@ -4597,6 +4598,7 @@ gdk_wayland_seat_finalize (GObject *object)
   gdk_wayland_pointer_data_finalize (&seat->pointer_info);
   /* FIXME: destroy data_device */
   g_clear_object (&seat->keyboard_settings);
+  g_clear_object (&seat->drag);
   g_clear_object (&seat->drop);
   g_clear_object (&seat->clipboard);
   g_clear_object (&seat->primary_clipboard);
@@ -5137,6 +5139,15 @@ gdk_wayland_seat_set_global_cursor (GdkSeat   *seat,
                                         NULL);
 }
 
+void
+gdk_wayland_seat_set_drag (GdkSeat        *seat,
+                           GdkDragContext *context)
+{
+  GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
+
+  g_set_object (&wayland_seat->drag, context);
+}
+
 struct wl_data_device *
 gdk_wayland_device_get_data_device (GdkDevice *gdk_device)
 {
index 3ff57f451d804d929e77e70993177709f9d033de..98c1b7a0c987ebe476b8fb6d99335d74ab52820c 100644 (file)
@@ -193,6 +193,9 @@ gdk_wayland_drag_context_drop_done (GdkDragContext *context,
                                     gboolean        success)
 {
   GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
+  GdkDevice *device = gdk_drag_context_get_device (context);
+
+  gdk_wayland_seat_set_drag (gdk_device_get_seat (device), context);
 
   if (success)
     {
@@ -387,9 +390,11 @@ _gdk_wayland_surface_drag_begin (GdkSurface          *surface,
 {
   GdkWaylandDragContext *context_wayland;
   GdkDragContext *context;
+  GdkSeat *seat;
   GdkWaylandDisplay *display_wayland;
 
   display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device));
+  seat = gdk_device_get_seat (device);
 
   context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
                                   "device", device,
@@ -411,13 +416,15 @@ _gdk_wayland_surface_drag_begin (GdkSurface          *surface,
                                   gdk_to_wl_actions (actions));
     }
 
+  gdk_wayland_seat_set_drag (seat, context);
+
   wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
                              context_wayland->data_source,
                              gdk_wayland_surface_get_wl_surface (surface),
                             context_wayland->dnd_wl_surface,
                              _gdk_wayland_display_get_serial (display_wayland));
 
-  gdk_seat_ungrab (gdk_device_get_seat (device));
+  gdk_seat_ungrab (seat);
 
   return context;
 }
index a73fa8be0029ca017e644e257ecd7e095bcf1ab6..09d6de5b4804707cddeef4699c10df10b57c469b 100644 (file)
@@ -261,6 +261,7 @@ gdk_wayland_drop_init (GdkWaylandDrop *drop)
 
 GdkDrop *
 gdk_wayland_drop_new (GdkDevice            *device,
+                      GdkDragContext       *drag,
                       GdkContentFormats    *formats,
                       GdkSurface           *surface,
                       struct wl_data_offer *offer,
@@ -271,6 +272,7 @@ gdk_wayland_drop_new (GdkDevice            *device,
 
   drop = g_object_new (GDK_TYPE_WAYLAND_DROP,
                        "device", device,
+                       "drag", drag,
                        "formats", formats,
                        "surface", surface,
                        NULL);
index 14dc4d4e5cd1990aa46353c3199f6ed1fa0d7689..c45d17fc3321ca41823b1f4ad02752361e64342f 100644 (file)
@@ -105,6 +105,7 @@ void            _gdk_wayland_surface_offset_next_wl_buffer (GdkSurface *surface,
                                                             int        x,
                                                             int        y);
 GdkDrop *        gdk_wayland_drop_new                      (GdkDevice             *device,
+                                                            GdkDragContext        *drag,
                                                             GdkContentFormats     *formats,
                                                             GdkSurface            *surface,
                                                             struct wl_data_offer  *offer,
@@ -192,6 +193,8 @@ struct gtk_surface1 * gdk_wayland_surface_get_gtk_surface (GdkSurface *surface);
 
 void gdk_wayland_seat_set_global_cursor (GdkSeat   *seat,
                                          GdkCursor *cursor);
+void gdk_wayland_seat_set_drag (GdkSeat        *seat,
+                                GdkDragContext *drag);
 
 struct wl_output *gdk_wayland_surface_get_wl_output (GdkSurface *surface);