* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include <config.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <string.h>
+#include "config.h"
+
+#include "gdkdnd.h"
-#include "gdk.h" /* For gdk_flush() */
+#include "gdkmain.h"
#include "gdkx.h"
#include "gdkasync.h"
-#include "gdkdnd.h"
#include "gdkproperty.h"
#include "gdkprivate-x11.h"
#include "gdkinternals.h"
#include "gdkscreen-x11.h"
#include "gdkdisplay-x11.h"
-#include "gdkalias.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/extensions/shape.h>
+#include <X11/extensions/Xcomposite.h>
+
+#include <string.h>
typedef struct _GdkDragContextPrivateX11 GdkDragContextPrivateX11;
guint32 xid;
gint x, y, width, height;
gboolean mapped;
+ gboolean shape_selected;
+ gboolean shape_valid;
+ cairo_region_t *shape;
} GdkCacheChild;
typedef struct {
guint version; /* Xdnd protocol version */
GSList *window_caches;
+ GdkDevice *device;
};
#define PRIVATE_DATA(context) ((GdkDragContextPrivateX11 *) GDK_DRAG_CONTEXT (context)->windowing_data)
static GList *contexts;
-const static struct {
+static const struct {
const char *atom_name;
GdkFilterFunc func;
} xdnd_filters[] = {
{ "XdndDrop", xdnd_drop_filter },
};
-G_DEFINE_TYPE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT);
+G_DEFINE_TYPE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
static void
gdk_drag_context_init (GdkDragContext *dragcontext)
}
/**
- * gdk_drag_context_ref:
- * @context: a #GdkDragContext.
- *
- * Deprecated function; use g_object_ref() instead.
+ * gdk_drag_context_set_device:
+ * @context: a #GdkDragContext
+ * @device: a #GdkDevice
+ *
+ * Associates a #GdkDevice to @context, so all Drag and Drop events
+ * for @context are emitted as if they came from this device.
**/
-void
-gdk_drag_context_ref (GdkDragContext *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));
- g_object_ref (context);
+ private = PRIVATE_DATA (context);
+
+ if (private->device)
+ {
+ g_object_unref (private->device);
+ private->device = NULL;
+ }
+
+ if (device)
+ private->device = g_object_ref (device);
}
/**
- * gdk_drag_context_unref:
- * @context: a #GdkDragContext.
- *
- * Deprecated function; use g_object_unref() instead.
+ * gdk_drag_context_get_device:
+ * @context: a #GdkDragContext
+ *
+ * Returns the #GdkDevice associated to the drag context.
+ *
+ * Returns: (transfer none): The #GdkDevice associated to @context.
**/
-void
-gdk_drag_context_unref (GdkDragContext *context)
+GdkDevice *
+gdk_drag_context_get_device (GdkDragContext *context)
{
- g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+ GdkDragContextPrivateX11 *private;
- g_object_unref (context);
+ g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
+
+ private = PRIVATE_DATA (context);
+
+ return private->device;
}
static GdkDragContext *
context = (GdkDragContext *)tmp_list->data;
private = PRIVATE_DATA (context);
- if ((context->source_window && gdk_drawable_get_display (context->source_window) != display) ||
- (context->dest_window && gdk_drawable_get_display (context->dest_window) != display))
+ if ((context->source_window && gdk_window_get_display (context->source_window) != display) ||
+ (context->dest_window && gdk_window_get_display (context->dest_window) != display))
continue;
context_dest_xid = context->dest_window ?
(private->drop_xid ?
private->drop_xid :
- GDK_DRAWABLE_XID (context->dest_window)) :
+ GDK_WINDOW_XID (context->dest_window)) :
None;
if ((!context->is_source == !is_source) &&
((source_xid == None) || (context->source_window &&
- (GDK_DRAWABLE_XID (context->source_window) == source_xid))) &&
+ (GDK_WINDOW_XID (context->source_window) == source_xid))) &&
((dest_xid == None) || (context_dest_xid == dest_xid)))
return context;
/* Utility functions */
+static void
+free_cache_child (GdkCacheChild *child,
+ GdkDisplay *display)
+{
+ if (child->shape)
+ cairo_region_destroy (child->shape);
+
+ if (child->shape_selected && display)
+ {
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
+
+ XShapeSelectInput (display_x11->xdisplay, child->xid, 0);
+ }
+
+ g_free (child);
+}
+
static void
gdk_window_cache_add (GdkWindowCache *cache,
guint32 xid,
child->width = width;
child->height = height;
child->mapped = mapped;
+ child->shape_selected = FALSE;
+ child->shape_valid = FALSE;
+ child->shape = NULL;
cache->children = g_list_prepend (cache->children, child);
g_hash_table_insert (cache->child_hash, GUINT_TO_POINTER (xid),
cache->children);
}
+static GdkFilterReturn
+gdk_window_cache_shape_filter (GdkXEvent *xev,
+ GdkEvent *event,
+ gpointer data)
+{
+ XEvent *xevent = (XEvent *)xev;
+ GdkWindowCache *cache = data;
+
+ GdkDisplayX11 *display = GDK_DISPLAY_X11 (gdk_screen_get_display (cache->screen));
+
+ if (display->have_shapes &&
+ xevent->type == display->shape_event_base + ShapeNotify)
+ {
+ XShapeEvent *xse = (XShapeEvent*)xevent;
+ GList *node;
+
+ node = g_hash_table_lookup (cache->child_hash,
+ GUINT_TO_POINTER (xse->window));
+ if (node)
+ {
+ GdkCacheChild *child = node->data;
+ child->shape_valid = FALSE;
+ if (child->shape)
+ {
+ cairo_region_destroy (child->shape);
+ child->shape = NULL;
+ }
+ }
+
+ return GDK_FILTER_REMOVE;
+ }
+
+ return GDK_FILTER_CONTINUE;
+}
+
static GdkFilterReturn
gdk_window_cache_filter (GdkXEvent *xev,
GdkEvent *event,
GUINT_TO_POINTER (xdwe->window));
if (node)
{
+ GdkCacheChild *child = node->data;
+
g_hash_table_remove (cache->child_hash,
GUINT_TO_POINTER (xdwe->window));
cache->children = g_list_remove_link (cache->children, node);
- g_free (node->data);
+ /* window is destroyed, no need to disable ShapeNotify */
+ free_cache_child (child, NULL);
g_list_free_1 (node);
}
break;
node = g_hash_table_lookup (cache->child_hash,
GUINT_TO_POINTER (xume->window));
- if (node)
+ if (node)
{
GdkCacheChild *child = node->data;
child->mapped = FALSE;
GdkWindow *root_window = gdk_screen_get_root_window (screen);
GdkChildInfoX11 *children;
guint nchildren, i;
+ Window cow;
GdkWindowCache *result = g_new (GdkWindowCache, 1);
XGetWindowAttributes (xdisplay, GDK_WINDOW_XWINDOW (root_window), &xwa);
result->old_event_mask = xwa.your_event_mask;
+
+ if (G_UNLIKELY (!GDK_DISPLAY_X11 (GDK_SCREEN_X11 (screen)->display)->trusted_client))
+ {
+ GList *toplevel_windows, *list;
+ GdkWindow *window;
+ gint x, y, width, height;
+
+ toplevel_windows = gdk_screen_get_toplevel_windows (screen);
+ for (list = toplevel_windows; list; list = list->next) {
+ window = GDK_WINDOW (list->data);
+ gdk_window_get_geometry (window, &x, &y, &width, &height, NULL);
+ gdk_window_cache_add (result, GDK_WINDOW_XID (window),
+ x, y, width, height,
+ gdk_window_is_visible (window));
+ }
+ g_list_free (toplevel_windows);
+ return result;
+ }
+
XSelectInput (xdisplay, GDK_WINDOW_XWINDOW (root_window),
result->old_event_mask | SubstructureNotifyMask);
gdk_window_add_filter (root_window, gdk_window_cache_filter, result);
+ gdk_window_add_filter (NULL, gdk_window_cache_shape_filter, result);
if (!_gdk_x11_get_window_child_info (gdk_screen_get_display (screen),
GDK_WINDOW_XWINDOW (root_window),
g_free (children);
+#ifdef HAVE_XCOMPOSITE
+ /*
+ * Add the composite overlay window to the cache, as this can be a reasonable
+ * Xdnd proxy as well.
+ * This is only done when the screen is composited in order to avoid mapping
+ * the COW. We assume that the CM is using the COW (which is true for pretty
+ * much any CM currently in use).
+ */
+ if (gdk_screen_is_composited (screen))
+ {
+ cow = XCompositeGetOverlayWindow (xdisplay, GDK_WINDOW_XWINDOW (root_window));
+ gdk_window_cache_add (result, cow, 0, 0, gdk_screen_get_width (screen), gdk_screen_get_height (screen), TRUE);
+ XCompositeReleaseOverlayWindow (xdisplay, GDK_WINDOW_XWINDOW (root_window));
+ }
+#endif
+
return result;
}
gdk_window_cache_destroy (GdkWindowCache *cache)
{
GdkWindow *root_window = gdk_screen_get_root_window (cache->screen);
-
- XSelectInput (GDK_WINDOW_XDISPLAY (root_window),
+
+ XSelectInput (GDK_WINDOW_XDISPLAY (root_window),
GDK_WINDOW_XWINDOW (root_window),
cache->old_event_mask);
gdk_window_remove_filter (root_window, gdk_window_cache_filter, cache);
+ gdk_window_remove_filter (NULL, gdk_window_cache_shape_filter, cache);
+
+ gdk_error_trap_push ();
+
+ g_list_foreach (cache->children, (GFunc)free_cache_child,
+ gdk_screen_get_display (cache->screen));
+
+ gdk_error_trap_pop_ignored ();
- g_list_foreach (cache->children, (GFunc)g_free, NULL);
g_list_free (cache->children);
g_hash_table_destroy (cache->child_hash);
g_free (cache);
}
+static gboolean
+is_pointer_within_shape (GdkDisplay *display,
+ GdkCacheChild *child,
+ gint x_pos,
+ gint y_pos)
+{
+ if (!child->shape_selected)
+ {
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
+
+ XShapeSelectInput (display_x11->xdisplay, child->xid, ShapeNotifyMask);
+ child->shape_selected = TRUE;
+ }
+ if (!child->shape_valid)
+ {
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
+ cairo_region_t *input_shape;
+
+ child->shape = _xwindow_get_shape (display_x11->xdisplay,
+ child->xid, ShapeBounding);
+#ifdef ShapeInput
+ input_shape = _xwindow_get_shape (display_x11->xdisplay,
+ child->xid, ShapeInput);
+ if (child->shape && input_shape)
+ {
+ cairo_region_intersect (child->shape, input_shape);
+ cairo_region_destroy (input_shape);
+ }
+ else if (input_shape)
+ {
+ child->shape = input_shape;
+ }
+#endif
+
+ child->shape_valid = TRUE;
+ }
+
+ return child->shape == NULL ||
+ cairo_region_contains_point (child->shape, x_pos, y_pos);
+}
+
static Window
get_client_window_at_coords_recurse (GdkDisplay *display,
Window win,
GdkCacheChild *child = tmp_list->data;
if ((child->xid != ignore) && (child->mapped))
- {
- if ((x_root >= child->x) && (x_root < child->x + child->width) &&
- (y_root >= child->y) && (y_root < child->y + child->height))
- {
- retval = get_client_window_at_coords_recurse (gdk_screen_get_display (cache->screen),
- child->xid, TRUE,
- x_root - child->x,
- y_root - child->y);
- if (!retval)
- retval = child->xid;
- }
-
- }
+ {
+ if ((x_root >= child->x) && (x_root < child->x + child->width) &&
+ (y_root >= child->y) && (y_root < child->y + child->height))
+ {
+ GdkDisplay *display = gdk_screen_get_display (cache->screen);
+
+ if (!is_pointer_within_shape (display, child,
+ x_root - child->x,
+ y_root - child->y))
+ {
+ tmp_list = tmp_list->next;
+ continue;
+ }
+
+ retval = get_client_window_at_coords_recurse (display,
+ child->xid, TRUE,
+ x_root - child->x,
+ y_root - child->y);
+ if (!retval)
+ retval = child->xid;
+ }
+ }
tmp_list = tmp_list->next;
}
- gdk_error_trap_pop ();
+ gdk_error_trap_pop_ignored ();
if (retval)
return retval;
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
MotifDragInitiatorInfo info;
gint i;
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
info.byte_order = local_byte_order;
info.protocol_version = 0;
info.selection_atom = private->motif_selection;
- XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
- GDK_DRAWABLE_XID (context->source_window),
+ XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
+ GDK_WINDOW_XID (context->source_window),
private->motif_selection,
gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_INITIATOR_INFO"),
8, PropModeReplace,
guint32 time)
{
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
XEvent xev;
+ if (!G_LIKELY (GDK_DISPLAY_X11 (display)->trusted_client))
+ return; /* Motif Dnd requires getting properties on the root window */
+
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE");
xev.xclient.format = 8;
- xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
+ xev.xclient.window = GDK_WINDOW_XID (context->dest_window);
MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_ENTER;
MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
MOTIF_XCLIENT_SHORT (&xev, 1) = 0;
MOTIF_XCLIENT_LONG (&xev, 1) = time;
- MOTIF_XCLIENT_LONG (&xev, 2) = GDK_DRAWABLE_XID (context->source_window);
+ MOTIF_XCLIENT_LONG (&xev, 2) = GDK_WINDOW_XID (context->source_window);
if (!private->motif_targets_set)
motif_set_targets (context);
MOTIF_XCLIENT_LONG (&xev, 4) = 0;
if (!_gdk_send_xevent (display,
- GDK_DRAWABLE_XID (context->dest_window),
+ GDK_WINDOW_XID (context->dest_window),
FALSE, 0, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->dest_window)));
+ GDK_WINDOW_XID (context->dest_window)));
}
static void
motif_send_leave (GdkDragContext *context,
guint32 time)
{
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE");
xev.xclient.format = 8;
- xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
+ xev.xclient.window = GDK_WINDOW_XID (context->dest_window);
MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_LEAVE;
MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
MOTIF_XCLIENT_LONG (&xev, 4) = 0;
if (!_gdk_send_xevent (display,
- GDK_DRAWABLE_XID (context->dest_window),
+ GDK_WINDOW_XID (context->dest_window),
FALSE, 0, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->dest_window)));
+ GDK_WINDOW_XID (context->dest_window)));
}
static gboolean
guint32 time)
{
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
gboolean retval;
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE");
xev.xclient.format = 8;
- xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
+ xev.xclient.window = GDK_WINDOW_XID (context->dest_window);
MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
MOTIF_XCLIENT_SHORT (&xev, 1) = motif_dnd_get_flags (context);
}
if (!_gdk_send_xevent (display,
- GDK_DRAWABLE_XID (context->dest_window),
+ GDK_WINDOW_XID (context->dest_window),
FALSE, 0, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->dest_window)));
+ GDK_WINDOW_XID (context->dest_window)));
return retval;
}
motif_send_drop (GdkDragContext *context, guint32 time)
{
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE");
xev.xclient.format = 8;
- xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
+ xev.xclient.window = GDK_WINDOW_XID (context->dest_window);
MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START;
MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
MOTIF_XCLIENT_SHORT (&xev, 5) = private->last_y;
MOTIF_XCLIENT_LONG (&xev, 3) = private->motif_selection;
- MOTIF_XCLIENT_LONG (&xev, 4) = GDK_DRAWABLE_XID (context->source_window);
+ MOTIF_XCLIENT_LONG (&xev, 4) = GDK_WINDOW_XID (context->source_window);
if (!_gdk_send_xevent (display,
- GDK_DRAWABLE_XID (context->dest_window),
+ GDK_WINDOW_XID (context->dest_window),
FALSE, 0, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->dest_window)));
+ GDK_WINDOW_XID (context->dest_window)));
}
/* Target Side */
{
GdkDragContext *new_context;
GdkDragContextPrivateX11 *private;
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (dest_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (dest_window);
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
/* FIXME, current_dest_drag really shouldn't be NULL'd
guint32 source_window,
guint32 atom)
{
- GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_DRAWABLE_DISPLAY (event->any.window));
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (event->any.window));
GdkDragContext *new_context;
GDK_NOTE(DND, g_message ("Motif DND top level enter: flags: %#4x time: %d source_widow: %#4x atom: %d",
guint16 flags,
guint32 timestamp)
{
- GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_DRAWABLE_DISPLAY (event->any.window));
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (event->any.window));
GDK_NOTE(DND, g_message ("Motif DND top level leave: flags: %#4x time: %d",
flags, timestamp));
gint16 y_root)
{
GdkDragContextPrivateX11 *private;
- GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_DRAWABLE_DISPLAY (event->any.window));
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (event->any.window));
GDK_NOTE(DND, g_message ("Motif DND motion: flags: %#4x time: %d (%d, %d)",
flags, timestamp, x_root, y_root));
guint32 timestamp)
{
GdkDragContextPrivateX11 *private;
- GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_DRAWABLE_DISPLAY (event->any.window));
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (event->any.window));
GDK_NOTE(DND, g_message ("Motif DND operation changed: flags: %#4x time: %d",
flags, timestamp));
gint16 y_root)
{
GdkDragContext *new_context;
- GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_DRAWABLE_DISPLAY (event->any.window));
+ GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (event->any.window));
GDK_NOTE(DND, g_message ("Motif DND drop start: flags: %#4x time: %d (%d, %d) source_widow: %#4x atom: %d",
flags, timestamp, x_root, y_root, source_window, atom));
GDK_NOTE (DND,
g_message ("Motif status message: flags %x", flags));
- display = gdk_drawable_get_display (event->any.window);
+ display = gdk_window_get_display (event->any.window);
if (!display)
return GDK_FILTER_REMOVE;
- context = gdk_drag_context_find (display, TRUE, GDK_DRAWABLE_XID (event->any.window), None);
+ context = gdk_drag_context_find (display, TRUE, GDK_WINDOW_XID (event->any.window), None);
if (context)
{
xdnd_action_from_atom (GdkDisplay *display,
Atom xatom)
{
- GdkAtom atom = gdk_x11_xatom_to_atom_for_display (display, xatom);
+ GdkAtom atom;
gint i;
+ if (xatom == None)
+ return 0;
+
+ atom = gdk_x11_xatom_to_atom_for_display (display, xatom);
+
if (!xdnd_actions_initialized)
xdnd_initialize_actions();
g_message ("XdndStatus: dest_window: %#x action: %ld",
dest_window, action));
- display = gdk_drawable_get_display (event->any.window);
+ display = gdk_window_get_display (event->any.window);
context = gdk_drag_context_find (display, TRUE, xevent->xclient.window, dest_window);
if (context)
event->dnd.send_event = FALSE;
event->dnd.type = GDK_DRAG_STATUS;
event->dnd.context = context;
+ gdk_event_set_device (event, gdk_drag_context_get_device (context));
g_object_ref (context);
event->dnd.time = GDK_CURRENT_TIME; /* FIXME? */
GDK_NOTE (DND,
g_message ("XdndFinished: dest_window: %#x", dest_window));
- display = gdk_drawable_get_display (event->any.window);
+ display = gdk_window_get_display (event->any.window);
context = gdk_drag_context_find (display, TRUE, xevent->xclient.window, dest_window);
if (context)
event->dnd.type = GDK_DROP_FINISHED;
event->dnd.context = context;
+ gdk_event_set_device (event, gdk_drag_context_get_device (context));
g_object_ref (context);
event->dnd.time = GDK_CURRENT_TIME; /* FIXME? */
GList *tmp_list = context->targets;
gint i;
gint n_atoms = g_list_length (context->targets);
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
atomlist = g_new (Atom, n_atoms);
i = 0;
i++;
}
- XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
- GDK_DRAWABLE_XID (context->source_window),
+ XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
+ GDK_WINDOW_XID (context->source_window),
gdk_x11_get_xatom_by_name_for_display (display, "XdndTypeList"),
XA_ATOM, 32, PropModeReplace,
(guchar *)atomlist, n_atoms);
gint i;
gint n_atoms;
guint actions;
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
if (!xdnd_actions_initialized)
xdnd_initialize_actions();
}
}
- XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
- GDK_DRAWABLE_XID (context->source_window),
+ XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
+ GDK_WINDOW_XID (context->source_window),
gdk_x11_get_xatom_by_name_for_display (display, "XdndActionList"),
XA_ATOM, 32, PropModeReplace,
(guchar *)atomlist, n_atoms);
context->dest_window &&
window == GDK_WINDOW_XID (context->dest_window))
{
- GdkEvent temp_event;
+ GdkEvent *temp_event;
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
g_object_unref (context->dest_window);
private->drag_status = GDK_DRAG_STATUS_DRAG;
- temp_event.dnd.type = GDK_DRAG_STATUS;
- temp_event.dnd.window = context->source_window;
- temp_event.dnd.send_event = TRUE;
- temp_event.dnd.context = context;
- temp_event.dnd.time = GDK_CURRENT_TIME;
+ temp_event = gdk_event_new (GDK_DRAG_STATUS);
+ temp_event->dnd.window = g_object_ref (context->source_window);
+ temp_event->dnd.send_event = TRUE;
+ temp_event->dnd.context = g_object_ref (context);
+ temp_event->dnd.time = GDK_CURRENT_TIME;
+ gdk_event_set_device (temp_event, gdk_drag_context_get_device (context));
- gdk_event_put (&temp_event);
+ gdk_event_put (temp_event);
+
+ gdk_event_free (temp_event);
}
g_object_unref (context);
gdk_drag_context_get_display (GdkDragContext *context)
{
if (context->source_window)
- return GDK_DRAWABLE_DISPLAY (context->source_window);
+ return GDK_WINDOW_DISPLAY (context->source_window);
else if (context->dest_window)
- return GDK_DRAWABLE_DISPLAY (context->dest_window);
+ return GDK_WINDOW_DISPLAY (context->dest_window);
g_assert_not_reached ();
return NULL;
if (gdk_x11_get_xatom_by_name_for_display (display, xdnd_filters[i].atom_name) ==
event_send->xclient.message_type)
{
- GdkEvent temp_event;
- temp_event.any.window = window;
+ GdkEvent *temp_event;
+
+ temp_event = gdk_event_new (GDK_NOTHING);
+ temp_event->any.window = g_object_ref (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);
+ gdk_event_put (temp_event);
+ gdk_event_free (temp_event);
}
return TRUE;
{
XEvent xev;
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->dest_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->dest_window);
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndEnter");
xev.xclient.format = 32;
xev.xclient.window = private->drop_xid ?
private->drop_xid :
- GDK_DRAWABLE_XID (context->dest_window);
- xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
+ GDK_WINDOW_XID (context->dest_window);
+ xev.xclient.data.l[0] = GDK_WINDOW_XID (context->source_window);
xev.xclient.data.l[1] = (private->version << 24); /* version */
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
GDK_NOTE(DND,
g_message ("Sending enter source window %#lx XDND protocol version %d\n",
- GDK_DRAWABLE_XID (context->source_window), private->version));
+ GDK_WINDOW_XID (context->source_window), private->version));
if (g_list_length (context->targets) > 3)
{
if (!private->xdnd_targets_set)
{
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->dest_window)));
+ GDK_WINDOW_XID (context->dest_window)));
g_object_unref (context->dest_window);
context->dest_window = NULL;
}
static void
xdnd_send_leave (GdkDragContext *context)
{
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
XEvent xev;
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
xev.xclient.format = 32;
xev.xclient.window = private->drop_xid ?
private->drop_xid :
- GDK_DRAWABLE_XID (context->dest_window);
- xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
+ GDK_WINDOW_XID (context->dest_window);
+ xev.xclient.data.l[0] = GDK_WINDOW_XID (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
{
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->dest_window)));
+ GDK_WINDOW_XID (context->dest_window)));
g_object_unref (context->dest_window);
context->dest_window = NULL;
}
xdnd_send_drop (GdkDragContext *context, guint32 time)
{
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.format = 32;
xev.xclient.window = private->drop_xid ?
private->drop_xid :
- GDK_DRAWABLE_XID (context->dest_window);
- xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
+ GDK_WINDOW_XID (context->dest_window);
+ xev.xclient.data.l[0] = GDK_WINDOW_XID (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = time;
xev.xclient.data.l[3] = 0;
{
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->dest_window)));
+ GDK_WINDOW_XID (context->dest_window)));
g_object_unref (context->dest_window);
context->dest_window = NULL;
}
guint32 time)
{
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.format = 32;
xev.xclient.window = private->drop_xid ?
private->drop_xid :
- GDK_DRAWABLE_XID (context->dest_window);
- xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->source_window);
+ GDK_WINDOW_XID (context->dest_window);
+ xev.xclient.data.l[0] = GDK_WINDOW_XID (context->source_window);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = (x_root << 16) | y_root;
xev.xclient.data.l[3] = time;
{
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->dest_window)));
+ GDK_WINDOW_XID (context->dest_window)));
g_object_unref (context->dest_window);
context->dest_window = NULL;
}
}
}
- gdk_error_trap_pop ();
+ gdk_error_trap_pop_ignored ();
return retval ? (proxy ? proxy : win) : None;
}
gdk_error_trap_push ();
if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
- GDK_DRAWABLE_XID (context->source_window),
+ GDK_WINDOW_XID (context->source_window),
gdk_x11_get_xatom_by_name_for_display (display, "XdndActionList"),
0, 65536,
False, XA_ATOM, &type, &format, &nitems,
if (data)
XFree (data);
- gdk_error_trap_pop ();
+ gdk_error_trap_pop_ignored ();
}
else
{
GdkDragContext *source_context;
source_context = gdk_drag_context_find (display, TRUE,
- GDK_DRAWABLE_XID (context->source_window),
- GDK_DRAWABLE_XID (context->dest_window));
+ GDK_WINDOW_XID (context->source_window),
+ GDK_WINDOW_XID (context->dest_window));
if (source_context)
{
*/
}
- gdk_display_sync (gdk_drawable_get_display (window));
- gdk_error_trap_pop ();
+ gdk_error_trap_pop_ignored ();
}
}
GdkEvent *event,
gpointer cb_data)
{
+ GdkDeviceManager *device_manager;
GdkDisplay *display;
GdkDisplayX11 *display_x11;
XEvent *xevent = (XEvent *)xev;
get_types = ((xevent->xclient.data.l[1] & 1) != 0);
version = (xevent->xclient.data.l[1] & 0xff000000) >> 24;
- display = GDK_DRAWABLE_DISPLAY (event->any.window);
+ display = GDK_WINDOW_DISPLAY (event->any.window);
display_x11 = GDK_DISPLAY_X11 (display);
xdnd_precache_atoms (display);
new_context->protocol = GDK_DRAG_PROTO_XDND;
PRIVATE_DATA(new_context)->version = version;
+ /* FIXME: Should extend DnD protocol to have device info */
+ device_manager = gdk_display_get_device_manager (display);
+ gdk_drag_context_set_device (new_context, gdk_device_manager_get_client_pointer (device_manager));
+
new_context->source_window = gdk_window_lookup_for_display (display, source_window);
if (new_context->source_window)
g_object_ref (new_context->source_window);
if (get_types)
{
gdk_error_trap_push ();
- XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (event->any.window),
+ XGetWindowProperty (GDK_WINDOW_XDISPLAY (event->any.window),
source_window,
gdk_x11_get_xatom_by_name_for_display (display, "XdndTypeList"),
0, 65536,
event->dnd.type = GDK_DRAG_ENTER;
event->dnd.context = new_context;
+ gdk_event_set_device (event, gdk_drag_context_get_device (new_context));
g_object_ref (new_context);
display_x11->current_dest_drag = new_context;
g_message ("XdndLeave: source_window: %#x",
source_window));
- display = GDK_DRAWABLE_DISPLAY (event->any.window);
+ display = GDK_WINDOW_DISPLAY (event->any.window);
display_x11 = GDK_DISPLAY_X11 (display);
xdnd_precache_atoms (display);
if ((display_x11->current_dest_drag != NULL) &&
(display_x11->current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
- (GDK_DRAWABLE_XID (display_x11->current_dest_drag->source_window) == source_window))
+ (GDK_WINDOW_XID (display_x11->current_dest_drag->source_window) == source_window))
{
event->dnd.type = GDK_DRAG_LEAVE;
/* Pass ownership of context to the event */
event->dnd.context = display_x11->current_dest_drag;
+ gdk_event_set_device (event, gdk_drag_context_get_device (event->dnd.context));
display_x11->current_dest_drag = NULL;
g_message ("XdndPosition: source_window: %#x position: (%d, %d) time: %d action: %ld",
source_window, x_root, y_root, time, action));
- display = GDK_DRAWABLE_DISPLAY (event->any.window);
+ display = GDK_WINDOW_DISPLAY (event->any.window);
display_x11 = GDK_DISPLAY_X11 (display);
xdnd_precache_atoms (display);
if ((display_x11->current_dest_drag != NULL) &&
(display_x11->current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
- (GDK_DRAWABLE_XID (display_x11->current_dest_drag->source_window) == source_window))
+ (GDK_WINDOW_XID (display_x11->current_dest_drag->source_window) == source_window))
{
event->dnd.type = GDK_DRAG_MOTION;
event->dnd.context = display_x11->current_dest_drag;
+ gdk_event_set_device (event, gdk_drag_context_get_device (event->dnd.context));
g_object_ref (display_x11->current_dest_drag);
event->dnd.time = time;
g_message ("XdndDrop: source_window: %#x time: %d",
source_window, time));
- display = GDK_DRAWABLE_DISPLAY (event->any.window);
+ display = GDK_WINDOW_DISPLAY (event->any.window);
display_x11 = GDK_DISPLAY_X11 (display);
xdnd_precache_atoms (display);
if ((display_x11->current_dest_drag != NULL) &&
(display_x11->current_dest_drag->protocol == GDK_DRAG_PROTO_XDND) &&
- (GDK_DRAWABLE_XID (display_x11->current_dest_drag->source_window) == source_window))
+ (GDK_WINDOW_XID (display_x11->current_dest_drag->source_window) == source_window))
{
GdkDragContextPrivateX11 *private;
private = PRIVATE_DATA (display_x11->current_dest_drag);
event->dnd.type = GDK_DROP_START;
event->dnd.context = display_x11->current_dest_drag;
+ gdk_event_set_device (event, gdk_drag_context_get_device (event->dnd.context));
g_object_ref (display_x11->current_dest_drag);
event->dnd.time = time;
/**
* gdk_drag_begin:
* @window: the source window for this drag.
- * @targets: the list of offered targets.
+ * @targets: (transfer none) (element-type GdkAtom): the offered targets,
+ * as list of #GdkAtom<!-- -->s
*
* Starts a drag and creates a new drag context for it.
*
* This function is called by the drag source.
*
- * Return value: a newly created #GdkDragContext.
+ * Return value: (transfer full): a newly created #GdkDragContext.
**/
GdkDragContext *
gdk_drag_begin (GdkWindow *window,
GList *targets)
{
GdkDragContext *new_context;
-
+ GdkDisplay *display;
+ GdkDevice *device;
+ GdkDeviceManager *device_manager;
+
g_return_val_if_fail (window != NULL, NULL);
+ g_return_val_if_fail (GDK_WINDOW_IS_X11 (window), NULL);
new_context = gdk_drag_context_new ();
new_context->is_source = TRUE;
new_context->actions = 0;
+ display = gdk_window_get_display (window);
+ device_manager = gdk_display_get_device_manager (display);
+ device = gdk_device_manager_get_client_pointer (device_manager);
+ gdk_drag_context_set_device (new_context, device);
+
return new_context;
}
-static guint32
+static GdkNativeWindow
_gdk_drag_get_protocol_for_display (GdkDisplay *display,
- guint32 xid,
+ GdkNativeWindow xid,
GdkDragProtocol *protocol,
guint *version)
{
GdkWindow *window;
- guint32 retval;
+ GdkNativeWindow retval;
g_return_val_if_fail (GDK_IS_DISPLAY (display), None);
base_precache_atoms (display);
GDK_NOTE (DND, g_message ("Entering root window\n"));
return xid;
}
-
- return None;
}
-
- if ((retval = xdnd_check_dest (display, xid, version)))
+ else if ((retval = xdnd_check_dest (display, xid, version)))
{
*protocol = GDK_DRAG_PROTO_XDND;
xdnd_precache_atoms (display);
}
#endif
- gdk_error_trap_pop ();
+ gdk_error_trap_pop_ignored ();
if (rootwin)
{
}
*protocol = GDK_DRAG_PROTO_NONE;
- return None;
+
+ return 0; /* a.k.a. None */
}
/**
* gdk_drag_get_protocol_for_display:
* @display: the #GdkDisplay where the destination window resides
- * @xid: the X id of the destination window.
+ * @xid: the windowing system id of the destination window.
* @protocol: location where the supported DND protocol is returned.
- * @returns: the X id of the window where the drop should happen. This
- * may be @xid or the X id of a proxy window, or None if @xid doesn't
+ * @returns: the windowing system id of the window where the drop should happen. This
+ * may be @xid or the id of a proxy window, or zero if @xid doesn't
* support Drag and Drop.
*
* Finds out the DND protocol supported by a window.
*
* Since: 2.2
*/
-guint32
+GdkNativeWindow
gdk_drag_get_protocol_for_display (GdkDisplay *display,
- guint32 xid,
+ GdkNativeWindow xid,
GdkDragProtocol *protocol)
{
return _gdk_drag_get_protocol_for_display (display, xid, protocol, NULL);
* @screen: the screen where the destination window is sought.
* @x_root: the x position of the pointer in root coordinates.
* @y_root: the y position of the pointer in root coordinates.
- * @dest_window: location to store the destination window in.
- * @protocol: location to store the DND protocol in.
- *
+ * @dest_window: (out): location to store the destination window in.
+ * @protocol: (out): location to store the DND protocol in.
+ *
* Finds the destination window and DND protocol to use at the
- * given pointer position.
+ * given pointer position.
*
* This function is called by the drag source to obtain the
* @dest_window and @protocol parameters for gdk_drag_motion().
window_cache = drag_context_find_window_cache (context, screen);
dest = get_client_window_at_coords (window_cache,
- drag_window ?
- GDK_DRAWABLE_XID (drag_window) : None,
+ drag_window && GDK_WINDOW_IS_X11 (drag_window) ?
+ GDK_WINDOW_XID (drag_window) : None,
x_root, y_root);
if (private->dest_xid != dest)
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
g_return_val_if_fail (context != NULL, FALSE);
+ g_return_val_if_fail (dest_window == NULL || GDK_WINDOW_IS_X11 (dest_window), FALSE);
private->old_actions = context->actions;
context->actions = possible_actions;
GdkDisplay *display = GDK_WINDOW_DISPLAY (dest_window);
xdnd_check_dest (display,
- GDK_DRAWABLE_XID (dest_window),
+ GDK_WINDOW_XID (dest_window),
&private->version);
}
}
GdkDragContext *dest_context;
dest_context = gdk_drag_context_find (display, FALSE,
- GDK_DRAWABLE_XID (context->source_window),
- GDK_DRAWABLE_XID (dest_window));
+ GDK_WINDOW_XID (context->source_window),
+ GDK_WINDOW_XID (dest_window));
if (dest_context)
{
if (context->dest_window != dest_window)
{
- GdkEvent temp_event;
+ GdkEvent *temp_event;
/* Send a leave to the last destination */
gdk_drag_do_leave (context, time);
/* Push a status event, to let the client know that
* the drag changed
*/
-
- temp_event.dnd.type = GDK_DRAG_STATUS;
- temp_event.dnd.window = context->source_window;
+ temp_event = gdk_event_new (GDK_DRAG_STATUS);
+ temp_event->dnd.window = g_object_ref (context->source_window);
/* We use this to signal a synthetic status. Perhaps
* we should use an extra field...
*/
- temp_event.dnd.send_event = TRUE;
+ temp_event->dnd.send_event = TRUE;
- temp_event.dnd.context = context;
- temp_event.dnd.time = time;
+ temp_event->dnd.context = g_object_ref (context);
+ temp_event->dnd.time = time;
+ gdk_event_set_device (temp_event, gdk_drag_context_get_device (context));
- gdk_event_put (&temp_event);
+ gdk_event_put (temp_event);
+ gdk_event_free (temp_event);
}
else
{
case GDK_DRAG_PROTO_ROOTWIN:
{
- GdkEvent temp_event;
+ GdkEvent *temp_event;
/* GTK+ traditionally has used application/x-rootwin-drop,
* but the XDND spec specifies x-rootwindow-drop.
*/
else
context->action = 0;
- temp_event.dnd.type = GDK_DRAG_STATUS;
- temp_event.dnd.window = context->source_window;
- temp_event.dnd.send_event = FALSE;
- temp_event.dnd.context = context;
- temp_event.dnd.time = time;
+ temp_event = gdk_event_new (GDK_DRAG_STATUS);
+ temp_event->dnd.window = g_object_ref (context->source_window);
+ temp_event->dnd.send_event = FALSE;
+ temp_event->dnd.context = g_object_ref (context);
+ temp_event->dnd.time = time;
+ gdk_event_set_device (temp_event, gdk_drag_context_get_device (context));
- gdk_event_put (&temp_event);
+ gdk_event_put (temp_event);
+ gdk_event_free (temp_event);
}
break;
case GDK_DRAG_PROTO_NONE:
g_return_if_fail (context != NULL);
private = PRIVATE_DATA (context);
- display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ display = GDK_WINDOW_DISPLAY (context->source_window);
context->action = action;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display,
"_MOTIF_DRAG_AND_DROP_MESSAGE");
xev.xclient.format = 8;
- xev.xclient.window = GDK_DRAWABLE_XID (context->source_window);
+ xev.xclient.window = GDK_WINDOW_XID (context->source_window);
if (private->drag_status == GDK_DRAG_STATUS_ACTION_WAIT)
{
MOTIF_XCLIENT_LONG (&xev, 4) = 0;
if (!_gdk_send_xevent (display,
- GDK_DRAWABLE_XID (context->source_window),
+ GDK_WINDOW_XID (context->source_window),
FALSE, 0, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->source_window)));
+ GDK_WINDOW_XID (context->source_window)));
}
else if (context->protocol == GDK_DRAG_PROTO_XDND)
{
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus");
xev.xclient.format = 32;
- xev.xclient.window = GDK_DRAWABLE_XID (context->source_window);
+ xev.xclient.window = GDK_WINDOW_XID (context->source_window);
- xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->dest_window);
+ xev.xclient.data.l[0] = GDK_WINDOW_XID (context->dest_window);
xev.xclient.data.l[1] = (action != 0) ? (2 | 1) : 0;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
FALSE, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->source_window)));
+ GDK_WINDOW_XID (context->source_window)));
}
private->old_action = action;
if (context->protocol == GDK_DRAG_PROTO_MOTIF)
{
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
XEvent xev;
xev.xclient.type = ClientMessage;
MOTIF_XCLIENT_LONG (&xev, 4) = 0;
_gdk_send_xevent (display,
- GDK_DRAWABLE_XID (context->source_window),
+ GDK_WINDOW_XID (context->source_window),
FALSE, 0, &xev);
}
}
if (context->protocol == GDK_DRAG_PROTO_XDND)
{
- GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
+ GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndFinished");
xev.xclient.format = 32;
- xev.xclient.window = GDK_DRAWABLE_XID (context->source_window);
+ xev.xclient.window = GDK_WINDOW_XID (context->source_window);
- xev.xclient.data.l[0] = GDK_DRAWABLE_XID (context->dest_window);
+ xev.xclient.data.l[0] = GDK_WINDOW_XID (context->dest_window);
if (success)
{
xev.xclient.data.l[1] = 1;
FALSE, &xev))
GDK_NOTE (DND,
g_message ("Send event to %lx failed",
- GDK_DRAWABLE_XID (context->source_window)));
+ GDK_WINDOW_XID (context->source_window)));
}
}
+/**
+ * gdk_window_register_dnd:
+ * @window: a #GdkWindow.
+ *
+ * Registers a window as a potential drop destination.
+ */
void
gdk_window_register_dnd (GdkWindow *window)
{
static const gulong xdnd_version = 5;
MotifDragReceiverInfo info;
Atom motif_drag_receiver_info_atom;
- GdkDisplay *display = gdk_drawable_get_display (window);
+ GdkDisplay *display = gdk_window_get_display (window);
g_return_if_fail (window != NULL);
+ if (gdk_window_get_window_type (window) == GDK_WINDOW_OFFSCREEN)
+ return;
+
base_precache_atoms (display);
if (g_object_get_data (G_OBJECT (window), "gdk-dnd-registered") != NULL)
motif_drag_receiver_info_atom = gdk_x11_get_xatom_by_name_for_display (display,
"_MOTIF_DRAG_RECEIVER_INFO");
+ /* initialize to zero to avoid writing uninitialized data to socket */
+ memset(&info, 0, sizeof(info));
info.byte_order = local_byte_order;
info.protocol_version = 0;
info.protocol_style = XmDRAG_DYNAMIC;
info.num_drop_sites = 0;
info.total_size = sizeof(info);
- XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_DRAWABLE_XID (window),
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
motif_drag_receiver_info_atom,
motif_drag_receiver_info_atom,
8, PropModeReplace,
/* The property needs to be of type XA_ATOM, not XA_INTEGER. Blech */
XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
- GDK_DRAWABLE_XID (window),
+ GDK_WINDOW_XID (window),
gdk_x11_get_xatom_by_name_for_display (display, "XdndAware"),
XA_ATOM, 32, PropModeReplace,
(guchar *)&xdnd_version, 1);
g_return_val_if_fail (context != NULL, GDK_NONE);
if (context->protocol == GDK_DRAG_PROTO_MOTIF)
- return gdk_x11_xatom_to_atom_for_display (GDK_DRAWABLE_DISPLAY (context->source_window),
+ return gdk_x11_xatom_to_atom_for_display (GDK_WINDOW_DISPLAY (context->source_window),
(PRIVATE_DATA (context))->motif_selection);
else if (context->protocol == GDK_DRAG_PROTO_XDND)
return gdk_atom_intern_static_string ("XdndSelection");
* gdk_drag_drop_succeeded:
* @context: a #GdkDragContext
*
- * Returns wether the dropped data has been successfully
+ * Returns whether the dropped data has been successfully
* transferred. This function is intended to be used while
* handling a %GDK_DROP_FINISHED event, its return value is
* meaningless at other times.
return !private->drop_failed;
}
-
-#define __GDK_DND_X11_C__
-#include "gdkaliasdef.c"