I have a GTK application which listen for clipboard "owner-change"
signal to detect clipboard changes.
Under x11 all is working fine, the signal is fired when, for example,
you press CTRL+C inside gedit.
Under Wayland "owner-change" signal is emitted when my window is
*focused* and *moved*. Not when the clipboard changes. And most of
GdkEventOwnerChange struct fields are *null*, including timestamps.
Here is the code, just run it under both wayland or x11 (or
GDK_BACKEND=x11) and see the differencies.
static void cb(GtkClipboard *gtkClipboard, GdkEvent *event, void *d)
oce = (GdkEventOwnerChange *)event;
if (oce->type == GDK_OWNER_CHANGE)
printf("oce->type is GDK_OWNER_CHANGE\n");
printf("oce->type is BAD: %d\n", (int)oce->type);
printf("oce->window = %p\n", oce->window);
printf("oce->send_event = %u\n", (unsigned)oce->send_event);
printf("oce->owner = %p\n", oce->owner);
printf("oce->reason = %d\n", (int)oce->reason);
printf("oce->selection = %s\n", gdk_atom_name(oce->selection));
printf("oce->time = %u\n", (unsigned)oce->time);
printf("oce->selection_time = %u\n", (unsigned)oce->selection_time);
activate (GtkApplication* app,
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "Window");
gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
c = gtk_widget_get_clipboard(window, GDK_SELECTION_CLIPBOARD);
g_signal_connect(c, "owner-change", G_CALLBACK(cb), (void *)1);
main (int argc,
app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
Tests have been done under Ubutu 17.10.
gtk-app-devel-list mailing list