[gtk+/xi2] Add gdk_drag_context_[gs]et_device().
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2] Add gdk_drag_context_[gs]et_device().
- Date: Sat, 9 Jan 2010 12:46:32 +0000 (UTC)
commit 542b7de01c027f113dca9e813f062d4151b70604
Author: Carlos Garnacho <carlos gnome org>
Date: Thu Dec 31 11:43:29 2009 +0100
Add gdk_drag_context_[gs]et_device().
This is used to attach a DnD operation to a specific pointer.
gdk_drag_context_new() will contain no pointer by default, and
gdk_drag_begin() will have the GdkDragContext attached to the
window's display core pointer by default.
gdk/gdkdnd.h | 6 ++++++
gdk/x11/gdkdnd-x11.c | 42 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/gdk/gdkdnd.h b/gdk/gdkdnd.h
index b9f8335..3c63a6e 100644
--- a/gdk/gdkdnd.h
+++ b/gdk/gdkdnd.h
@@ -32,6 +32,7 @@
#define __GDK_DND_H__
#include <gdk/gdktypes.h>
+#include <gdk/gdkdevice.h>
G_BEGIN_DECLS
@@ -112,6 +113,11 @@ void gdk_drag_context_ref (GdkDragContext *context);
void gdk_drag_context_unref (GdkDragContext *context);
#endif
+void gdk_drag_context_set_device (GdkDragContext *context,
+ GdkDevice *device);
+GdkDevice * gdk_drag_context_get_device (GdkDragContext *context);
+
+
/* Destination side */
void gdk_drag_status (GdkDragContext *context,
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index c7c803a..79be459 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -89,6 +89,7 @@ struct _GdkDragContextPrivateX11 {
guint version; /* Xdnd protocol version */
GSList *window_caches;
+ GdkDevice *device;
};
#define PRIVATE_DATA(context) ((GdkDragContextPrivateX11 *) GDK_DRAG_CONTEXT (context)->windowing_data)
@@ -245,6 +246,39 @@ gdk_drag_context_unref (GdkDragContext *context)
g_object_unref (context);
}
+void
+gdk_drag_context_set_device (GdkDragContext *context,
+ GdkDevice *device)
+{
+ GdkDragContextPrivateX11 *private;
+
+ g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+ g_return_if_fail (GDK_IS_DEVICE (device));
+
+ private = PRIVATE_DATA (context);
+
+ if (private->device)
+ {
+ g_object_unref (private->device);
+ private->device = NULL;
+ }
+
+ if (device)
+ private->device = g_object_ref (device);
+}
+
+GdkDevice *
+gdk_drag_context_get_device (GdkDragContext *context)
+{
+ GdkDragContextPrivateX11 *private;
+
+ g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
+
+ private = PRIVATE_DATA (context);
+
+ return private->device;
+}
+
static GdkDragContext *
gdk_drag_context_find (GdkDisplay *display,
gboolean is_source,
@@ -2220,7 +2254,7 @@ xdnd_send_xevent (GdkDragContext *context,
GdkEvent temp_event;
temp_event.any.window = window;
- if ((*xdnd_filters[i].func) (event_send, &temp_event, NULL) == GDK_FILTER_TRANSLATE)
+ if ((*xdnd_filters[i].func) (event_send, &temp_event, NULL) == GDK_FILTER_TRANSLATE)
{
gdk_event_put (&temp_event);
g_object_unref (temp_event.dnd.context);
@@ -2994,6 +3028,8 @@ gdk_drag_begin (GdkWindow *window,
GList *targets)
{
GdkDragContext *new_context;
+ GdkDisplay *display;
+ GdkDevice *device;
g_return_val_if_fail (window != NULL, NULL);
g_return_val_if_fail (GDK_WINDOW_IS_X11 (window), NULL);
@@ -3008,6 +3044,10 @@ gdk_drag_begin (GdkWindow *window,
new_context->actions = 0;
+ display = gdk_drawable_get_display (GDK_DRAWABLE (window));
+ device = gdk_display_get_core_pointer (display);
+ gdk_drag_context_set_device (new_context, device);
+
return new_context;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]