[gtk: 1/2] x11: Ignore old XFixesSelectionNotify events



commit 77c3ef48cf5b9951435b0e37d74b9486fc194c95
Author: Jason Crain <jcrain src gnome org>
Date:   Sat Jul 21 04:17:57 2018 -0500

    x11: Ignore old XFixesSelectionNotify events
    
    GtkEntryCompletion can rapidly release and claim ownership of the
    primary selection. This generates multiple XFixesSelectionNotify events,
    first stating that no one owns the selection, then another stating that
    we own the selection. The notification that no one owns the selection
    causes GtkEntryCompletion to deselect the text, breaking inline
    autocompletion.
    
    This fixes it by ignoring any XFixesSelectionNotify with a timestamp
    earlier than our clipboard timestamp.
    
    Fixes #14

 gdk/x11/gdkclipboard-x11.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/gdk/x11/gdkclipboard-x11.c b/gdk/x11/gdkclipboard-x11.c
index d2d81e0aea..55d0440e1e 100644
--- a/gdk/x11/gdkclipboard-x11.c
+++ b/gdk/x11/gdkclipboard-x11.c
@@ -491,6 +491,14 @@ gdk_x11_clipboard_xevent (GdkDisplay   *display,
           if (sn->selection != cb->xselection)
             return FALSE;
 
+          if (sn->selection_timestamp < cb->timestamp)
+            {
+              GDK_DISPLAY_NOTE (display, CLIPBOARD,
+                        g_printerr ("%s: Ignoring XFixesSelectionNotify with too old timestamp (%lu vs 
%lu)\n",
+                                    cb->selection, sn->selection_timestamp, cb->timestamp));
+              return FALSE;
+            }
+
           if (sn->owner == GDK_X11_DISPLAY (display)->leader_window)
             {
               GDK_DISPLAY_NOTE (display, CLIPBOARD,


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