From 6452d34cd7d84ee8b1edb784a9a08310d1b720b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Mon, 18 Nov 2019 13:43:42 +0000 Subject: [PATCH] GDK W32: no "GDK_SELECTION" event for clipboard _gdk_win32_display_convert_selection() does not return anything, it generates a selection notify event instead. Depending on how successful it was, the event will have property=GDK_NONE or property="GDK_SELECTION". property="GDK_SELECTION" is the default return value for successful cases, and it tells GTK to grab the data that GDK previously deposited using selection_property_store(). The problem is that the clipboard branch of this function calls open_clipboard_timeout(), which can't return anything meaningful (it's normally a timeout function), and thus doesn't know whether the function succeeded or failed. Due to my oversight, this resulted in GDK generating two selection notification events - one from inside of open_clipboard_timeout() (with the right property, if successful), and one from the catch-all last line (always defaulting to "GDK_SELECTION"). This caused issue #2223, where GTK only expected exactly one notification per request, and got confused because it was getting two. I've looked at the code in open_clipboard_timeout(), and it seems to me that it always generates a notification (a successful one or an unsuccessful one). Thus the branch of the function that calls it directly does not need to follow up with a catch-all notification and can just return. This seems to be fixing issue #2223, at least for me, but i'm not entirely sure that this will not have any adverse side-effects. Clipboard handling in GTK3 is a complicated mess. --- gdk/win32/gdkselection-win32.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c index 862d2729fc..a047a4ada5 100644 --- a/gdk/win32/gdkselection-win32.c +++ b/gdk/win32/gdkselection-win32.c @@ -2251,6 +2251,7 @@ _gdk_win32_display_convert_selection (GdkDisplay *display, queue_open_clipboard (GDK_WIN32_CLIPBOARD_QUEUE_ACTION_CONVERT, display, requestor, target, time); open_clipboard_timeout (NULL); + return; } else {