summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdk/broadway/gdkdnd-broadway.c4
-rw-r--r--gdk/gdkdnd.c56
-rw-r--r--gdk/gdkdndprivate.h2
-rw-r--r--gdk/quartz/GdkQuartzNSWindow.c9
-rw-r--r--gdk/quartz/gdkdnd-quartz.c4
-rw-r--r--gdk/wayland/gdkdevice-wayland.c14
-rw-r--r--gdk/wayland/gdkdnd-wayland.c8
-rw-r--r--gdk/wayland/gdkprivate-wayland.h2
-rw-r--r--gdk/win32/gdkdnd-win32.c3
-rw-r--r--gdk/win32/gdkdrag-win32.c4
-rw-r--r--gdk/win32/gdkdrop-win32.c4
-rw-r--r--gdk/x11/gdkdnd-x11.c8
-rw-r--r--testsuite/gtk/notify.c2
-rw-r--r--testsuite/gtk/objects-finalize.c7
14 files changed, 57 insertions, 70 deletions
diff --git a/gdk/broadway/gdkdnd-broadway.c b/gdk/broadway/gdkdnd-broadway.c
index e3836f9d62..660c36aa74 100644
--- a/gdk/broadway/gdkdnd-broadway.c
+++ b/gdk/broadway/gdkdnd-broadway.c
@@ -84,7 +84,7 @@ gdk_broadway_drag_context_finalize (GObject *object)
/* Drag Contexts */
GdkDragContext *
-_gdk_broadway_surface_drag_begin (GdkSurface *surface,
+_gdk_broadway_surface_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
@@ -97,7 +97,7 @@ _gdk_broadway_surface_drag_begin (GdkSurface *surface,
g_return_val_if_fail (GDK_SURFACE_IS_BROADWAY (surface), NULL);
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT,
- "display", gdk_surface_get_display (surface),
+ "device", device,
"content", content,
NULL);
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
index 8a7f16c355..7e26eceb76 100644
--- a/gdk/gdkdnd.c
+++ b/gdk/gdkdnd.c
@@ -51,6 +51,7 @@ static struct {
enum {
PROP_0,
PROP_CONTENT,
+ PROP_DEVICE,
PROP_DISPLAY,
PROP_FORMATS,
N_PROPERTIES
@@ -203,30 +204,6 @@ gdk_drag_context_get_dest_surface (GdkDragContext *context)
}
/**
- * gdk_drag_context_set_device:
- * @context: a #GdkDragContext
- * @device: a #GdkDevice
- *
- * Associates a #GdkDevice to @context, so all Drag and Drop events
- * for @context are emitted as if they came from this device.
- */
-void
-gdk_drag_context_set_device (GdkDragContext *context,
- GdkDevice *device)
-{
- g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
- g_return_if_fail (GDK_IS_DEVICE (device));
-
- if (context->device)
- g_object_unref (context->device);
-
- context->device = device;
-
- if (context->device)
- g_object_ref (context->device);
-}
-
-/**
* gdk_drag_context_get_device:
* @context: a #GdkDragContext
*
@@ -266,9 +243,10 @@ gdk_drag_context_set_property (GObject *gobject,
context->formats = gdk_content_provider_ref_formats (context->content);
break;
- case PROP_DISPLAY:
- context->display = g_value_get_object (value);
- g_assert (context->display != NULL);
+ case PROP_DEVICE:
+ context->device = g_value_dup_object (value);
+ g_assert (context->device != NULL);
+ context->display = gdk_device_get_display (context->device);
break;
default:
@@ -291,6 +269,10 @@ gdk_drag_context_get_property (GObject *gobject,
g_value_set_object (value, context->content);
break;
+ case PROP_DEVICE:
+ g_value_set_object (value, context->device);
+ break;
+
case PROP_DISPLAY:
g_value_set_object (value, context->display);
break;
@@ -386,15 +368,29 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
/**
* GdkDragContext:display:
*
+ * The #GdkDevice that is performing the drag.
+ */
+ properties[PROP_DEVICE] =
+ g_param_spec_object ("device",
+ "Device",
+ "The device performing the drag",
+ GDK_TYPE_DEVICE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS |
+ G_PARAM_EXPLICIT_NOTIFY);
+
+ /**
+ * GdkDragContext:display:
+ *
* The #GdkDisplay that the drag context belongs to.
*/
properties[PROP_DISPLAY] =
g_param_spec_object ("display",
"Display",
- "Display owning this clipboard",
+ "Display this drag belongs to",
GDK_TYPE_DISPLAY,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
diff --git a/gdk/gdkdndprivate.h b/gdk/gdkdndprivate.h
index 101ceed712..ee8edf8bdc 100644
--- a/gdk/gdkdndprivate.h
+++ b/gdk/gdkdndprivate.h
@@ -102,8 +102,6 @@ struct _GdkDragContext {
guint drop_done : 1; /* Whether gdk_drag_drop_done() was performed */
};
-void gdk_drag_context_set_device (GdkDragContext *context,
- GdkDevice *device);
void gdk_drag_context_set_cursor (GdkDragContext *context,
GdkCursor *cursor);
void gdk_drag_context_cancel (GdkDragContext *context,
diff --git a/gdk/quartz/GdkQuartzNSWindow.c b/gdk/quartz/GdkQuartzNSWindow.c
index cc3bc37100..74dddeeeaa 100644
--- a/gdk/quartz/GdkQuartzNSWindow.c
+++ b/gdk/quartz/GdkQuartzNSWindow.c
@@ -584,16 +584,13 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
if (current_context)
g_object_unref (current_context);
- current_context = g_object_new (GDK_TYPE_QUARTZ_DRAG_CONTEXT, NULL);
+ current_context = g_object_new (GDK_TYPE_QUARTZ_DRAG_CONTEXT,
+ "device", gdk_seat_get_pointer (gdk_display_get_default_seat (current_context->display)),
+ NULL);
update_context_from_dragging_info (sender);
window = [[self contentView] gdkSurface];
- current_context->display = gdk_surface_get_display (window);
-
- gdk_drag_context_set_device (current_context,
- gdk_seat_get_pointer (gdk_display_get_default_seat (current_context->display)));
-
event = gdk_event_new (GDK_DRAG_ENTER);
event->dnd.window = g_object_ref (window);
event->dnd.send_event = FALSE;
diff --git a/gdk/quartz/gdkdnd-quartz.c b/gdk/quartz/gdkdnd-quartz.c
index d1a7ec0936..f091185751 100644
--- a/gdk/quartz/gdkdnd-quartz.c
+++ b/gdk/quartz/gdkdnd-quartz.c
@@ -44,7 +44,7 @@ _gdk_quartz_surface_drag_begin (GdkSurface *window,
/* Create fake context */
_gdk_quartz_drag_source_context = g_object_new (GDK_TYPE_QUARTZ_DRAG_CONTEXT,
- "display", display,
+ "device", device,
NULL);
_gdk_quartz_drag_source_context->is_source = TRUE;
@@ -53,8 +53,6 @@ _gdk_quartz_surface_drag_begin (GdkSurface *window,
_gdk_quartz_drag_source_context->targets = targets;
- gdk_drag_context_set_device (_gdk_quartz_drag_source_context, device);
-
return _gdk_quartz_drag_source_context;
}
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 22ae09aec8..2b28b87aac 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -1078,6 +1078,7 @@ data_device_enter (void *data,
{
GdkWaylandSeat *seat = data;
GdkSurface *dest_surface, *dnd_owner;
+ GdkDevice *device;
dest_surface = wl_surface_get_user_data (surface);
@@ -1093,12 +1094,17 @@ data_device_enter (void *data,
seat->pointer_info.surface_x = wl_fixed_to_double (x);
seat->pointer_info.surface_y = wl_fixed_to_double (y);
- seat->drop_context = _gdk_wayland_drop_context_new (seat->display,
- seat->data_device);
if (seat->master_pointer)
- gdk_drag_context_set_device (seat->drop_context, seat->master_pointer);
+ device = seat->master_pointer;
else if (seat->touch_master)
- gdk_drag_context_set_device (seat->drop_context, seat->touch_master);
+ device = seat->touch_master;
+ else
+ {
+ g_warning ("No device for DND enter, ignoring.");
+ return;
+ }
+ seat->drop_context = _gdk_wayland_drop_context_new (device,
+ seat->data_device);
gdk_wayland_drop_context_update_targets (seat->drop_context);
diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c
index 7f72a4c47f..24d9070b1d 100644
--- a/gdk/wayland/gdkdnd-wayland.c
+++ b/gdk/wayland/gdkdnd-wayland.c
@@ -494,15 +494,13 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
display_wayland = GDK_WAYLAND_DISPLAY (gdk_device_get_display (device));
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
- "display", display_wayland,
+ "device", device,
"content", content,
NULL);
context = GDK_DRAG_CONTEXT (context_wayland);
context->source_surface = g_object_ref (surface);
context->is_source = TRUE;
- gdk_drag_context_set_device (context, device);
-
context_wayland->dnd_surface = create_dnd_surface (gdk_surface_get_display (surface));
context_wayland->dnd_wl_surface = gdk_wayland_surface_get_wl_surface (context_wayland->dnd_surface);
context_wayland->data_source =
@@ -534,14 +532,14 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
GdkDragContext *
-_gdk_wayland_drop_context_new (GdkDisplay *display,
+_gdk_wayland_drop_context_new (GdkDevice *device,
struct wl_data_device *data_device)
{
GdkWaylandDragContext *context_wayland;
GdkDragContext *context;
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
- "display", display,
+ "device", device,
NULL);
context = GDK_DRAG_CONTEXT (context_wayland);
context->is_source = FALSE;
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index db1c916264..0403073c30 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -104,7 +104,7 @@ GdkDragContext *_gdk_wayland_surface_drag_begin (GdkSurface *surface,
void _gdk_wayland_surface_offset_next_wl_buffer (GdkSurface *surface,
int x,
int y);
-GdkDragContext * _gdk_wayland_drop_context_new (GdkDisplay *display,
+GdkDragContext * _gdk_wayland_drop_context_new (GdkDevice *device,
struct wl_data_device *data_device);
void _gdk_wayland_drag_context_set_source_surface (GdkDragContext *context,
GdkSurface *surface);
diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c
index 92cc8c88cd..97c753c91d 100644
--- a/gdk/win32/gdkdnd-win32.c
+++ b/gdk/win32/gdkdnd-win32.c
@@ -248,11 +248,10 @@ gdk_drag_context_new (GdkDisplay *display,
GdkDragContext *context;
context_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT,
- "display", display,
+ "device", device ? device : gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
NULL);
context = GDK_DRAG_CONTEXT(context_win32);
- gdk_drag_context_set_device (context, device ? device : gdk_seat_get_pointer (gdk_display_get_default_seat (display)));
if (win32_display->has_fixed_scale)
context_win32->scale = win32_display->surface_scale;
diff --git a/gdk/win32/gdkdrag-win32.c b/gdk/win32/gdkdrag-win32.c
index 556239ae33..830af3232f 100644
--- a/gdk/win32/gdkdrag-win32.c
+++ b/gdk/win32/gdkdrag-win32.c
@@ -811,14 +811,12 @@ gdk_drag_context_new (GdkDisplay *display,
GdkDragContext *context;
context_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT,
- "display", display,
+ "device", device ? device : gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
"content", content,
NULL);
context = GDK_DRAG_CONTEXT (context_win32);
- gdk_drag_context_set_device (context, device ? device : gdk_seat_get_pointer (gdk_display_get_default_seat (display)));
-
if (win32_display->has_fixed_scale)
context_win32->scale = win32_display->surface_scale;
else
diff --git a/gdk/win32/gdkdrop-win32.c b/gdk/win32/gdkdrop-win32.c
index 5038a53346..b41a6cfa4b 100644
--- a/gdk/win32/gdkdrop-win32.c
+++ b/gdk/win32/gdkdrop-win32.c
@@ -141,13 +141,11 @@ gdk_drop_context_new (GdkDisplay *display,
GdkDragContext *context;
context_win32 = g_object_new (GDK_TYPE_WIN32_DROP_CONTEXT,
- "display", display,
+ "device", gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
NULL);
context = GDK_DRAG_CONTEXT (context_win32);
- gdk_drag_context_set_device (context, gdk_seat_get_pointer (gdk_display_get_default_seat (display)));
-
if (win32_display->has_fixed_scale)
context_win32->scale = win32_display->surface_scale;
else
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index fed6f33890..ddcd22632a 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -1776,8 +1776,9 @@ xdnd_enter_filter (const XEvent *xevent,
display_x11->current_dest_drag = NULL;
}
+ seat = gdk_display_get_default_seat (display);
context_x11 = g_object_new (GDK_TYPE_X11_DRAG_CONTEXT,
- "display", display,
+ "device", gdk_seat_get_pointer (seat),
NULL);
context = (GdkDragContext *)context_x11;
@@ -1785,8 +1786,6 @@ xdnd_enter_filter (const XEvent *xevent,
context_x11->version = version;
/* FIXME: Should extend DnD protocol to have device info */
- seat = gdk_display_get_default_seat (display);
- gdk_drag_context_set_device (context, gdk_seat_get_pointer (seat));
context->source_surface = gdk_x11_surface_foreign_new_for_display (display, source_surface);
if (!context->source_surface)
@@ -2957,7 +2956,7 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
display = gdk_surface_get_display (surface);
context = (GdkDragContext *) g_object_new (GDK_TYPE_X11_DRAG_CONTEXT,
- "display", display,
+ "device", device,
"content", content,
NULL);
x11_context = GDK_X11_DRAG_CONTEXT (context);
@@ -2968,7 +2967,6 @@ _gdk_x11_surface_drag_begin (GdkSurface *surface,
precache_target_list (context);
- gdk_drag_context_set_device (context, device);
gdk_device_get_position (device, &x_root, &y_root);
x_root += dx;
y_root += dy;
diff --git a/testsuite/gtk/notify.c b/testsuite/gtk/notify.c
index bf78772657..1b88db8f41 100644
--- a/testsuite/gtk/notify.c
+++ b/testsuite/gtk/notify.c
@@ -411,7 +411,7 @@ test_type (gconstpointer data)
else if (g_str_equal (g_type_name (type), "GdkClipboard"))
instance = g_object_new (type, "display", display, NULL);
else if (g_str_equal (g_type_name (type), "GdkDragContext"))
- instance = g_object_new (type, "display", display, NULL);
+ instance = g_object_new (type, "device", gdk_seat_get_pointer (gdk_display_get_default_seat (gdk_display_get_default ())), NULL);
else
instance = g_object_new (type, NULL);
diff --git a/testsuite/gtk/objects-finalize.c b/testsuite/gtk/objects-finalize.c
index 9ef2349231..bb3af68031 100644
--- a/testsuite/gtk/objects-finalize.c
+++ b/testsuite/gtk/objects-finalize.c
@@ -52,11 +52,12 @@ test_finalize_object (gconstpointer data)
GType test_type = GPOINTER_TO_SIZE (data);
GObject *object;
- if (g_str_equal (g_type_name (test_type), "GdkClipboard") ||
- g_str_equal (g_type_name (test_type), "GdkDragContext"))
+ if (g_str_equal (g_type_name (test_type), "GdkClipboard"))
object = g_object_new (test_type, "display", gdk_display_get_default (), NULL);
+ else if (g_str_equal (g_type_name (test_type), "GdkDragContext"))
+ object = g_object_new (test_type, "device", gdk_seat_get_pointer (gdk_display_get_default_seat (gdk_display_get_default ())), NULL);
else
- object = g_object_new (test_type, NULL);
+ object = g_object_new (test_type, NULL);
g_assert (G_IS_OBJECT (object));
/* Make sure we have the only reference */