forked from AuroraMiddleware/gtk
drop: Add GdkDrop:surface property
This replaces gdk_drag_context_get_dest_surface().
This commit is contained in:
parent
4aedf3d003
commit
05bf87cf14
@ -36,6 +36,7 @@ struct _GdkDropPrivate {
|
|||||||
GdkDevice *device;
|
GdkDevice *device;
|
||||||
GdkDragContext *drag;
|
GdkDragContext *drag;
|
||||||
GdkContentFormats *formats;
|
GdkContentFormats *formats;
|
||||||
|
GdkSurface *surface;
|
||||||
GdkDragAction actions;
|
GdkDragAction actions;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ enum {
|
|||||||
PROP_DISPLAY,
|
PROP_DISPLAY,
|
||||||
PROP_DRAG,
|
PROP_DRAG,
|
||||||
PROP_FORMATS,
|
PROP_FORMATS,
|
||||||
|
PROP_SURFACE,
|
||||||
N_PROPERTIES
|
N_PROPERTIES
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -118,6 +120,8 @@ gdk_drop_set_property (GObject *gobject,
|
|||||||
case PROP_DEVICE:
|
case PROP_DEVICE:
|
||||||
priv->device = g_value_dup_object (value);
|
priv->device = g_value_dup_object (value);
|
||||||
g_assert (priv->device != NULL);
|
g_assert (priv->device != NULL);
|
||||||
|
if (priv->surface)
|
||||||
|
g_assert (gdk_surface_get_display (priv->surface) == gdk_device_get_display (priv->device));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_DRAG:
|
case PROP_DRAG:
|
||||||
@ -131,6 +135,15 @@ gdk_drop_set_property (GObject *gobject,
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_SURFACE:
|
||||||
|
priv->surface = g_value_dup_object (value);
|
||||||
|
#ifdef DROP_SUBCLASS
|
||||||
|
g_assert (priv->surface != NULL);
|
||||||
|
if (priv->device)
|
||||||
|
g_assert (gdk_surface_get_display (priv->surface) == gdk_device_get_display (priv->device));
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -168,6 +181,10 @@ gdk_drop_get_property (GObject *gobject,
|
|||||||
g_value_set_boxed (value, priv->formats);
|
g_value_set_boxed (value, priv->formats);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_SURFACE:
|
||||||
|
g_value_set_object (value, priv->surface);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -271,6 +288,22 @@ gdk_drop_class_init (GdkDropClass *klass)
|
|||||||
G_PARAM_CONSTRUCT_ONLY |
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
G_PARAM_STATIC_STRINGS |
|
G_PARAM_STATIC_STRINGS |
|
||||||
G_PARAM_EXPLICIT_NOTIFY);
|
G_PARAM_EXPLICIT_NOTIFY);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GdkDrop:surface:
|
||||||
|
*
|
||||||
|
* The #GdkSurface the drop happens on
|
||||||
|
*/
|
||||||
|
properties[PROP_SURFACE] =
|
||||||
|
g_param_spec_object ("surface",
|
||||||
|
"Surface",
|
||||||
|
"The surface the drop is happening on",
|
||||||
|
GDK_TYPE_SURFACE,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS |
|
||||||
|
G_PARAM_EXPLICIT_NOTIFY);
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
|
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,6 +367,24 @@ gdk_drop_get_formats (GdkDrop *self)
|
|||||||
return priv->formats;
|
return priv->formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdk_drop_get_surface:
|
||||||
|
* @self: a #GdkDrop
|
||||||
|
*
|
||||||
|
* Returns the #GdkSurface performing the drop.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): The #GdkSurface performing the drop.
|
||||||
|
**/
|
||||||
|
GdkSurface *
|
||||||
|
gdk_drop_get_surface (GdkDrop *self)
|
||||||
|
{
|
||||||
|
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (GDK_IS_DROP (self), NULL);
|
||||||
|
|
||||||
|
return priv->surface;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_drop_get_actions:
|
* gdk_drop_get_actions:
|
||||||
* @self: a #GdkDrop
|
* @self: a #GdkDrop
|
||||||
|
@ -44,6 +44,8 @@ GdkDisplay * gdk_drop_get_display (GdkDrop
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GdkDevice * gdk_drop_get_device (GdkDrop *self);
|
GdkDevice * gdk_drop_get_device (GdkDrop *self);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
GdkSurface * gdk_drop_get_surface (GdkDrop *self);
|
||||||
|
GDK_AVAILABLE_IN_ALL
|
||||||
GdkContentFormats * gdk_drop_get_formats (GdkDrop *self);
|
GdkContentFormats * gdk_drop_get_formats (GdkDrop *self);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GdkDragAction gdk_drop_get_actions (GdkDrop *self);
|
GdkDragAction gdk_drop_get_actions (GdkDrop *self);
|
||||||
|
@ -1269,14 +1269,12 @@ data_device_enter (void *data,
|
|||||||
seat->pending_builder = NULL;
|
seat->pending_builder = NULL;
|
||||||
seat->pending_offer = NULL;
|
seat->pending_offer = NULL;
|
||||||
|
|
||||||
seat->drop_context = _gdk_wayland_drop_context_new (device, formats, offer);
|
seat->drop_context = _gdk_wayland_drop_context_new (device, formats, dest_surface, offer, serial);
|
||||||
|
|
||||||
dnd_owner = seat->foreign_dnd_surface;
|
dnd_owner = seat->foreign_dnd_surface;
|
||||||
|
|
||||||
_gdk_wayland_drag_context_set_source_surface (seat->drop_context, dnd_owner);
|
_gdk_wayland_drag_context_set_source_surface (seat->drop_context, dnd_owner);
|
||||||
|
|
||||||
_gdk_wayland_drag_context_set_dest_surface (seat->drop_context,
|
|
||||||
dest_surface, serial);
|
|
||||||
_gdk_wayland_drag_context_set_coords (seat->drop_context,
|
_gdk_wayland_drag_context_set_coords (seat->drop_context,
|
||||||
wl_fixed_to_double (x),
|
wl_fixed_to_double (x),
|
||||||
wl_fixed_to_double (y));
|
wl_fixed_to_double (y));
|
||||||
@ -1305,7 +1303,6 @@ data_device_leave (void *data,
|
|||||||
_gdk_wayland_drag_context_set_coords (seat->drop_context, -1, -1);
|
_gdk_wayland_drag_context_set_coords (seat->drop_context, -1, -1);
|
||||||
_gdk_wayland_drag_context_emit_event (seat->drop_context, GDK_DRAG_LEAVE,
|
_gdk_wayland_drag_context_emit_event (seat->drop_context, GDK_DRAG_LEAVE,
|
||||||
GDK_CURRENT_TIME);
|
GDK_CURRENT_TIME);
|
||||||
_gdk_wayland_drag_context_set_dest_surface (seat->drop_context, NULL, 0);
|
|
||||||
|
|
||||||
g_clear_object (&seat->drop_context);
|
g_clear_object (&seat->drop_context);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ _gdk_wayland_drag_context_emit_event (GdkDragContext *context,
|
|||||||
if (context->is_source)
|
if (context->is_source)
|
||||||
surface = gdk_drag_context_get_source_surface (context);
|
surface = gdk_drag_context_get_source_surface (context);
|
||||||
else
|
else
|
||||||
surface = gdk_drag_context_get_dest_surface (context);
|
surface = gdk_drop_get_surface (GDK_DROP (context));
|
||||||
|
|
||||||
event = gdk_event_new (type);
|
event = gdk_event_new (type);
|
||||||
event->any.surface = g_object_ref (surface);
|
event->any.surface = g_object_ref (surface);
|
||||||
@ -494,7 +494,10 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
|
|||||||
GdkDragContext *
|
GdkDragContext *
|
||||||
_gdk_wayland_drop_context_new (GdkDevice *device,
|
_gdk_wayland_drop_context_new (GdkDevice *device,
|
||||||
GdkContentFormats *formats,
|
GdkContentFormats *formats,
|
||||||
struct wl_data_offer *offer)
|
GdkSurface *surface,
|
||||||
|
struct wl_data_offer *offer,
|
||||||
|
uint32_t serial)
|
||||||
|
|
||||||
{
|
{
|
||||||
GdkWaylandDragContext *context_wayland;
|
GdkWaylandDragContext *context_wayland;
|
||||||
GdkDragContext *context;
|
GdkDragContext *context;
|
||||||
@ -502,10 +505,12 @@ _gdk_wayland_drop_context_new (GdkDevice *device,
|
|||||||
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
|
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
|
||||||
"device", device,
|
"device", device,
|
||||||
"formats", formats,
|
"formats", formats,
|
||||||
|
"surface", surface,
|
||||||
NULL);
|
NULL);
|
||||||
context = GDK_DRAG_CONTEXT (context_wayland);
|
context = GDK_DRAG_CONTEXT (context_wayland);
|
||||||
context->is_source = FALSE;
|
context->is_source = FALSE;
|
||||||
context_wayland->offer = offer;
|
context_wayland->offer = offer;
|
||||||
|
context_wayland->serial = serial;
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
@ -532,18 +537,6 @@ _gdk_wayland_drag_context_set_source_surface (GdkDragContext *context,
|
|||||||
context->source_surface = surface ? g_object_ref (surface) : NULL;
|
context->source_surface = surface ? g_object_ref (surface) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
_gdk_wayland_drag_context_set_dest_surface (GdkDragContext *context,
|
|
||||||
GdkSurface *dest_surface,
|
|
||||||
uint32_t serial)
|
|
||||||
{
|
|
||||||
if (context->dest_surface)
|
|
||||||
g_object_unref (context->dest_surface);
|
|
||||||
|
|
||||||
context->dest_surface = dest_surface ? g_object_ref (dest_surface) : NULL;
|
|
||||||
GDK_WAYLAND_DRAG_CONTEXT (context)->serial = serial;
|
|
||||||
}
|
|
||||||
|
|
||||||
GdkDragContext *
|
GdkDragContext *
|
||||||
gdk_wayland_drag_context_lookup_by_data_source (struct wl_data_source *source)
|
gdk_wayland_drag_context_lookup_by_data_source (struct wl_data_source *source)
|
||||||
{
|
{
|
||||||
|
@ -106,12 +106,11 @@ void _gdk_wayland_surface_offset_next_wl_buffer (GdkSurface *surface,
|
|||||||
int y);
|
int y);
|
||||||
GdkDragContext * _gdk_wayland_drop_context_new (GdkDevice *device,
|
GdkDragContext * _gdk_wayland_drop_context_new (GdkDevice *device,
|
||||||
GdkContentFormats *formats,
|
GdkContentFormats *formats,
|
||||||
struct wl_data_offer *offer);
|
GdkSurface *surface,
|
||||||
|
struct wl_data_offer *offer,
|
||||||
|
uint32_t serial);
|
||||||
void _gdk_wayland_drag_context_set_source_surface (GdkDragContext *context,
|
void _gdk_wayland_drag_context_set_source_surface (GdkDragContext *context,
|
||||||
GdkSurface *surface);
|
GdkSurface *surface);
|
||||||
void _gdk_wayland_drag_context_set_dest_surface (GdkDragContext *context,
|
|
||||||
GdkSurface *dest_surface,
|
|
||||||
uint32_t serial);
|
|
||||||
void _gdk_wayland_drag_context_emit_event (GdkDragContext *context,
|
void _gdk_wayland_drag_context_emit_event (GdkDragContext *context,
|
||||||
GdkEventType type,
|
GdkEventType type,
|
||||||
guint32 time_);
|
guint32 time_);
|
||||||
|
@ -144,6 +144,7 @@ gdk_drop_context_new (GdkDisplay *display,
|
|||||||
context_win32 = g_object_new (GDK_TYPE_WIN32_DROP_CONTEXT,
|
context_win32 = g_object_new (GDK_TYPE_WIN32_DROP_CONTEXT,
|
||||||
"device", gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
|
"device", gdk_seat_get_pointer (gdk_display_get_default_seat (display)),
|
||||||
"formats", formats,
|
"formats", formats,
|
||||||
|
"surface", dest_surface,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
context = GDK_DRAG_CONTEXT (context_win32);
|
context = GDK_DRAG_CONTEXT (context_win32);
|
||||||
|
@ -1815,6 +1815,7 @@ xdnd_enter_filter (const XEvent *xevent,
|
|||||||
context_x11 = g_object_new (GDK_TYPE_X11_DRAG_CONTEXT,
|
context_x11 = g_object_new (GDK_TYPE_X11_DRAG_CONTEXT,
|
||||||
"device", gdk_seat_get_pointer (seat),
|
"device", gdk_seat_get_pointer (seat),
|
||||||
"formats", content_formats,
|
"formats", content_formats,
|
||||||
|
"surface", event->any.surface,
|
||||||
NULL);
|
NULL);
|
||||||
context = (GdkDragContext *)context_x11;
|
context = (GdkDragContext *)context_x11;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user