gdk/dnd: Don't use default display when getting cursor

Always associate a drag context with a GdkDisplay and use that when
getting a cursor for a given action.

If we don't do this, dragging on a window that doesn't use the default
display will make us use cursors from the wrong display.

https://bugzilla.gnome.org/show_bug.cgi?id=765565
This commit is contained in:
Jonas Ådahl 2016-04-26 15:31:33 +08:00
parent f27dd21426
commit 1a4f000f3b
10 changed files with 24 additions and 8 deletions

View File

@ -98,6 +98,7 @@ _gdk_broadway_window_drag_begin (GdkWindow *window,
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT,
NULL);
new_context->display = gdk_window_get_display (window);
return new_context;
}

View File

@ -753,7 +753,8 @@ gdk_drag_context_handle_source_event (GdkEvent *event)
}
GdkCursor *
gdk_drag_get_cursor (GdkDragAction action)
gdk_drag_get_cursor (GdkDragContext *context,
GdkDragAction action)
{
gint i;
@ -762,7 +763,7 @@ gdk_drag_get_cursor (GdkDragAction action)
break;
if (drag_cursors[i].cursor == NULL)
drag_cursors[i].cursor = gdk_cursor_new_from_name (gdk_display_get_default (),
drag_cursors[i].cursor = gdk_cursor_new_from_name (context->display,
drag_cursors[i].name);
return drag_cursors[i].cursor;
}

View File

@ -94,6 +94,8 @@ struct _GdkDragContext {
/*< private >*/
GdkDragProtocol protocol;
GdkDisplay *display;
gboolean is_source;
GdkWindow *source_window;
GdkWindow *dest_window;
@ -119,7 +121,8 @@ 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 (GdkDragAction action);
GdkCursor * gdk_drag_get_cursor (GdkDragContext *context,
GdkDragAction action);
G_END_DECLS

View File

@ -587,6 +587,8 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
window = [[self contentView] gdkWindow];
current_context->display = gdk_window_get_display (window);
device_manager = gdk_display_get_device_manager (gdk_display_get_default ());
gdk_drag_context_set_device (current_context,
gdk_device_manager_get_client_pointer (device_manager));

View File

@ -44,6 +44,7 @@ _gdk_quartz_window_drag_begin (GdkWindow *window,
/* Create fake context */
_gdk_quartz_drag_source_context = g_object_new (GDK_TYPE_QUARTZ_DRAG_CONTEXT,
NULL);
_gdk_quartz_drag_source_context->display = gdk_window_get_display (window);
_gdk_quartz_drag_source_context->is_source = TRUE;
_gdk_quartz_drag_source_context->source_window = window;

View File

@ -3988,7 +3988,8 @@ _gdk_wayland_device_manager_add_seat (GdkDeviceManager *device_manager,
seat->data_device =
wl_data_device_manager_get_data_device (display_wayland->data_device_manager,
seat->wl_seat);
seat->drop_context = _gdk_wayland_drop_context_new (seat->data_device);
seat->drop_context = _gdk_wayland_drop_context_new (display,
seat->data_device);
wl_data_device_add_listener (seat->data_device,
&data_device_listener, seat);

View File

@ -427,7 +427,7 @@ gdk_wayland_drag_context_action_changed (GdkDragContext *context,
{
GdkCursor *cursor;
cursor = gdk_drag_get_cursor (action);
cursor = gdk_drag_get_cursor (context, action);
gdk_drag_context_set_cursor (context, cursor);
}
@ -528,6 +528,7 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, NULL);
context = GDK_DRAG_CONTEXT (context_wayland);
context->display = gdk_window_get_display (window);
context->source_window = g_object_ref (window);
context->is_source = TRUE;
context->targets = g_list_copy (targets);
@ -552,13 +553,15 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
}
GdkDragContext *
_gdk_wayland_drop_context_new (struct wl_data_device *data_device)
_gdk_wayland_drop_context_new (GdkDisplay *display,
struct wl_data_device *data_device)
{
GdkWaylandDragContext *context_wayland;
GdkDragContext *context;
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, NULL);
context = GDK_DRAG_CONTEXT (context_wayland);
context->display = display;
context->is_source = FALSE;
return context;

View File

@ -109,7 +109,8 @@ GdkDragContext *_gdk_wayland_window_drag_begin (GdkWindow *window,
void _gdk_wayland_window_offset_next_wl_buffer (GdkWindow *window,
int x,
int y);
GdkDragContext * _gdk_wayland_drop_context_new (struct wl_data_device *data_device);
GdkDragContext * _gdk_wayland_drop_context_new (GdkDisplay *display,
struct wl_data_device *data_device);
void _gdk_wayland_drag_context_set_source_window (GdkDragContext *context,
GdkWindow *window);
void _gdk_wayland_drag_context_set_dest_window (GdkDragContext *context,

View File

@ -182,6 +182,7 @@ gdk_drag_context_new (GdkDisplay *display)
context_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT, NULL);
context = GDK_DRAG_CONTEXT(context_win32);
context->display = display;
gdk_drag_context_set_device (context, gdk_seat_get_pointer (gdk_display_get_default_seat (display)));

View File

@ -1705,6 +1705,7 @@ xdnd_enter_filter (GdkXEvent *xev,
context_x11 = (GdkX11DragContext *)g_object_new (GDK_TYPE_X11_DRAG_CONTEXT, NULL);
context = (GdkDragContext *)context_x11;
context->display = display;
context->protocol = GDK_DRAG_PROTO_XDND;
context_x11->version = version;
@ -2020,6 +2021,7 @@ _gdk_x11_window_drag_begin (GdkWindow *window,
context = (GdkDragContext *) g_object_new (GDK_TYPE_X11_DRAG_CONTEXT, NULL);
context->display = gdk_window_get_display (window);
context->is_source = TRUE;
context->source_window = window;
g_object_ref (window);
@ -3132,6 +3134,6 @@ gdk_x11_drag_context_action_changed (GdkDragContext *context,
{
GdkCursor *cursor;
cursor = gdk_drag_get_cursor (action);
cursor = gdk_drag_get_cursor (context, action);
gdk_drag_context_set_cursor (context, cursor);
}