Merge branch 'fix-dnd' into 'master'

Fix dnd

See merge request GNOME/gtk!1273
This commit is contained in:
Matthias Clasen 2019-12-30 17:12:30 +00:00
commit 49c6e99970
4 changed files with 30 additions and 5 deletions

View File

@ -938,6 +938,9 @@ gdk_drop_emit_motion_event (GdkDrop *self,
{
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
GdkEvent *event;
int x, y;
gdk_surface_get_origin (priv->surface, &x, &y);
event = gdk_event_new (GDK_DRAG_MOTION);
event->any.surface = g_object_ref (priv->surface);
@ -945,6 +948,8 @@ gdk_drop_emit_motion_event (GdkDrop *self,
event->dnd.time = time;
event->dnd.x_root = x_root;
event->dnd.y_root = y_root;
event->dnd.x = x_root - x;
event->dnd.y = y_root - y;
gdk_event_set_device (event, priv->device);
gdk_drop_do_emit_event (event, dont_queue);
@ -976,6 +981,9 @@ gdk_drop_emit_drop_event (GdkDrop *self,
{
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
GdkEvent *event;
int x, y;
gdk_surface_get_origin (priv->surface, &x, &y);
event = gdk_event_new (GDK_DROP_START);
event->any.surface = g_object_ref (priv->surface);
@ -983,6 +991,8 @@ gdk_drop_emit_drop_event (GdkDrop *self,
event->dnd.time = time;
event->dnd.x_root = x_root;
event->dnd.y_root = y_root;
event->dnd.x = x_root - x;
event->dnd.y = y_root - y;
gdk_event_set_device (event, priv->device);
gdk_drop_do_emit_event (event, dont_queue);

View File

@ -947,6 +947,13 @@ gdk_event_get_coords (const GdkEvent *event,
x = event->touchpad_pinch.x;
y = event->touchpad_pinch.y;
break;
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
case GDK_DRAG_MOTION:
case GDK_DROP_START:
x = event->dnd.x;
y = event->dnd.y;
break;
default:
fetched = FALSE;
break;

View File

@ -418,7 +418,9 @@ struct _GdkEventDND {
GdkDrop *drop;
guint32 time;
gshort x_root, y_root;
double x_root, y_root;
double x;
double y;
};
/*

View File

@ -1296,6 +1296,7 @@ data_device_motion (void *data,
wl_fixed_t y)
{
GdkWaylandSeat *seat = data;
int origin_x, origin_y;
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("data device motion, data_device = %p, time = %d, x = %f, y = %f",
@ -1308,10 +1309,12 @@ 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_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
gdk_drop_emit_motion_event (seat->drop,
FALSE,
seat->pointer_info.surface_x,
seat->pointer_info.surface_y,
origin_x + seat->pointer_info.surface_x,
origin_y + seat->pointer_info.surface_y,
time);
}
@ -1320,14 +1323,17 @@ data_device_drop (void *data,
struct wl_data_device *data_device)
{
GdkWaylandSeat *seat = data;
int origin_x, origin_y;
GDK_DISPLAY_NOTE (seat->display, EVENTS,
g_message ("data device drop, data device %p", data_device));
gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
gdk_drop_emit_drop_event (seat->drop,
FALSE,
seat->pointer_info.surface_x,
seat->pointer_info.surface_y,
origin_x + seat->pointer_info.surface_x,
origin_y + seat->pointer_info.surface_y,
GDK_CURRENT_TIME);
}