/* Drag Contexts */
GdkDragContext *
-_gdk_broadway_surface_drag_begin (GdkSurface *surface,
+_gdk_broadway_surface_drag_begin (GdkSurface *surface,
GdkDevice *device,
GdkContentProvider *content,
GdkDragAction actions,
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);
enum {
PROP_0,
PROP_CONTENT,
+ PROP_DEVICE,
PROP_DISPLAY,
PROP_FORMATS,
N_PROPERTIES
return context->dest_surface;
}
-/**
- * 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
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:
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;
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * 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:
*
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);
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,
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;
/* 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;
_gdk_quartz_drag_source_context->targets = targets;
- gdk_drag_context_set_device (_gdk_quartz_drag_source_context, device);
-
return _gdk_quartz_drag_source_context;
}
{
GdkWaylandSeat *seat = data;
GdkSurface *dest_surface, *dnd_owner;
+ GdkDevice *device;
dest_surface = wl_surface_get_user_data (surface);
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);
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 =
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;
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);
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;
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
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
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;
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)
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);
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;
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);
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 */