From f4ebdb64eefefa8b6562b1077bac296f561d53de Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 7 Dec 2015 21:52:03 -0500 Subject: [PATCH] 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(+) diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index b26ede0ae2..a2ab5d8c17 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 GDK_DRAG_CONTEXT diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index 691b52bff5..8a4559e286 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 4d2cd65a7d..bcac0a6f9f 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 be1626fcbd..e8a163f7c8 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 {