[Xfce4-commits] <xfce4-settings:master> Dispatch primary clipboard restoration (bug #6819).

Jérôme Guelfucci noreply at xfce.org
Thu Jan 13 00:10:01 CET 2011


Updating branch refs/heads/master
         to 82978242d97cfc9fa4710cbab79ec20b93f8bb66 (commit)
       from 6bc24e6fbd7d5e7bfb514e7b9456c2d2398575ff (commit)

commit 82978242d97cfc9fa4710cbab79ec20b93f8bb66
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Sun Jan 9 20:40:09 2011 +0100

    Dispatch primary clipboard restoration (bug #6819).
    
    The GtkEntryCompletion widget is continuously removing ownership over
    the clipboard, quickly after that setting it back.
    
    The code assumed that when the ownership was removed, it could safely
    restore the cached value. Wrong. This causes the widget to "erase" its
    current selection and typing continues at the end of the string (as seen
    in GNOME bug 333320).
    
    Now restoring works through a dispatched GSource, which enables to
    remove this GSource if ownership is set right back again.

 xfce4-settings-helper/clipboard-manager.c |   37 +++++++++++++++++++---------
 1 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/xfce4-settings-helper/clipboard-manager.c b/xfce4-settings-helper/clipboard-manager.c
index 76a5a7c..b65ad02 100644
--- a/xfce4-settings-helper/clipboard-manager.c
+++ b/xfce4-settings-helper/clipboard-manager.c
@@ -4,7 +4,7 @@
  * Copyright (C) 2007 Anders Carlsson
  * Copyright (C) 2007 Rodrigo Moya
  * Copyright (C) 2007 William Jon McCann <mccann at jhu.edu>
- * Copyright (C) 2009 Mike Massonnet <mmassonnet at xfce.org>
+ * Copyright (C) 2009-2011 Mike Massonnet <mmassonnet at xfce.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -269,6 +269,21 @@ xfce_clipboard_manager_primary_clipboard_store (XfceClipboardManager *manager)
 }
 
 
+static gboolean
+xfce_clipboard_manager_primary_clipboard_restore (XfceClipboardManager *manager)
+{
+    if (manager->primary_cache != NULL)
+    {
+        gtk_clipboard_set_text (manager->primary_clipboard,
+                                manager->primary_cache,
+                                -1);
+        manager->primary_internal_change = TRUE;
+    }
+
+    return FALSE;
+}
+
+
 static void
 xfce_clipboard_manager_primary_owner_change (XfceClipboardManager *manager,
                                              GdkEventOwnerChange *event)
@@ -278,6 +293,12 @@ xfce_clipboard_manager_primary_owner_change (XfceClipboardManager *manager,
     if (event->send_event == TRUE)
         return;
 
+    if (manager->primary_timeout != 0)
+    {
+        g_source_remove (manager->primary_timeout);
+        manager->primary_timeout = 0;
+    }
+
     if (event->owner != 0)
     {
         if (manager->primary_internal_change == TRUE)
@@ -286,19 +307,11 @@ xfce_clipboard_manager_primary_owner_change (XfceClipboardManager *manager,
             return;
         }
 
-        if (manager->primary_timeout == 0)
-        {
-            manager->primary_timeout =
-            g_timeout_add (250, (GSourceFunc)xfce_clipboard_manager_primary_clipboard_store, manager);
-        }
+        manager->primary_timeout = g_timeout_add (250, (GSourceFunc)xfce_clipboard_manager_primary_clipboard_store, manager);
     }
-    else
+    else if (gtk_clipboard_wait_is_text_available (manager->primary_clipboard) == FALSE)
     {
-        if (manager->primary_cache != NULL)
-            gtk_clipboard_set_text (manager->primary_clipboard,
-                                    manager->primary_cache,
-                                    -1);
-        manager->primary_internal_change = TRUE;
+        manager->primary_timeout = g_timeout_add (250, (GSourceFunc)xfce_clipboard_manager_primary_clipboard_restore, manager);
     }
 }
 



More information about the Xfce4-commits mailing list