vino r842 - in branches/gnome-2-22: . server



Author: jwendell
Date: Sat May 24 20:35:06 2008
New Revision: 842
URL: http://svn.gnome.org/viewvc/vino?rev=842&view=rev

Log:
2008-05-24  Jonh Wendell  <jwendell gnome org>

	* server/vino-server.c,
	* server/vino-input.[ch]: Fix bug #534262 â cyclic clipboard propagation.


Modified:
   branches/gnome-2-22/ChangeLog
   branches/gnome-2-22/server/vino-input.c
   branches/gnome-2-22/server/vino-input.h
   branches/gnome-2-22/server/vino-server.c

Modified: branches/gnome-2-22/server/vino-input.c
==============================================================================
--- branches/gnome-2-22/server/vino-input.c	(original)
+++ branches/gnome-2-22/server/vino-input.c	Sat May 24 20:35:06 2008
@@ -18,6 +18,7 @@
  *
  * Authors:
  *      Mark McLoughlin <mark skynet ie>
+ *      Jonh Wendell <wendell bani com br>
  *
  *
  *   The keyboard and pointer handling code is borrowed from
@@ -435,6 +436,8 @@
 };
 static const int num_decompositions = G_N_ELEMENTS (decompositions);
 
+static gchar *cb_str = NULL;
+
 static void vino_input_initialize_keycodes (Display *xdisplay);
 
 static void
@@ -1114,24 +1117,45 @@
 #endif /* HAVE_XTEST */
 }
 
+/* text was actually requested */
+static void
+copy_cb (GtkClipboard     *clipboard,
+         GtkSelectionData *data,
+	 guint             info,
+	 VinoServer       *server)
+{
+  gtk_selection_data_set_text (data, cb_str, -1);
+}
+
 void
-vino_input_handle_clipboard_event (GdkScreen *screen,
-				   char      *text,
-				   int        len)
+vino_input_handle_clipboard_event (GdkScreen  *screen,
+				   char       *text,
+				   int         len,
+				   VinoServer *server)
 {
   GtkClipboard *cb;
-  gchar *out;
   gsize a, b;
+  GtkTargetEntry targets[] = {
+				{"UTF8_STRING", 0, 0},
+				{"COMPOUND_TEXT", 0, 0},
+				{"TEXT", 0, 0},
+				{"STRING", 0, 0},
+			     };
 
   if (!text)
     return;
 
-  out = g_convert (text, len, "utf-8", "iso8859-1", &a, &b, NULL);
-  if (out)
+  g_free (cb_str);
+  cb_str = g_convert (text, len, "utf-8", "iso8859-1", &a, &b, NULL);
+  if (cb_str)
     {
       cb = gtk_clipboard_get_for_display (gdk_screen_get_display (screen),
                                           GDK_SELECTION_CLIPBOARD);
-      gtk_clipboard_set_text (cb, out, -1);
-      g_free (out);
+      gtk_clipboard_set_with_owner (cb,
+				    targets,
+				    G_N_ELEMENTS(targets),
+				    (GtkClipboardGetFunc) copy_cb,
+				    NULL,
+				    G_OBJECT (server));
     }
 }

Modified: branches/gnome-2-22/server/vino-input.h
==============================================================================
--- branches/gnome-2-22/server/vino-input.h	(original)
+++ branches/gnome-2-22/server/vino-input.h	Sat May 24 20:35:06 2008
@@ -18,12 +18,14 @@
  *
  * Authors:
  *      Mark McLoughlin <mark skynet ie>
+ *      Jonh Wendell <wendell bani com br>
  */
 
 #ifndef __VINO_INPUT_H__
 #define __VINO_INPUT_H__
 
 #include <gdk/gdk.h>
+#include "vino-server.h"
 
 G_BEGIN_DECLS
 
@@ -37,7 +39,8 @@
 					    gboolean    key_press);
 void     vino_input_handle_clipboard_event (GdkScreen  *screen,
 					    char       *text,
-					    int         len);
+					    int         len,
+					    VinoServer *server);
 
 G_END_DECLS
 

Modified: branches/gnome-2-22/server/vino-server.c
==============================================================================
--- branches/gnome-2-22/server/vino-server.c	(original)
+++ branches/gnome-2-22/server/vino-server.c	Sat May 24 20:35:06 2008
@@ -484,7 +484,7 @@
   if (server->priv->view_only)
     return;
 
-  vino_input_handle_clipboard_event (server->priv->screen, str, len);
+  vino_input_handle_clipboard_event (server->priv->screen, str, len, server);
 }
 
 static gboolean
@@ -781,6 +781,9 @@
   if (server->priv->on_hold)
     return;
 
+  if (gtk_clipboard_get_owner (cb) == G_OBJECT (server))
+    return;
+
   text = gtk_clipboard_wait_for_text (cb);
   if (!text)
     return;



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