wayland: Use new DND event emitters

This commit is contained in:
Benjamin Otte 2018-05-23 20:11:28 +02:00
parent 657ebd2a78
commit 114ab8775a
3 changed files with 26 additions and 76 deletions

View File

@ -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

View File

@ -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)

View File

@ -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);