gdk_x11_clipboard_request_targets (cb);
}
-static GdkFilterReturn
-gdk_x11_clipboard_filter_event (GdkXEvent *xev,
- GdkEvent *gdkevent,
- gpointer data)
+static GdkEvent *
+gdk_x11_clipboard_translate_event (GdkDisplay *display,
+ const XEvent *xevent,
+ gpointer data)
{
GdkX11Clipboard *cb = GDK_X11_CLIPBOARD (data);
- GdkDisplay *display;
- XEvent *xevent = xev;
Window xwindow;
- display = gdk_clipboard_get_display (GDK_CLIPBOARD (cb));
xwindow = GDK_X11_DISPLAY (display)->leader_window;
if (xevent->xany.window != xwindow)
- return GDK_FILTER_CONTINUE;
+ return NULL;
switch (xevent->type)
{
case SelectionClear:
if (xevent->xselectionclear.selection != cb->xselection)
- return GDK_FILTER_CONTINUE;
+ return NULL;
if (xevent->xselectionclear.time < cb->timestamp)
{
GDK_NOTE(CLIPBOARD, g_printerr ("%s: ignoring SelectionClear with too old timestamp (%lu vs %lu)\n",
cb->selection, xevent->xselectionclear.time, cb->timestamp));
- return GDK_FILTER_CONTINUE;
+ return NULL;
}
GDK_NOTE(CLIPBOARD, g_printerr ("%s: got SelectionClear\n", cb->selection));
gdk_x11_clipboard_claim_remote (cb, xevent->xselectionclear.time);
- return GDK_FILTER_REMOVE;
+ return gdk_event_new (GDK_NOTHING);
case SelectionNotify:
/* This code only checks clipboard manager replies, so... */
if (!g_str_equal (cb->selection, "CLIPBOARD"))
- return GDK_FILTER_CONTINUE;
+ return NULL;
/* selection is not for us */
if (xevent->xselection.selection != gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER") ||
xevent->xselection.target != gdk_x11_get_xatom_by_name_for_display (display, "SAVE_TARGETS"))
- return GDK_FILTER_CONTINUE;
+ return NULL;
/* We already received a selectionNotify before */
if (cb->store_task == NULL)
{
GDK_NOTE(CLIPBOARD, g_printerr ("%s: got SelectionNotify for nonexisting task?!\n",
cb->selection));
- return GDK_FILTER_CONTINUE;
+ return NULL;
}
GDK_NOTE(CLIPBOARD, g_printerr ("%s: got SelectionNotify for store task\n",
_("Clipboard manager could not store selection."));
g_clear_object (&cb->store_task);
- return GDK_FILTER_CONTINUE;
+ return NULL;
case SelectionRequest:
{
const char *target, *property;
if (xevent->xselectionrequest.selection != cb->xselection)
- return GDK_FILTER_CONTINUE;
+ return NULL;
target = gdk_x11_get_xatom_name_for_display (display, xevent->xselectionrequest.target);
if (xevent->xselectionrequest.property == None)
{
GDK_NOTE(CLIPBOARD, g_printerr ("%s: got SelectionRequest for %s @ %s even though we don't own the selection, huh?\n",
cb->selection, target, property));
- return GDK_FILTER_REMOVE;
+ return gdk_event_new (GDK_NOTHING);
}
if (xevent->xselectionrequest.requestor == None)
{
GDK_NOTE(CLIPBOARD, g_printerr ("%s: got SelectionRequest for %s @ %s with NULL window, ignoring\n",
cb->selection, target, property));
- return GDK_FILTER_REMOVE;
+ return gdk_event_new (GDK_NOTHING);
}
GDK_NOTE(CLIPBOARD, g_printerr ("%s: got SelectionRequest for %s @ %s\n",
xevent->xselectionrequest.time,
gdk_x11_clipboard_default_output_handler,
cb);
- return GDK_FILTER_REMOVE;
+ return gdk_event_new (GDK_NOTHING);
}
default:
XFixesSelectionNotifyEvent *sn = (XFixesSelectionNotifyEvent *) xevent;
if (sn->selection != cb->xselection)
- return GDK_FILTER_CONTINUE;
+ return NULL;
if (sn->owner == GDK_X11_DISPLAY (display)->leader_window)
{
GDK_NOTE(CLIPBOARD, g_printerr ("%s: Ignoring XFixesSelectionNotify for ourselves\n",
cb->selection));
- return GDK_FILTER_CONTINUE;
+ return NULL;
}
GDK_NOTE(CLIPBOARD, g_printerr ("%s: Received XFixesSelectionNotify, claiming selection\n",
gdk_x11_clipboard_claim_remote (cb, sn->selection_timestamp);
}
#endif
- return GDK_FILTER_CONTINUE;
+ return NULL;
}
}
{
GdkX11Clipboard *cb = GDK_X11_CLIPBOARD (object);
- gdk_window_remove_filter (NULL, gdk_x11_clipboard_filter_event, cb);
+ g_signal_handlers_disconnect_by_func (gdk_clipboard_get_display (GDK_CLIPBOARD (cb)),
+ gdk_x11_clipboard_translate_event,
+ cb);
g_free (cb->selection);
G_OBJECT_CLASS (gdk_x11_clipboard_parent_class)->finalize (object);
cb->xselection = gdk_x11_get_xatom_by_name_for_display (display, selection);
gdk_display_request_selection_notification (display, gdk_atom_intern (selection, FALSE));
- gdk_window_add_filter (NULL, gdk_x11_clipboard_filter_event, cb);
+ g_signal_connect (display, "translate-event", G_CALLBACK (gdk_x11_clipboard_translate_event), cb);
gdk_x11_clipboard_claim_remote (cb, CurrentTime);
return GDK_CLIPBOARD (cb);