[gtk+/wip/matthiasc/dnd-animation: 1/7] gdk: Allow passing the start coordinates in drag_begin



commit 268c7a3e44bbedd71f93b9456f91e0116b79dc71
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Dec 7 13:47:45 2015 -0500

    gdk: Allow passing the start coordinates in drag_begin
    
    Add a variant of gdk_drag_begin that takes the start position
    in addition to the device. All backend implementation have been
    updated to accept (and ignore) the new arguments.
    
    Subsequent commits will make use of the data in some backends.

 docs/reference/gdk/gdk3-sections.txt |    1 +
 gdk/broadway/gdkdnd-broadway.c       |    4 ++-
 gdk/broadway/gdkprivate-broadway.h   |    4 ++-
 gdk/gdkdnd.h                         |    7 ++++++
 gdk/gdkwindow.c                      |   39 ++++++++++++++++++++++++++++++---
 gdk/gdkwindowimpl.h                  |    4 ++-
 gdk/quartz/gdkdnd-quartz.c           |    4 ++-
 gdk/quartz/gdkprivate-quartz.h       |    4 ++-
 gdk/wayland/gdkdnd-wayland.c         |    4 ++-
 gdk/wayland/gdkprivate-wayland.h     |    5 ++-
 gdk/win32/gdkdnd-win32.c             |    4 ++-
 gdk/win32/gdkprivate-win32.h         |    2 +-
 gdk/x11/gdkdnd-x11.c                 |    4 ++-
 gdk/x11/gdkprivate-x11.h             |    4 ++-
 14 files changed, 74 insertions(+), 16 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index a2ab5d8..414cf26 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -950,6 +950,7 @@ gdk_drag_drop
 gdk_drag_find_window_for_screen
 gdk_drag_begin
 gdk_drag_begin_for_device
+gdk_drag_begin_from_point
 gdk_drag_motion
 gdk_drop_finish
 GdkDragProtocol
