gdk: Make DRAG_ENTER event take x/y coordinates

Make it mirror the behavior of ENTER/LEAVE events.
This commit is contained in:
Benjamin Otte 2020-02-19 03:37:23 +01:00
parent 41ef6e9fa5
commit 808961564c
7 changed files with 25 additions and 12 deletions

View File

@ -962,6 +962,8 @@ gdk_drop_do_emit_event (GdkEvent *event,
void
gdk_drop_emit_enter_event (GdkDrop *self,
gboolean dont_queue,
double x,
double y,
guint32 time)
{
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);

View File

@ -61,6 +61,8 @@ void gdk_drop_set_actions (GdkDrop
void gdk_drop_emit_enter_event (GdkDrop *self,
gboolean dont_queue,
double x,
double y,
guint32 time);
void gdk_drop_emit_motion_event (GdkDrop *self,
gboolean dont_queue,

View File

@ -1201,6 +1201,7 @@ data_device_enter (void *data,
GdkWaylandSeat *seat = data;
GdkSurface *dest_surface;
GdkContentFormats *formats;
int origin_x, origin_y;
GdkDevice *device;
dest_surface = wl_surface_get_user_data (surface);
@ -1245,8 +1246,12 @@ data_device_enter (void *data,
gdk_wayland_seat_discard_pending_offer (seat);
gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
gdk_drop_emit_enter_event (seat->drop,
FALSE,
origin_x + seat->pointer_info.surface_x,
origin_y + seat->pointer_info.surface_y,
GDK_CURRENT_TIME);
}

View File

@ -487,8 +487,7 @@ _gdk_win32_local_drop_target_dragenter (GdkDrag *drag,
source_actions = set_source_actions_helper (drop, *actions, grfKeyState);
gdk_drop_emit_enter_event (drop, TRUE, time_);
gdk_drop_emit_motion_event (drop, TRUE, x_root, y_root, time_);
gdk_drop_emit_enter_event (drop, TRUE, x_root, y_root, time_);
drop_win32->last_key_state = grfKeyState;
drop_win32->last_x = x_root;
drop_win32->last_y = y_root;
@ -559,8 +558,7 @@ idroptarget_dragenter (LPDROPTARGET This,
set_data_object (&ctx->data_object, pDataObj);
pt_x = pt.x / drop_win32->scale + _gdk_offset_x;
pt_y = pt.y / drop_win32->scale + _gdk_offset_y;
gdk_drop_emit_enter_event (drop, TRUE, GDK_CURRENT_TIME);
gdk_drop_emit_motion_event (drop, TRUE, pt_x, pt_y, GDK_CURRENT_TIME);
gdk_drop_emit_enter_event (drop, TRUE, pt_x, pt_y, GDK_CURRENT_TIME);
drop_win32->last_key_state = grfKeyState;
drop_win32->last_x = pt_x;
drop_win32->last_y = pt_y;

View File

@ -70,6 +70,7 @@ struct _GdkX11Drop
guint xdnd_targets_set : 1; /* Whether we've already set XdndTypeList */
guint xdnd_have_actions : 1; /* Whether an XdndActionList was provided */
guint enter_emitted : 1; /* Set after gdk_drop_emit_enter() */
};
struct _GdkX11DropClass
@ -582,8 +583,6 @@ xdnd_enter_filter (GdkSurface *surface,
display_x11->current_drop = drop;
gdk_drop_emit_enter_event (drop, FALSE, GDK_CURRENT_TIME);
gdk_content_formats_unref (content_formats);
return TRUE;
@ -609,6 +608,7 @@ xdnd_leave_filter (GdkSurface *surface,
if ((display_x11->current_drop != NULL) &&
(GDK_X11_DROP (display_x11->current_drop)->source_window == source_window))
{
if (GDK_X11_DROP (display_x11->current_drop)->enter_emitted)
gdk_drop_emit_leave_event (display_x11->current_drop, FALSE, GDK_CURRENT_TIME);
g_clear_object (&display_x11->current_drop);
@ -656,8 +656,16 @@ xdnd_position_filter (GdkSurface *surface,
drop_x11->last_x = x_root / impl->surface_scale;
drop_x11->last_y = y_root / impl->surface_scale;
if (drop_x11->enter_emitted)
{
gdk_drop_emit_motion_event (drop, FALSE, drop_x11->last_x - surface->x, drop_x11->last_y - surface->y, time);
}
else
{
gdk_drop_emit_enter_event (drop, FALSE, drop_x11->last_x - surface->x, drop_x11->last_y - surface->y, time);
drop_x11->enter_emitted = TRUE;
}
}
return TRUE;
}

View File

@ -822,13 +822,11 @@ gtk_drag_dest_handle_event (GtkWidget *toplevel,
switch ((guint) event_type)
{
case GDK_DRAG_ENTER:
break;
case GDK_DRAG_LEAVE:
gtk_drop_set_current_dest (drop, NULL);
break;
case GDK_DRAG_ENTER:
case GDK_DRAG_MOTION:
case GDK_DROP_START:
gtk_drop_set_current_dest (drop, NULL);

View File

@ -1812,13 +1812,13 @@ gtk_main_do_event (GdkEvent *event)
/* Crossing event propagation happens during picking */
break;
case GDK_DRAG_ENTER:
case GDK_DRAG_MOTION:
case GDK_DROP_START:
if (gtk_propagate_event (target_widget, event))
break;
G_GNUC_FALLTHROUGH;
case GDK_DRAG_ENTER:
case GDK_DRAG_LEAVE:
gtk_drag_dest_handle_event (target_widget, event);
break;