[gtk+/wip/matthiasc/dnd-animation: 2/7] dnd: Pass start coordinates when creating the drag context



commit a24bbcbb8d722cf55d7c454c49108c251500511a
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Dec 7 14:21:20 2015 -0500

    dnd: Pass start coordinates when creating the drag context
    
    This will be used in subsequent commits.

 gtk/gtkdnd.c |   41 +++++++++++++++++++++--------------------
 1 files changed, 21 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index eba82c9..439fc5c 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -2173,6 +2173,7 @@ gtk_drag_begin_internal (GtkWidget          *widget,
   GdkCursor *cursor;
   GdkDevice *pointer, *keyboard;
   GdkWindow *ipc_window;
+  gint start_x, start_y;
 
   pointer = keyboard = NULL;
   ipc_widget = gtk_drag_get_ipc_widget (widget);
@@ -2244,7 +2245,24 @@ gtk_drag_begin_internal (GtkWidget          *widget,
 
   source_widgets = g_slist_prepend (source_widgets, ipc_widget);
 
-  context = gdk_drag_begin_for_device (ipc_window, pointer, targets);
+  if (x != -1 && y != -1)
+    {
+      GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
+      gtk_widget_translate_coordinates (widget, toplevel,
+                                        x, y, &x, &y);
+      gdk_window_get_root_coords (gtk_widget_get_window (toplevel),
+                                  x, y, &start_x, &start_y);
+    }
+  else if (event && event->type == GDK_MOTION_NOTIFY)
+    {
+      start_x = event->motion.x_root;
+      start_y = event->motion.y_root;
+    }
+  else
+    gdk_device_get_position (pointer, NULL, &start_x, &start_y);
+
+  context = gdk_drag_begin_from_point (ipc_window, pointer, targets, start_x, start_y);
+
   gdk_drag_context_set_device (context, pointer);
   g_list_free (targets);
   
@@ -2269,30 +2287,13 @@ gtk_drag_begin_internal (GtkWidget          *widget,
   info->icon_widget = NULL;
   info->destroy_icon = FALSE;
 
-  /* Set cur_x, cur_y here so if the "drag-begin" signal shows
-   * the drag icon, it will be in the right place
-   */
   if (event)
     info->cur_screen = gdk_event_get_screen (event);
   else
     gdk_device_get_position (pointer, &info->cur_screen, NULL, NULL);
 
-  if (x != -1 && y != -1)
-    {
-      GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
-      gtk_widget_translate_coordinates (widget, toplevel,
-                                        x, y, &x, &y);
-      gdk_window_get_root_coords (gtk_widget_get_window (toplevel),
-                                  x, y, &info->start_x, &info->start_y);
-    }
-  else if (event && event->type == GDK_MOTION_NOTIFY)
-    {
-      info->start_x = event->motion.x_root;
-      info->start_y = event->motion.y_root;
-    }
-  else
-    gdk_device_get_position (pointer, NULL, &info->start_x, &info->start_y);
-
+  info->start_x = start_x;
+  info->start_y = start_y;
 
   g_signal_emit_by_name (widget, "drag-begin", info->context);
 


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