From: Benjamin Otte Date: Wed, 23 May 2018 18:11:28 +0000 (+0200) Subject: wayland: Use new DND event emitters X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~22^2~109 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=114ab8775a8cd78e87f01162d8277e723f8f1eb8;p=gtk4.git wayland: Use new DND event emitters --- diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 08a936e739..90093445ac 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -1158,8 +1158,11 @@ data_offer_source_actions (void *data, gdk_wayland_actions_to_gdk_actions (source_actions), gdk_drag_context_get_suggested_action (drop_context)); - _gdk_wayland_drag_context_emit_event (drop_context, GDK_DRAG_MOTION, - GDK_CURRENT_TIME); + gdk_drop_emit_motion_event (GDK_DROP (seat->drop_context), + FALSE, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, + GDK_CURRENT_TIME); } static void @@ -1186,8 +1189,11 @@ data_offer_action (void *data, gdk_drag_context_get_actions (drop_context), gdk_wayland_actions_to_gdk_actions (action)); - _gdk_wayland_drag_context_emit_event (drop_context, GDK_DRAG_MOTION, - GDK_CURRENT_TIME); + gdk_drop_emit_motion_event (GDK_DROP (seat->drop_context), + FALSE, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, + GDK_CURRENT_TIME); } static const struct wl_data_offer_listener data_offer_listener = { @@ -1275,14 +1281,11 @@ data_device_enter (void *data, _gdk_wayland_drag_context_set_source_surface (seat->drop_context, dnd_owner); - _gdk_wayland_drag_context_set_coords (seat->drop_context, - wl_fixed_to_double (x), - wl_fixed_to_double (y)); - gdk_wayland_seat_discard_pending_offer (seat); - _gdk_wayland_drag_context_emit_event (seat->drop_context, GDK_DRAG_ENTER, - GDK_CURRENT_TIME); + gdk_drop_emit_enter_event (GDK_DROP (seat->drop_context), + FALSE, + GDK_CURRENT_TIME); } static void @@ -1300,9 +1303,9 @@ data_device_leave (void *data, g_object_unref (seat->pointer_info.focus); seat->pointer_info.focus = NULL; - _gdk_wayland_drag_context_set_coords (seat->drop_context, -1, -1); - _gdk_wayland_drag_context_emit_event (seat->drop_context, GDK_DRAG_LEAVE, - GDK_CURRENT_TIME); + gdk_drop_emit_leave_event (GDK_DROP (seat->drop_context), + FALSE, + GDK_CURRENT_TIME); g_clear_object (&seat->drop_context); } @@ -1327,11 +1330,11 @@ data_device_motion (void *data, seat->pointer_info.surface_x = wl_fixed_to_double (x); seat->pointer_info.surface_y = wl_fixed_to_double (y); - _gdk_wayland_drag_context_set_coords (seat->drop_context, - wl_fixed_to_double (x), - wl_fixed_to_double (y)); - _gdk_wayland_drag_context_emit_event (seat->drop_context, - GDK_DRAG_MOTION, time); + gdk_drop_emit_motion_event (GDK_DROP (seat->drop_context), + FALSE, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, + time); } static void @@ -1343,8 +1346,11 @@ data_device_drop (void *data, GDK_DISPLAY_NOTE (seat->display, EVENTS, g_message ("data device drop, data device %p", data_device)); - _gdk_wayland_drag_context_emit_event (seat->drop_context, - GDK_DROP_START, GDK_CURRENT_TIME); + gdk_drop_emit_drop_event (GDK_DROP (seat->drop_context), + FALSE, + seat->pointer_info.surface_x, + seat->pointer_info.surface_y, + GDK_CURRENT_TIME); } static void diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c index 52ad3e3142..b93a95bbc1 100644 --- a/gdk/wayland/gdkdnd-wayland.c +++ b/gdk/wayland/gdkdnd-wayland.c @@ -53,8 +53,6 @@ struct _GdkWaylandDragContext struct wl_data_offer *offer; GdkDragAction selected_action; uint32_t serial; - gdouble x; - gdouble y; gint hot_x; gint hot_y; }; @@ -95,42 +93,6 @@ gdk_wayland_drag_context_finalize (GObject *object) gdk_surface_destroy (dnd_surface); } -void -_gdk_wayland_drag_context_emit_event (GdkDragContext *context, - GdkEventType type, - guint32 time_) -{ - GdkSurface *surface; - GdkEvent *event; - - switch ((guint) type) - { - case GDK_DRAG_ENTER: - case GDK_DRAG_LEAVE: - case GDK_DRAG_MOTION: - case GDK_DROP_START: - break; - default: - return; - } - - if (context->is_source) - surface = gdk_drag_context_get_source_surface (context); - else - surface = gdk_drop_get_surface (GDK_DROP (context)); - - event = gdk_event_new (type); - event->any.surface = g_object_ref (surface); - event->dnd.context = g_object_ref (context); - event->dnd.time = time_; - event->dnd.x_root = GDK_WAYLAND_DRAG_CONTEXT (context)->x; - event->dnd.y_root = GDK_WAYLAND_DRAG_CONTEXT (context)->y; - gdk_event_set_device (event, gdk_drag_context_get_device (context)); - - gdk_display_put_event (gdk_surface_get_display (surface), event); - g_object_unref (event); -} - static inline uint32_t gdk_to_wl_actions (GdkDragAction action) { @@ -515,18 +477,6 @@ _gdk_wayland_drop_context_new (GdkDevice *device, return context; } -void -_gdk_wayland_drag_context_set_coords (GdkDragContext *context, - gdouble x, - gdouble y) -{ - GdkWaylandDragContext *context_wayland; - - context_wayland = GDK_WAYLAND_DRAG_CONTEXT (context); - context_wayland->x = x; - context_wayland->y = y; -} - void _gdk_wayland_drag_context_set_source_surface (GdkDragContext *context, GdkSurface *surface) diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h index dfeca6dce4..6c4471e145 100644 --- a/gdk/wayland/gdkprivate-wayland.h +++ b/gdk/wayland/gdkprivate-wayland.h @@ -111,12 +111,6 @@ GdkDragContext * _gdk_wayland_drop_context_new (GdkDevice *device, uint32_t serial); void _gdk_wayland_drag_context_set_source_surface (GdkDragContext *context, GdkSurface *surface); -void _gdk_wayland_drag_context_emit_event (GdkDragContext *context, - GdkEventType type, - guint32 time_); -void _gdk_wayland_drag_context_set_coords (GdkDragContext *context, - gdouble x, - gdouble y); GdkDragContext * gdk_wayland_drag_context_lookup_by_data_source (struct wl_data_source *source); GdkDragContext * gdk_wayland_drag_context_lookup_by_source_surface (GdkSurface *surface);