diff --git a/gdk/broadway/gdkdnd-broadway.c b/gdk/broadway/gdkdnd-broadway.c
index 06dcd8f..042a0cd 100644
--- a/gdk/broadway/gdkdnd-broadway.c
+++ b/gdk/broadway/gdkdnd-broadway.c
@@ -87,7 +87,9 @@ gdk_broadway_drag_context_finalize (GObject *object)
 GdkDragContext *
 _gdk_broadway_window_drag_begin (GdkWindow *window,
                                 GdkDevice *device,
-                                GList     *targets)
+                                GList     *targets,
+                                 gint       x_root,
+                                 gint       y_root)
 {
   GdkDragContext *new_context;
 
diff --git a/gdk/broadway/gdkprivate-broadway.h b/gdk/broadway/gdkprivate-broadway.h
index 45a1c82..aa52ccb 100644
--- a/gdk/broadway/gdkprivate-broadway.h
+++ b/gdk/broadway/gdkprivate-broadway.h
@@ -44,7 +44,9 @@ void _gdk_broadway_resync_windows (void);
 void     _gdk_broadway_window_register_dnd (GdkWindow      *window);
 GdkDragContext * _gdk_broadway_window_drag_begin (GdkWindow *window,
                                                  GdkDevice *device,
-                                                 GList     *targets);
+                                                 GList     *targets,
+                                                  gint       x_root,
+                                                  gint       y_root);
 void     _gdk_broadway_window_translate         (GdkWindow *window,
                                                 cairo_region_t *area,
                                                 gint       dx,
diff --git a/gdk/gdkdnd.h b/gdk/gdkdnd.h
index bcac0a6..12a817f 100644
--- a/gdk/gdkdnd.h
+++ b/gdk/gdkdnd.h
@@ -31,6 +31,7 @@
 
 #include <gdk/gdktypes.h>
 #include <gdk/gdkdevice.h>
+#include <gdk/gdkevents.h>
 
 G_BEGIN_DECLS
 
@@ -143,6 +144,12 @@ GDK_AVAILABLE_IN_ALL
 GdkDragContext * gdk_drag_begin_for_device (GdkWindow      *window,
                                             GdkDevice      *device,
                                             GList          *targets);
+GDK_AVAILABLE_IN_3_20
+GdkDragContext * gdk_drag_begin_from_point  (GdkWindow      *window,
+                                             GdkDevice      *device,
+                                             GList          *targets,
+                                             gint            x_root,
+                                             gint            y_root);
 
 GDK_AVAILABLE_IN_ALL
 void    gdk_drag_find_window_for_screen   (GdkDragContext   *context,
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 7e2dfb7..bd32ad1 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -11014,11 +11014,42 @@ gdk_drag_begin (GdkWindow     *window,
  * Returns: (transfer full): a newly created #GdkDragContext
  */
 GdkDragContext *
-gdk_drag_begin_for_device (GdkWindow     *window,
-                           GdkDevice     *device,
-                           GList         *targets)
+gdk_drag_begin_for_device (GdkWindow *window,
+                           GdkDevice *device,
+                           GList     *targets)
 {
-  return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->drag_begin (window, device, targets);
+  gint x, y;
+
+  gdk_device_get_position (device, NULL, &x, &y);
+
+  return gdk_drag_begin_from_point (window, device, targets, x, y);
+}
+
+/**
+ * gdk_drag_begin_from_point:
+ * @window: the source window for this drag
+ * @device: the device that controls this drag
+ * @targets: (transfer none) (element-type GdkAtom): the offered targets,
+ *     as list of #GdkAtoms
+ * @x_root: the x coordinate where the drag nominally started
+ * @y_root: the y coordinate where the drag nominally started
+ *
+ * Starts a drag and creates a new drag context for it.
+ *
+ * This function is called by the drag source.
+ *
+ * Returns: (transfer full): a newly created #GdkDragContext
+ *
+ * Since: 3.20
+ */
+GdkDragContext *
+gdk_drag_begin_from_point (GdkWindow *window,
+                           GdkDevice *device,
+                           GList     *targets,
+                           gint       x_root,
+                           gint       y_root)
+{
+  return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->drag_begin (window, device, targets, x_root, y_root);
 }
 
 /**
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index 07a307c..f074343 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -239,7 +239,9 @@ struct _GdkWindowImplClass
   void         (* register_dnd)         (GdkWindow *window);
   GdkDragContext * (*drag_begin)        (GdkWindow *window,
                                          GdkDevice *device,
-                                         GList     *targets);
+                                         GList     *targets,
+                                         gint       x_root,
+                                         gint       y_root);
 
   void         (*process_updates_recurse) (GdkWindow      *window,
                                            cairo_region_t *region);
diff --git a/gdk/quartz/gdkdnd-quartz.c b/gdk/quartz/gdkdnd-quartz.c
index bb4a8f3..0a38cd8 100644
--- a/gdk/quartz/gdkdnd-quartz.c
+++ b/gdk/quartz/gdkdnd-quartz.c
@@ -35,7 +35,9 @@ gdk_quartz_drag_source_context ()
 GdkDragContext *
 _gdk_quartz_window_drag_begin (GdkWindow *window,
                                GdkDevice *device,
-                               GList     *targets)
+                               GList     *targets,
+                               gint       x_root,
+                               gint       y_root)
 {
   g_assert (_gdk_quartz_drag_source_context == NULL);
 
diff --git a/gdk/quartz/gdkprivate-quartz.h b/gdk/quartz/gdkprivate-quartz.h
index 5d2fcc1..1a7410c 100644
--- a/gdk/quartz/gdkprivate-quartz.h
+++ b/gdk/quartz/gdkprivate-quartz.h
@@ -80,7 +80,9 @@ void         _gdk_quartz_synthesize_null_key_event (GdkWindow *window);
 void        _gdk_quartz_window_register_dnd      (GdkWindow   *window);
 GdkDragContext * _gdk_quartz_window_drag_begin   (GdkWindow   *window,
                                                   GdkDevice   *device,
-                                                  GList       *targets);
+                                                  GList       *targets,
+                                                  gint         x_root,
+                                                  gint         y_root);
 
 /* Display */
 
diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c
index fd0d0a3..36259e9 100644
--- a/gdk/wayland/gdkdnd-wayland.c
+++ b/gdk/wayland/gdkdnd-wayland.c
@@ -375,7 +375,9 @@ create_dnd_window (GdkScreen *screen)
 GdkDragContext *
 _gdk_wayland_window_drag_begin (GdkWindow *window,
                                GdkDevice *device,
-                               GList     *targets)
+                               GList     *targets,
+                                gint       x_root,
+                                gint       y_root)
 {
   GdkWaylandDragContext *context_wayland;
   GdkWaylandDisplay *display_wayland;
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index c4b5185..0e486f8 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -103,11 +103,12 @@ GdkDragProtocol _gdk_wayland_window_get_drag_protocol (GdkWindow *window,
 void            _gdk_wayland_window_register_dnd (GdkWindow *window);
 GdkDragContext *_gdk_wayland_window_drag_begin (GdkWindow *window,
                                                GdkDevice *device,
-                                               GList     *targets);
+                                               GList     *targets,
+                                                gint       x_root,
+                                                gint       y_root);
 void            _gdk_wayland_window_offset_next_wl_buffer (GdkWindow *window,
                                                            int        x,
                                                            int        y);
-
 GdkDragContext * _gdk_wayland_drop_context_new (struct wl_data_device *data_device);
 void _gdk_wayland_drag_context_set_source_window (GdkDragContext *context,
                                                   GdkWindow      *window);
diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c
index ca658cc..f0a1f97 100644
--- a/gdk/win32/gdkdnd-win32.c
+++ b/gdk/win32/gdkdnd-win32.c
@@ -1807,7 +1807,9 @@ gdk_drag_do_leave (GdkDragContext *context,
 GdkDragContext *
 _gdk_win32_window_drag_begin (GdkWindow *window,
                              GdkDevice *device,
-                             GList     *targets)
+                             GList     *targets,
+                              gint       x_root,
+                              gint       y_root)
 {
   if (!use_ole2_dnd)
     {
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index a94a188..f216d38 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -484,7 +484,7 @@ void       _gdk_win32_display_create_window_impl   (GdkDisplay    *display,
 
 /* stray GdkWindowImplWin32 members */
 void _gdk_win32_window_register_dnd (GdkWindow *window);
-GdkDragContext *_gdk_win32_window_drag_begin (GdkWindow *window, GdkDevice *device, GList *targets);
+GdkDragContext *_gdk_win32_window_drag_begin (GdkWindow *window, GdkDevice *device, GList *targets, gint 
x_root, gint y_root);
 gboolean _gdk_win32_window_simulate_key (GdkWindow      *window,
                                  gint            x,
                                  gint            y,
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index d0c8757..02d7e33 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -1948,7 +1948,9 @@ create_drag_window (GdkScreen *screen)
 GdkDragContext *
 _gdk_x11_window_drag_begin (GdkWindow *window,
                             GdkDevice *device,
-                            GList     *targets)
+                            GList     *targets,
+                            gint       x_root,
+                            gint       y_root)
 {
   GdkDragContext *context;
 
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index c2afecf..f35d2af 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -312,7 +312,9 @@ void _gdk_x11_window_register_dnd (GdkWindow *window);
 
 GdkDragContext * _gdk_x11_window_drag_begin (GdkWindow *window,
                                              GdkDevice *device,
-                                             GList     *targets);
+                                             GList     *targets,
+                                             gint       x_root,
+                                             gint       y_root);
 
 gboolean _gdk_x11_get_xft_setting (GdkScreen   *screen,
                                    const gchar *name,


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