gint hot_y;
Window dest_xid; /* The last window we looked up */
+ Window proxy_xid; /* The proxy window for dest_xid (or dest_xid if no proxying happens) */
Window drop_xid; /* The (non-proxied) window that is receiving drops */
guint xdnd_targets_set : 1; /* Whether we've already set XdndTypeList */
guint xdnd_have_actions : 1; /* Whether an XdndActionList was provided */
}
static void gdk_x11_drag_context_finalize (GObject *object);
-static GdkSurface * gdk_x11_drag_context_find_surface (GdkDragContext *context,
+static Window gdk_x11_drag_context_find_surface (GdkDragContext *context,
GdkSurface *drag_surface,
gint x_root,
gint y_root,
GdkDragProtocol *protocol);
static gboolean gdk_x11_drag_context_drag_motion (GdkDragContext *context,
- GdkSurface *dest_surface,
+ Window proxy_xid,
GdkDragProtocol protocol,
gint x_root,
gint y_root,
if (gdk_drag_context_get_display (context) != display)
continue;
- context_dest_xid = context->dest_surface
+ context_dest_xid = context_x11->proxy_xid
? (context_x11->drop_xid
? context_x11->drop_xid
- : GDK_SURFACE_XID (context->dest_surface))
+ : context_x11->proxy_xid)
: None;
if ((context->is_source) &&
gboolean success,
gpointer data)
{
+ GdkX11DragContext *context_x11 = data;
GdkDragContext *context = data;
+
GDK_DISPLAY_NOTE (gdk_drag_context_get_display (context), DND,
g_message ("Got async callback for #%lx, success = %d",
window, success));
* so we don't end up blocking for a timeout
*/
if (!success &&
- context->dest_surface &&
- window == GDK_SURFACE_XID (context->dest_surface))
+ window == context_x11->proxy_xid)
{
- GdkX11DragContext *context_x11 = data;
-
- g_object_unref (context->dest_surface);
- context->dest_surface = NULL;
+ context_x11->proxy_xid = None;
context->action = 0;
if (context->action != context_x11->current_action)
{
static void
xdnd_send_xevent (GdkX11DragContext *context_x11,
- GdkSurface *surface,
XEvent *event_send)
{
GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11);
GdkDisplay *display = gdk_drag_context_get_display (context);
- Window xwindow;
+ GdkSurface *surface;
glong event_mask;
g_assert (event_send->xany.type == ClientMessage);
/* We short-circuit messages to ourselves */
- if (gdk_surface_get_surface_type (surface) != GDK_SURFACE_FOREIGN)
+ surface = gdk_x11_surface_lookup_for_display (display, context_x11->proxy_xid);
+ if (surface)
{
if (gdk_x11_drop_filter (surface, event_send))
return;
}
- xwindow = GDK_SURFACE_XID (surface);
-
- if (_gdk_x11_display_is_root_window (display, xwindow))
+ if (_gdk_x11_display_is_root_window (display, context_x11->proxy_xid))
event_mask = ButtonPressMask;
else
event_mask = 0;
- send_client_message_async (context, xwindow, event_mask,
+ send_client_message_async (context, context_x11->proxy_xid, event_mask,
&event_send->xclient);
}
xev.xclient.format = 32;
xev.xclient.window = context_x11->drop_xid
? context_x11->drop_xid
- : GDK_SURFACE_XID (context->dest_surface);
+ : context_x11->proxy_xid;
xev.xclient.data.l[0] = GDK_SURFACE_XID (context_x11->ipc_surface);
xev.xclient.data.l[1] = (context_x11->version << 24); /* version */
xev.xclient.data.l[2] = 0;
}
}
- xdnd_send_xevent (context_x11, context->dest_surface, &xev);
+ xdnd_send_xevent (context_x11, &xev);
}
static void
xev.xclient.format = 32;
xev.xclient.window = context_x11->drop_xid
? context_x11->drop_xid
- : GDK_SURFACE_XID (context->dest_surface);
+ : context_x11->proxy_xid;
xev.xclient.data.l[0] = GDK_SURFACE_XID (context_x11->ipc_surface);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = 0;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
- xdnd_send_xevent (context_x11, context->dest_surface, &xev);
+ xdnd_send_xevent (context_x11, &xev);
}
static void
xev.xclient.format = 32;
xev.xclient.window = context_x11->drop_xid
? context_x11->drop_xid
- : GDK_SURFACE_XID (context->dest_surface);
+ : context_x11->proxy_xid;
xev.xclient.data.l[0] = GDK_SURFACE_XID (context_x11->ipc_surface);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = time;
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
- xdnd_send_xevent (context_x11, context->dest_surface, &xev);
+ xdnd_send_xevent (context_x11, &xev);
}
static void
xev.xclient.format = 32;
xev.xclient.window = context_x11->drop_xid
? context_x11->drop_xid
- : GDK_SURFACE_XID (context->dest_surface);
+ : context_x11->proxy_xid;
xev.xclient.data.l[0] = GDK_SURFACE_XID (context_x11->ipc_surface);
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = (x_root << 16) | y_root;
xev.xclient.data.l[3] = time;
xev.xclient.data.l[4] = xdnd_action_to_atom (display, action);
- xdnd_send_xevent (context_x11, context->dest_surface, &xev);
+ xdnd_send_xevent (context_x11, &xev);
context_x11->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
}
gdk_drag_do_leave (GdkX11DragContext *context_x11,
guint32 time)
{
- GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11);
-
- if (context->dest_surface)
+ if (context_x11->proxy_xid)
{
switch (context_x11->protocol)
{
break;
}
- g_object_unref (context->dest_surface);
- context->dest_surface = NULL;
+ context_x11->proxy_xid = None;
}
}
return context_x11->cache;
}
-static GdkSurface *
+static Window
gdk_x11_drag_context_find_surface (GdkDragContext *context,
GdkSurface *drag_surface,
gint x_root,
GdkSurfaceCache *window_cache;
GdkDisplay *display;
Window dest;
- GdkSurface *dest_surface;
+ Window proxy;
display = gdk_drag_context_get_display (context);
screen_x11 = GDK_X11_SCREEN(GDK_X11_DISPLAY (display)->screen);
if (context_x11->dest_xid != dest)
{
- Window recipient;
context_x11->dest_xid = dest;
/* Check if new destination accepts drags, and which protocol */
* two are passed explicitly, the third implicitly through
* protocol->dest_xid.
*/
- recipient = _gdk_x11_display_get_drag_protocol (display,
- dest,
- protocol,
- &context_x11->version);
-
- if (recipient != None)
- dest_surface = gdk_x11_surface_foreign_new_for_display (display, recipient);
- else
- dest_surface = NULL;
+ proxy = _gdk_x11_display_get_drag_protocol (display,
+ dest,
+ protocol,
+ &context_x11->version);
}
else
{
- dest_surface = context->dest_surface;
- if (dest_surface)
- g_object_ref (dest_surface);
+ proxy = dest;
*protocol = context_x11->protocol;
}
- return dest_surface;
+ return proxy;
}
static void
static gboolean
gdk_x11_drag_context_drag_motion (GdkDragContext *context,
- GdkSurface *dest_surface,
+ Window proxy_xid,
GdkDragProtocol protocol,
gint x_root,
gint y_root,
guint32 time)
{
GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context);
- GdkSurfaceImplX11 *impl;
if (context_x11->drag_surface)
move_drag_surface (context, x_root, y_root);
* gdk_drag_find_window(). This happens, e.g.
* when GTK+ is proxying DND events to embedded windows.
*/
- if (dest_surface)
+ if (proxy_xid)
{
- GdkDisplay *display = GDK_SURFACE_DISPLAY (dest_surface);
+ GdkDisplay *display = gdk_drag_context_get_display (context);
xdnd_check_dest (display,
- GDK_SURFACE_XID (dest_surface),
+ proxy_xid,
&context_x11->version);
}
}
*/
if (protocol == GDK_DRAG_PROTO_XDND && context_x11->xdnd_actions != gdk_drag_context_get_actions (context))
{
- if (dest_surface)
+ if (proxy_xid)
{
- GdkDisplay *display = GDK_SURFACE_DISPLAY (dest_surface);
+ GdkDisplay *display = gdk_drag_context_get_display (context);
GdkDrop *drop = GDK_X11_DISPLAY (display)->current_drop;
- if (drop && gdk_drop_get_surface (drop) == dest_surface)
+ if (drop && GDK_SURFACE_XID (gdk_drop_get_surface (drop)) == proxy_xid)
gdk_x11_drop_read_actions (drop);
else
xdnd_set_actions (context_x11);
}
}
- if (context->dest_surface != dest_surface)
+ if (context_x11->proxy_xid != proxy_xid)
{
/* Send a leave to the last destination */
gdk_drag_do_leave (context_x11, time);
/* Check if new destination accepts drags, and which protocol */
- if (dest_surface)
+ if (proxy_xid)
{
- context->dest_surface = dest_surface;
+ context_x11->proxy_xid = proxy_xid;
context_x11->drop_xid = context_x11->dest_xid;
- g_object_ref (context->dest_surface);
context_x11->protocol = protocol;
switch (protocol)
}
else
{
- context->dest_surface = NULL;
+ context_x11->proxy_xid = None;
context_x11->drop_xid = None;
context->action = 0;
}
context_x11->last_x = x_root;
context_x11->last_y = y_root;
- if (context->dest_surface)
+ if (context_x11->proxy_xid)
{
- impl = GDK_SURFACE_IMPL_X11 (context->dest_surface->impl);
+ GdkDisplay *display = gdk_drag_context_get_display (context);
+ GdkX11Screen *screen_x11 = GDK_X11_SCREEN(GDK_X11_DISPLAY (display)->screen);
if (context_x11->drag_status == GDK_DRAG_STATUS_DRAG)
{
switch (context_x11->protocol)
{
case GDK_DRAG_PROTO_XDND:
- xdnd_send_motion (context_x11, x_root * impl->surface_scale, y_root * impl->surface_scale, suggested_action, time);
+ xdnd_send_motion (context_x11, x_root * screen_x11->surface_scale, y_root * screen_x11->surface_scale, suggested_action, time);
break;
case GDK_DRAG_PROTO_ROOTWIN:
{
GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context);
- if (context->dest_surface)
+ if (context_x11->proxy_xid)
{
switch (context_x11->protocol)
{
{
GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context);
GdkDragAction action, possible_actions;
- GdkSurface *dest_surface;
GdkDragProtocol protocol;
+ Window proxy;
gdk_drag_get_current_actions (mods, GDK_BUTTON_PRIMARY, x11_context->actions,
&action, &possible_actions);
- dest_surface = gdk_x11_drag_context_find_surface (context,
- x11_context->drag_surface,
- x_root, y_root, &protocol);
+ proxy = gdk_x11_drag_context_find_surface (context,
+ x11_context->drag_surface,
+ x_root, y_root, &protocol);
- gdk_x11_drag_context_drag_motion (context, dest_surface, protocol, x_root, y_root,
+ gdk_x11_drag_context_drag_motion (context, proxy, protocol, x_root, y_root,
action, possible_actions, evtime);
}
case GDK_KEY_KP_Enter:
case GDK_KEY_KP_Space:
if ((gdk_drag_context_get_selected_action (context) != 0) &&
- (context->dest_surface != NULL))
+ (x11_context->proxy_xid != None))
{
g_signal_emit_by_name (context, "drop-performed",
gdk_event_get_time ((GdkEvent *) event));
gdk_dnd_handle_button_event (GdkDragContext *context,
const GdkEventButton *event)
{
+ GdkX11DragContext *x11_context = GDK_X11_DRAG_CONTEXT (context);
+
#if 0
/* FIXME: Check the button matches */
if (event->button != x11_context->button)
#endif
if ((gdk_drag_context_get_selected_action (context) != 0) &&
- (context->dest_surface != NULL))
+ (x11_context->proxy_xid != None))
{
g_signal_emit_by_name (context, "drop-performed",
gdk_event_get_time ((GdkEvent *) event));