diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2016-04-26 15:31:33 +0800 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2016-04-26 23:03:24 +0800 |
commit | 1a4f000f3b2a3289c6bcd30b7ce259c1686ef169 (patch) | |
tree | c53c46c41b69be65b39738605a8d74ae096f72e9 | |
parent | f27dd214267b5b907411cefb85350acfbb26ac77 (diff) | |
download | gtk+-1a4f000f3b2a3289c6bcd30b7ce259c1686ef169.tar.gz |
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
-rw-r--r-- | gdk/broadway/gdkdnd-broadway.c | 1 | ||||
-rw-r--r-- | gdk/gdkdnd.c | 5 | ||||
-rw-r--r-- | gdk/gdkdndprivate.h | 5 | ||||
-rw-r--r-- | gdk/quartz/GdkQuartzNSWindow.c | 2 | ||||
-rw-r--r-- | gdk/quartz/gdkdnd-quartz.c | 1 | ||||
-rw-r--r-- | gdk/wayland/gdkdevice-wayland.c | 3 | ||||
-rw-r--r-- | gdk/wayland/gdkdnd-wayland.c | 7 | ||||
-rw-r--r-- | gdk/wayland/gdkprivate-wayland.h | 3 | ||||
-rw-r--r-- | gdk/win32/gdkdnd-win32.c | 1 | ||||
-rw-r--r-- | gdk/x11/gdkdnd-x11.c | 4 |
10 files changed, 24 insertions, 8 deletions
diff --git a/gdk/broadway/gdkdnd-broadway.c b/gdk/broadway/gdkdnd-broadway.c index 042a0cd65b..7c5fffeb6a 100644 --- a/gdk/broadway/gdkdnd-broadway.c +++ b/gdk/broadway/gdkdnd-broadway.c @@ -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; } diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index a1e52c2b2e..163a705ee0 100644 --- a/gdk/gdkdnd.c +++ b/gdk/gdkdnd.c @@ -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; } diff --git a/gdk/gdkdndprivate.h b/gdk/gdkdndprivate.h index 283dba2b85..d37ec67ab7 100644 --- a/gdk/gdkdndprivate.h +++ b/gdk/gdkdndprivate.h @@ -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 diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c index e45c632aa8..5a99411c6e 100644 --- a/gdk/quartz/GdkQuartzNSWindow.c +++ b/gdk/quartz/GdkQuartzNSWindow.c @@ -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)); diff --git a/gdk/quartz/gdkdnd-quartz.c b/gdk/quartz/gdkdnd-quartz.c index 0a38cd892e..15b6fed319 100644 --- a/gdk/quartz/gdkdnd-quartz.c +++ b/gdk/quartz/gdkdnd-quartz.c @@ -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; diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index c220d2b82b..e3f7fac7e2 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -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); diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c index 7bb0c6186d..adc33a4bc2 100644 --- a/gdk/wayland/gdkdnd-wayland.c +++ b/gdk/wayland/gdkdnd-wayland.c @@ -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; diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h index eb93047f96..81770f6640 100644 --- a/gdk/wayland/gdkprivate-wayland.h +++ b/gdk/wayland/gdkprivate-wayland.h @@ -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, diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c index d012463a96..cec3dcc763 100644 --- a/gdk/win32/gdkdnd-win32.c +++ b/gdk/win32/gdkdnd-win32.c @@ -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))); diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index c2a69193d2..3d25ea2734 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -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); } |