static GdkSurfaceCache *gdk_surface_cache_ref (GdkSurfaceCache *cache);
static void gdk_surface_cache_unref (GdkSurfaceCache *cache);
-static GdkFilterReturn xdnd_enter_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data);
-static GdkFilterReturn xdnd_leave_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data);
-static GdkFilterReturn xdnd_position_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data);
-static GdkFilterReturn xdnd_status_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data);
-static GdkFilterReturn xdnd_finished_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data);
-static GdkFilterReturn xdnd_drop_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data);
+static gboolean xdnd_enter_filter (GdkSurface *surface,
+ const XEvent *xevent);
+static gboolean xdnd_leave_filter (GdkSurface *surface,
+ const XEvent *xevent);
+static gboolean xdnd_position_filter (GdkSurface *surface,
+ const XEvent *xevent);
+static gboolean xdnd_status_filter (GdkSurface *surface,
+ const XEvent *xevent);
+static gboolean xdnd_finished_filter (GdkSurface *surface,
+ const XEvent *xevent);
+static gboolean xdnd_drop_filter (GdkSurface *surface,
+ const XEvent *xevent);
static void xdnd_manage_source_filter (GdkDragContext *context,
GdkSurface *surface,
static const struct {
const char *atom_name;
- GdkFilterFunc func;
+ gboolean (* func) (GdkSurface *surface, const XEvent *event);
} xdnd_filters[] = {
{ "XdndEnter", xdnd_enter_filter },
{ "XdndLeave", xdnd_leave_filter },
/* Source side */
-static GdkFilterReturn
-xdnd_status_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data)
+static gboolean
+xdnd_status_filter (GdkSurface *surface,
+ const XEvent *xevent)
{
GdkDisplay *display;
guint32 dest_surface = xevent->xclient.data.l[0];
Atom action = xevent->xclient.data.l[4];
GdkDragContext *context;
- if (!event->any.surface ||
- gdk_surface_get_surface_type (event->any.surface) == GDK_SURFACE_FOREIGN)
- return GDK_FILTER_CONTINUE; /* Not for us */
-
- display = gdk_surface_get_display (event->any.surface);
+ display = gdk_surface_get_display (surface);
context = gdk_drag_context_find (display, TRUE, xevent->xclient.window, dest_surface);
GDK_DISPLAY_NOTE (display, DND,
}
}
- return GDK_FILTER_REMOVE;
+ return TRUE;
}
-static GdkFilterReturn
-xdnd_finished_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data)
+static gboolean
+xdnd_finished_filter (GdkSurface *surface,
+ const XEvent *xevent)
{
GdkDisplay *display;
guint32 dest_surface = xevent->xclient.data.l[0];
GdkDragContext *context;
GdkX11DragContext *context_x11;
- if (!event->any.surface ||
- gdk_surface_get_surface_type (event->any.surface) == GDK_SURFACE_FOREIGN)
- return GDK_FILTER_CONTINUE; /* Not for us */
-
- display = gdk_surface_get_display (event->any.surface);
+ display = gdk_surface_get_display (surface);
context = gdk_drag_context_find (display, TRUE, xevent->xclient.window, dest_surface);
GDK_DISPLAY_NOTE (display, DND,
g_object_unref (context);
}
- return GDK_FILTER_REMOVE;
+ return TRUE;
}
static void
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 = gdk_event_new (GDK_NOTHING);
- temp_event->any.surface = g_object_ref (surface);
-
- if ((*xdnd_filters[i].func) (event_send, temp_event, NULL) == GDK_FILTER_TRANSLATE)
- gdk_display_put_event (display, temp_event);
-
- g_object_unref (temp_event);
+ (*xdnd_filters[i].func) (surface, event_send);
return TRUE;
}
}
}
-static GdkFilterReturn
-xdnd_enter_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer cb_data)
+static gboolean
+xdnd_enter_filter (GdkSurface *surface,
+ const XEvent *xevent)
{
GdkDisplay *display;
GdkX11Display *display_x11;
gboolean get_types;
gint version;
- if (!event->any.surface ||
- gdk_surface_get_surface_type (event->any.surface) == GDK_SURFACE_FOREIGN)
- return GDK_FILTER_CONTINUE; /* Not for us */
-
source_surface = xevent->xclient.data.l[0];
get_types = ((xevent->xclient.data.l[1] & 1) != 0);
version = (xevent->xclient.data.l[1] & 0xff000000) >> 24;
- display = GDK_SURFACE_DISPLAY (event->any.surface);
+ display = gdk_surface_get_display (surface);
display_x11 = GDK_X11_DISPLAY (display);
xdnd_precache_atoms (display);
{
/* Old source ignore */
GDK_DISPLAY_NOTE (display, DND, g_message ("Ignored old XdndEnter message"));
- return GDK_FILTER_REMOVE;
+ return TRUE;
}
if (display_x11->current_dest_drag != NULL)
if (get_types)
{
gdk_x11_display_error_trap_push (display);
- XGetWindowProperty (GDK_SURFACE_XDISPLAY (event->any.surface),
+ XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
source_surface,
gdk_x11_get_xatom_by_name_for_display (display, "XdndTypeList"),
0, 65536,
if (data)
XFree (data);
- return GDK_FILTER_REMOVE;
+ return TRUE;
}
atoms = (Atom *)data;
context_x11 = g_object_new (GDK_TYPE_X11_DRAG_CONTEXT,
"device", gdk_seat_get_pointer (seat),
"formats", content_formats,
- "surface", event->any.surface,
+ "surface", surface,
NULL);
context = (GdkDragContext *)context_x11;
if (!context->source_surface)
{
g_object_unref (context);
- return GDK_FILTER_REMOVE;
+ return TRUE;
}
- context->dest_surface = event->any.surface;
+ context->dest_surface = surface;
g_object_ref (context->dest_surface);
xdnd_manage_source_filter (context, context->source_surface, TRUE);
xdnd_read_actions (context_x11);
gdk_content_formats_unref (content_formats);
- return GDK_FILTER_REMOVE;
+ return TRUE;
}
-static GdkFilterReturn
-xdnd_leave_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data)
+static gboolean
+xdnd_leave_filter (GdkSurface *surface,
+ const XEvent *xevent)
{
guint32 source_surface = xevent->xclient.data.l[0];
GdkDisplay *display;
GdkX11Display *display_x11;
- if (!event->any.surface ||
- gdk_surface_get_surface_type (event->any.surface) == GDK_SURFACE_FOREIGN)
- return GDK_FILTER_CONTINUE; /* Not for us */
-
- display = GDK_SURFACE_DISPLAY (event->any.surface);
+ display = gdk_surface_get_display (surface);
display_x11 = GDK_X11_DISPLAY (display);
GDK_DISPLAY_NOTE (display, DND,
gdk_drop_emit_leave_event (GDK_DROP (display_x11->current_dest_drag), FALSE, GDK_CURRENT_TIME);
g_clear_object (&display_x11->current_dest_drag);
-
- return GDK_FILTER_REMOVE;
}
- else
- return GDK_FILTER_REMOVE;
+
+ return TRUE;
}
-static GdkFilterReturn
-xdnd_position_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data)
+static gboolean
+xdnd_position_filter (GdkSurface *surface,
+ const XEvent *xevent)
{
GdkSurfaceImplX11 *impl;
guint32 source_surface = xevent->xclient.data.l[0];
GdkX11DragContext *context_x11;
GdkDragAction suggested_action;
- if (!event->any.surface ||
- gdk_surface_get_surface_type (event->any.surface) == GDK_SURFACE_FOREIGN)
- return GDK_FILTER_CONTINUE; /* Not for us */
-
- display = GDK_SURFACE_DISPLAY (event->any.surface);
+ display = gdk_surface_get_display (surface);
display_x11 = GDK_X11_DISPLAY (display);
GDK_DISPLAY_NOTE (display, DND,
(GDK_X11_DRAG_CONTEXT (context)->protocol == GDK_DRAG_PROTO_XDND) &&
(GDK_SURFACE_XID (context->source_surface) == source_surface))
{
- impl = GDK_SURFACE_IMPL_X11 (event->any.surface->impl);
+ impl = GDK_SURFACE_IMPL_X11 (gdk_drop_get_surface (GDK_DROP (context))->impl);
context_x11 = GDK_X11_DRAG_CONTEXT (context);
- gdk_event_set_device (event, gdk_drag_context_get_device (context));
- g_object_ref (context);
-
suggested_action = xdnd_action_from_atom (display, action);
if (context_x11->xdnd_have_actions)
gdk_drag_context_set_actions (context,
context_x11->last_y = y_root / impl->surface_scale;
gdk_drop_emit_motion_event (GDK_DROP (context), FALSE, context_x11->last_x, context_x11->last_y, time);
-
- return GDK_FILTER_REMOVE;
}
- return GDK_FILTER_REMOVE;
+ return TRUE;
}
-static GdkFilterReturn
-xdnd_drop_filter (const XEvent *xevent,
- GdkEvent *event,
- gpointer data)
+static gboolean
+xdnd_drop_filter (GdkSurface *surface,
+ const XEvent *xevent)
{
guint32 source_surface = xevent->xclient.data.l[0];
guint32 time = xevent->xclient.data.l[2];
GdkDragContext *context;
GdkX11DragContext *context_x11;
- if (!event->any.surface ||
- gdk_surface_get_surface_type (event->any.surface) == GDK_SURFACE_FOREIGN)
- return GDK_FILTER_CONTINUE; /* Not for us */
-
- display = GDK_SURFACE_DISPLAY (event->any.surface);
+ display = gdk_surface_get_display (surface);
display_x11 = GDK_X11_DISPLAY (display);
GDK_DISPLAY_NOTE (display, DND,
gdk_x11_surface_set_user_time (gdk_drop_get_surface (GDK_DROP (context)), time);
gdk_drop_emit_drop_event (GDK_DROP (context), FALSE, context_x11->last_x, context_x11->last_y, time);
-
- return GDK_FILTER_REMOVE;
}
- return GDK_FILTER_REMOVE;
+ return TRUE;
}
GdkFilterReturn
if (xevent->type != ClientMessage)
return GDK_FILTER_CONTINUE;
+ if (!event->any.surface ||
+ gdk_surface_get_surface_type (event->any.surface) == GDK_SURFACE_FOREIGN)
+ return GDK_FILTER_CONTINUE; /* Not for us */
+
display = GDK_SURFACE_DISPLAY (event->any.surface);
for (i = 0; i < G_N_ELEMENTS (xdnd_filters); i++)
if (xevent->xclient.message_type != gdk_x11_get_xatom_by_name_for_display (display, xdnd_filters[i].atom_name))
continue;
- return xdnd_filters[i].func (xevent, event, data);
+ if (xdnd_filters[i].func (event->any.surface, xevent))
+ return GDK_FILTER_REMOVE;
+ else
+ return GDK_FILTER_CONTINUE;
}
return GDK_FILTER_CONTINUE;