[gtk/gtk-3-24: 1/2] GDK W32: no "GDK_SELECTION" event for clipboard



commit 6452d34cd7d84ee8b1edb784a9a08310d1b720b2
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date:   Mon Nov 18 13:43:42 2019 +0000

    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
         {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]