[gnome-todo/wip/gbsneto/dnd-fixups: 1/6] task-row: Start working on DnD



commit a94fc6044ba7dbf9de64c57fbdfa712fbc16b48f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Oct 31 14:51:28 2017 -0200

    task-row: Start working on DnD

 src/gtd-task-row.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)
---
diff --git a/src/gtd-task-row.c b/src/gtd-task-row.c
index 84a1c83..61277a0 100644
--- a/src/gtd-task-row.c
+++ b/src/gtd-task-row.c
@@ -62,8 +62,7 @@ struct _GtdTaskRow
   gboolean            active;
 };
 
-#define PRIORITY_ICON_SIZE         8
-#define DND_ICON_SCALE             0.85
+#define PRIORITY_ICON_SIZE 8
 
 G_DEFINE_TYPE (GtdTaskRow, gtd_task_row, GTK_TYPE_LIST_BOX_ROW)
 
@@ -119,29 +118,24 @@ get_dnd_icon (GtdTaskRow *self)
   GtkWidget *widget;
   cairo_t *cr;
   gint real_x;
+  gint real_y;
 
   widget = GTK_WIDGET (self);
   gtk_widget_translate_coordinates (self->dnd_event_box,
-                                    gtk_widget_get_parent (widget),
-                                    0,
-                                    0,
+                                    widget,
+                                    self->clicked_x,
+                                    self->clicked_y,
                                     &real_x,
-                                    NULL);
+                                    &real_y);
 
   /* Make it transparent */
   surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
-                                        gtk_widget_get_allocated_width (widget) * DND_ICON_SCALE,
-                                        gtk_widget_get_allocated_height (widget) * DND_ICON_SCALE);
+                                        gtk_widget_get_allocated_width (widget),
+                                        gtk_widget_get_allocated_height (widget));
 
   cr = cairo_create (surface);
-  cairo_scale (cr, DND_ICON_SCALE, DND_ICON_SCALE);
-
   gtk_widget_draw (widget, cr);
 
-  cairo_surface_set_device_offset (surface,
-                                   -(self->clicked_x + real_x) * DND_ICON_SCALE,
-                                   -self->clicked_y * DND_ICON_SCALE);
-
   return surface;
 }
 
@@ -227,11 +221,25 @@ drag_begin_cb (GtkWidget      *widget,
 {
   cairo_surface_t *surface;
 
+  gint real_x;
+  gint real_y;
+
+  widget = GTK_WIDGET (self);
+  gtk_widget_translate_coordinates (self->dnd_event_box,
+                                    GTK_WIDGET (self),
+                                    self->clicked_x,
+                                    self->clicked_y,
+                                    &real_x,
+                                    &real_y);
+
   surface = get_dnd_icon (self);
 
   set_cursor (widget, "grabbing");
 
   gtk_drag_set_icon_surface (context, surface);
+  gdk_drag_context_set_hotspot (context, self->clicked_x, self->clicked_y);
+
+  g_message ("Hotspot → %d, %d", real_x, real_y);
 
   gtk_widget_hide (GTK_WIDGET (self));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]