From 35c8d0d363d54770b280a80fde784f998e234756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Wutz?= Date: Thu, 16 Nov 2017 21:07:16 +0100 Subject: [PATCH] event-widget: reposition drag source to initial position --- src/gcal-event-widget.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c index 5990199e..22c30b8d 100644 --- a/src/gcal-event-widget.c +++ b/src/gcal-event-widget.c @@ -608,8 +608,16 @@ static void gcal_event_widget_drag_begin (GtkWidget *widget, GdkDragContext *context) { - GcalEventWidget *self = GCAL_EVENT_WIDGET (widget); + GcalEventWidget *self; cairo_surface_t *surface; + GdkWindow *window; + GdkDevice *device; + gint x, y; + GtkAllocation allocation; + + self = GCAL_EVENT_WIDGET (widget); + window = gtk_widget_get_window (widget); + device = gdk_drag_context_get_device (context); if (self->read_only) { @@ -622,6 +630,11 @@ gcal_event_widget_drag_begin (GtkWidget *widget, gtk_drag_set_icon_surface (context, surface); + /* reposition drag surface to the point the GCalEvent was */ + gtk_widget_get_allocation (widget, &allocation); + gdk_window_get_device_position (window, device, &x, &y, NULL); + gdk_drag_context_set_hotspot (context, x - allocation.x, y - allocation.y); + g_clear_pointer (&surface, cairo_surface_destroy); }