From 4b85b5299aa9fb0ab09652cee5ee78d8ffc891e4 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 20 May 2018 20:15:39 +0200 Subject: [PATCH] dnd: Remove GdkDragContext::commit_drag_status() vfunc The idea behind the vfunc doesn't work as status updates can happen asynchronously. A better solution needs to be found. --- gdk/gdkdnd.c | 36 ------------------------------------ gdk/gdkdndprivate.h | 3 --- gdk/gdkevents.c | 3 --- gdk/wayland/gdkdnd-wayland.c | 23 +++++++++-------------- 4 files changed, 9 insertions(+), 56 deletions(-) diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index 13267b7ffd..45c69f93b2 100644 --- a/gdk/gdkdnd.c +++ b/gdk/gdkdnd.c @@ -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 diff --git a/gdk/gdkdndprivate.h b/gdk/gdkdndprivate.h index 5bead8248c..923cef005e 100644 --- a/gdk/gdkdndprivate.h +++ b/gdk/gdkdndprivate.h @@ -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); diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 1aff65e143..ac3d400fdf 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -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; } /********************************************* diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c index 0cfebd6557..90058bef45 100644 --- a/gdk/wayland/gdkdnd-wayland.c +++ b/gdk/wayland/gdkdnd-wayland.c @@ -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