[Xfce4-commits] <xfce4-clipman-plugin:master> daemon: dispatch primary clipboard restoration

Mike Massonnet noreply at xfce.org
Sun Jan 9 22:12:01 CET 2011


Updating branch refs/heads/master
         to 0949eaee5b4395aba37a71f5c349079fc3cca1c8 (commit)
       from 31c230bda2bce175533db04656bc7e656728394b (commit)

commit 0949eaee5b4395aba37a71f5c349079fc3cca1c8
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Sun Jan 9 22:08:49 2011 +0100

    daemon: dispatch primary clipboard restoration
    
    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.

 daemon/gsd-clipboard-manager.c |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/daemon/gsd-clipboard-manager.c b/daemon/gsd-clipboard-manager.c
index 1edc068..62538fd 100644
--- a/daemon/gsd-clipboard-manager.c
+++ b/daemon/gsd-clipboard-manager.c
@@ -231,6 +231,19 @@ primary_clipboard_store (GsdClipboardManager *manager)
         return FALSE;
 }
 
+static gboolean
+primary_clipboard_restore (GsdClipboardManager *manager)
+{
+        if (manager->priv->primary_cache != NULL) {
+                gtk_clipboard_set_text (manager->priv->primary_clipboard,
+                                        manager->priv->primary_cache,
+                                        -1);
+                manager->priv->primary_internal_change = TRUE;
+        }
+
+        return FALSE;
+}
+
 static void
 primary_clipboard_owner_change (GsdClipboardManager *manager,
                                 GdkEventOwnerChange *event)
@@ -238,24 +251,20 @@ primary_clipboard_owner_change (GsdClipboardManager *manager,
         if (event->send_event == TRUE) {
                 return;
         }
+        if (manager->priv->primary_timeout != 0) {
+                g_source_remove (manager->priv->primary_timeout);
+                manager->priv->primary_timeout = 0;
+        }
 
         if (event->owner != 0) {
                 if (manager->priv->primary_internal_change == TRUE) {
                         manager->priv->primary_internal_change = FALSE;
                         return;
                 }
-                if (manager->priv->primary_timeout == 0) {
-                        manager->priv->primary_timeout =
-                          g_timeout_add (250, (GSourceFunc)primary_clipboard_store, manager);
-                }
+                manager->priv->primary_timeout = g_timeout_add (250, (GSourceFunc)primary_clipboard_store, manager);
         }
-        else {
-                if (manager->priv->primary_cache != NULL) {
-                        gtk_clipboard_set_text (manager->priv->primary_clipboard,
-                                                manager->priv->primary_cache,
-                                                -1);
-                        manager->priv->primary_internal_change = TRUE;
-                }
+        else if (gtk_clipboard_wait_is_text_available (manager->priv->primary_clipboard) == FALSE) {
+                manager->priv->primary_timeout = g_timeout_add (250, (GSourceFunc)primary_clipboard_restore, manager);
         }
 }
 



More information about the Xfce4-commits mailing list