From a29382ea5d52f3bf3668b13dfe9a5d39c4769031 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 21 Oct 2024 21:05:42 +0200 Subject: GTK/Win32: include trailing null byte in gtk_selection_data_set_text() * This API behaves very strangely and differently compared to UNIX/X11. When getting, it returns a trailing null for all clipboard contents (unless the clipboard is empty) and when setting, we apparently have to include it as well. At least since we cut it off when getting. Even more strangely, setting without the trailing null did work when pasting in external apps. (How they know when it's safe to throw away the trailing null is mysterious.) * In other words, this fixes X~G~. --- src/interface-gtk/interface.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/interface-gtk') diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c index 8cf0aab..3121b05 100644 --- a/src/interface-gtk/interface.c +++ b/src/interface-gtk/interface.c @@ -655,7 +655,12 @@ static void teco_interface_clipboard_provide(GtkClipboard *clipboard, GtkSelectionData *selection, guint info, gpointer userdata) { GString *str = userdata; - gtk_selection_data_set_text(selection, str->str, str->len); + gint len = str->len; +#ifdef G_OS_WIN32 + /* include trailing null byte */ + len++; +#endif + gtk_selection_data_set_text(selection, str->str, len); } static void -- cgit v1.2.3