[gtk+] gdk: Add api to set drag window hotspot



commit f4ebdb64eefefa8b6562b1077bac296f561d53de
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Dec 7 21:52:03 2015 -0500

    gdk: Add api to set drag window hotspot
    
    With GdkDragContext now being in charge of placing the window,
    it needs to know about the hotspot to place under the cursor.

 docs/reference/gdk/gdk3-sections.txt |    1 +
 gdk/gdkdnd.c                         |   23 +++++++++++++++++++++++
 gdk/gdkdnd.h                         |    5 +++++
 gdk/gdkdndprivate.h                  |    3 +++
 4 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index b26ede0..a2ab5d8 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -968,6 +968,7 @@ gdk_drag_context_get_source_window
 gdk_drag_context_get_dest_window
 gdk_drag_context_get_protocol
 gdk_drag_context_get_drag_window
+gdk_drag_context_set_hotspot
 
 <SUBSECTION Standard>
 GDK_DRAG_CONTEXT
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
index 691b52b..8a4559e 100644
--- a/gdk/gdkdnd.c
+++ b/gdk/gdkdnd.c
@@ -480,3 +480,26 @@ gdk_drag_context_get_drag_window (GdkDragContext *context)
 
   return NULL;
 }
+
+/**
+ * gdk_drag_context_set_hotspot:
+ * @context: a #GdkDragContext
+ * @hot_x: x coordinate of the drag window hotspot
+ * @hot_y: y coordinate of the drag window hotspot
+ *
+ * Sets the position of the drag window that will be kept
+ * under the cursor hotspot. Initially, the hotspot is at the
+ * top left corner of the drag window.
+ *
+ * Since: 3.20
+ */
+void
+gdk_drag_context_set_hotspot (GdkDragContext *context,
+                              gint            hot_x,
+                              gint            hot_y)
+{
+  g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+
+  if (GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot)
+    GDK_DRAG_CONTEXT_GET_CLASS (context)->set_hotspot (context, hot_x, hot_y);
+}
diff --git a/gdk/gdkdnd.h b/gdk/gdkdnd.h
index 4d2cd65..bcac0a6 100644
--- a/gdk/gdkdnd.h
+++ b/gdk/gdkdnd.h
@@ -174,6 +174,11 @@ gboolean        gdk_drag_drop_succeeded (GdkDragContext *context);
 GDK_AVAILABLE_IN_3_20
 GdkWindow      *gdk_drag_context_get_drag_window (GdkDragContext *context);
 
+GDK_AVAILABLE_IN_3_20
+void            gdk_drag_context_set_hotspot (GdkDragContext *context,
+                                              gint            hot_x,
+                                              gint            hot_y);
+
 G_END_DECLS
 
 #endif /* __GDK_DND_H__ */
diff --git a/gdk/gdkdndprivate.h b/gdk/gdkdndprivate.h
index be1626f..e8a163f 100644
--- a/gdk/gdkdndprivate.h
+++ b/gdk/gdkdndprivate.h
@@ -63,6 +63,9 @@ struct _GdkDragContextClass {
                                 guint32          time_);
   gboolean    (*drop_status)   (GdkDragContext  *context);
   GdkWindow*  (*get_drag_window) (GdkDragContext *context);
+  void        (*set_hotspot)   (GdkDragContext  *context,
+                                gint             hot_x,
+                                gint             hot_y);
 };
 
 struct _GdkDragContext {


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