dnd: Remove GdkDragContext::commit_drag_status() vfunc
authorBenjamin Otte <otte@redhat.com>
Sun, 20 May 2018 18:15:39 +0000 (20:15 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 18 Jun 2018 21:49:52 +0000 (23:49 +0200)
The idea behind the vfunc doesn't work as status updates can happen
asynchronously.

A better solution needs to be found.

gdk/gdkdnd.c
gdk/gdkdndprivate.h
gdk/gdkevents.c
gdk/wayland/gdkdnd-wayland.c

index 13267b7ffdfa3bff0f9397b19d02ba3d546a5dc7..45c69f93b23159fd46451da0865fefeb6e2c77e9 100644 (file)
@@ -864,42 +864,6 @@ gdk_drag_get_cursor (GdkDragContext *context,
   return drag_cursors[i].cursor;
 }
 
-static void
-gdk_drag_context_commit_drag_status (GdkDragContext *context)
-{
-  GdkDragContextClass *context_class;
-
-  g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
-  g_return_if_fail (!context->is_source);
-
-  context_class = GDK_DRAG_CONTEXT_GET_CLASS (context);
-
-  if (context_class->commit_drag_status)
-    context_class->commit_drag_status (context);
-}
-
-gboolean
-gdk_drag_context_handle_dest_event (GdkEvent *event)
-{
-  GdkDragContext *context = NULL;
-
-  switch ((guint) event->any.type)
-    {
-    case GDK_DRAG_MOTION:
-    case GDK_DROP_START:
-      context = event->dnd.context;
-      break;
-    default:
-      return FALSE;
-    }
-
-  if (!context)
-    return FALSE;
-
-  gdk_drag_context_commit_drag_status (context);
-  return TRUE;;
-}
-
 /**
  * gdk_drag_action_is_unique:
  * @action: a #GdkDragAction
index 5bead8248c2a5b8bc151ff4c2ec48e53d50c267c..923cef005e5c4c1fc0bd2cacd0184105cc294252 100644 (file)
@@ -58,8 +58,6 @@ struct _GdkDragContextClass {
                                  const GdkEvent  *event);
   void        (*action_changed) (GdkDragContext  *context,
                                  GdkDragAction    action);
-
-  void        (*commit_drag_status) (GdkDragContext  *context);
 };
 
 struct _GdkDragContext {
@@ -86,7 +84,6 @@ void     gdk_drag_context_set_actions         (GdkDragContext *context,
 void     gdk_drag_context_cancel              (GdkDragContext      *context,
                                                GdkDragCancelReason  reason);
 gboolean gdk_drag_context_handle_source_event (GdkEvent *event);
-gboolean gdk_drag_context_handle_dest_event   (GdkEvent *event);
 GdkCursor * gdk_drag_get_cursor               (GdkDragContext *context,
                                                GdkDragAction   action);
 
index 1aff65e14334f809da289af816632da76809f14f..ac3d400fdf504d492e256e4e7e57e7e34b5fba0e 100644 (file)
@@ -169,9 +169,6 @@ _gdk_event_emit (GdkEvent *event)
 
   if (_gdk_event_func)
     (*_gdk_event_func) (event, _gdk_event_data);
-
-  if (gdk_drag_context_handle_dest_event (event))
-    return;
 }
 
 /*********************************************
index 0cfebd6557b790d00311f518f50e36bde0399cff..90058bef45ebc7c42dc3b9f6236ba094388421be 100644 (file)
@@ -161,20 +161,15 @@ gdk_wayland_drag_context_drag_drop (GdkDragContext *context,
 /* Destination side */
 
 static void
-gdk_wayland_drop_context_set_status (GdkDragContext *context,
-                                     gboolean        accepted)
+gdk_wayland_drop_context_set_status (GdkWaylandDragContext *context_wayland,
+                                     gboolean               accepted)
 {
-  GdkWaylandDragContext *context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context);
-
-  if (!context->dest_surface)
-    return;
-
   if (accepted)
     {
       const char *const *mimetypes;
       gsize i, n_mimetypes;
       
-      mimetypes = gdk_content_formats_get_mime_types (gdk_drag_context_get_formats (context), &n_mimetypes);
+      mimetypes = gdk_content_formats_get_mime_types (gdk_drop_get_formats (GDK_DROP (context_wayland)), &n_mimetypes);
       for (i = 0; i < n_mimetypes; i++)
         {
           if (mimetypes[i] != g_intern_static_string ("DELETE"))
@@ -192,13 +187,12 @@ gdk_wayland_drop_context_set_status (GdkDragContext *context,
 }
 
 static void
-gdk_wayland_drag_context_commit_status (GdkDragContext *context)
+gdk_wayland_drag_context_commit_status (GdkWaylandDragContext *wayland_context)
 {
-  GdkWaylandDragContext *wayland_context = GDK_WAYLAND_DRAG_CONTEXT (context);
   GdkDisplay *display;
   uint32_t dnd_actions, all_actions = 0;
 
-  display = gdk_device_get_display (gdk_drag_context_get_device (context));
+  display = gdk_drop_get_display (GDK_DROP (wayland_context));
 
   dnd_actions = gdk_to_wl_actions (wayland_context->selected_action);
 
@@ -211,7 +205,7 @@ gdk_wayland_drag_context_commit_status (GdkDragContext *context)
       WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION)
     wl_data_offer_set_actions (wayland_context->offer, all_actions, dnd_actions);
 
-  gdk_wayland_drop_context_set_status (context, wayland_context->selected_action != 0);
+  gdk_wayland_drop_context_set_status (wayland_context, wayland_context->selected_action != 0);
 }
 
 static void
@@ -222,6 +216,8 @@ gdk_wayland_drag_context_status (GdkDrop       *drop,
 
   wayland_context = GDK_WAYLAND_DRAG_CONTEXT (drop);
   wayland_context->selected_action = action;
+
+  gdk_wayland_drag_context_commit_status (wayland_context);
 }
 
 static void
@@ -234,7 +230,7 @@ gdk_wayland_drag_context_finish (GdkDrop       *drop,
 
   if (action)
     {
-      gdk_wayland_drag_context_commit_status (GDK_DRAG_CONTEXT (drop));
+      gdk_wayland_drag_context_commit_status (wayland_context);
 
       if (display_wayland->data_device_manager_version >=
           WL_DATA_OFFER_FINISH_SINCE_VERSION)
@@ -414,7 +410,6 @@ gdk_wayland_drag_context_class_init (GdkWaylandDragContextClass *klass)
   context_class->action_changed = gdk_wayland_drag_context_action_changed;
   context_class->drop_performed = gdk_wayland_drag_context_drop_performed;
   context_class->cancel = gdk_wayland_drag_context_cancel;
-  context_class->commit_drag_status = gdk_wayland_drag_context_commit_status;
 }
 
 void