On MacOS copying from a GTK4 app to a non-GTK4 app results in corrupted text
Steps to reproduce
- Use
gdk_clipboard_set_text
to set any text, for example"TEST"
. - Paste to a non-GTK application.
Current behavior
If pasted in a non-GTK program, "TEST" is pasted followed by a series of NULL characters. The number of NULLs varies. The NULLs are visible and are rendered as unicode errors (boxes with 0 0 0 0). I'd paste the string into this issue right now, but it causes GitLab to throw up...
Expected outcome
Just the text TEXT
, or whatever was set, should be pasted.
Version information
GTK 4.8.1, installed using Homebrew. macOS 12.6
Additional information
Here is my test program:
#include <gtk/gtk.h>
static void activate (GtkApplication* app, gpointer user_data)
{
GtkWidget *window;
window = gtk_application_window_new (app);
gtk_widget_show (window);
GdkClipboard* clip = gdk_display_get_clipboard(gdk_display_get_default());
gdk_clipboard_set_text(clip, "TEST");
}
int main (int argc, char **argv)
{
GtkApplication *app;
int status;
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);
g_object_unref (app);
return status;
}