Hi, As discussed earlier, here is the clipboard support patch. It is just for testing, not merging!
Summary: * adds a ClipboardSynchronizer class * adds _process_clipboard callbacks to server and client * sprinkle some request_clipboards() calls here and there... Any feedback would be most welcome. Thanks Antoine
diff -urwBN ./parti-all-0.0.5-last/xpra/client.py parti-all-0.0.5-clipboard/xpra/client.py
--- ./parti-all-0.0.5-last/xpra/client.py 2009-03-10 17:00:21.000000000 +0700
+++ parti-all-0.0.5-clipboard/xpra/client.py 2009-03-10 18:39:17.000000000 +0700
@@ -16,6 +16,7 @@
from xpra.keys import mask_to_names
import xpra
+from xpra.clipboard import ClipboardSynchronizer
default_capabilities = {"deflate": 3,
"__prerelease_version": xpra.__version__}
@@ -206,6 +207,7 @@
# reason to overhaul keyboard support:
if name is not None:
self._client.send(["key-action", self._id, name, depressed, modifiers])
+ self._client.clipboard_sync.request_clipboards()
def do_key_press_event(self, event):
self._key_action(event, True)
@@ -228,6 +230,7 @@
self._client.send_positional(["button-action", self._id,
button, depressed,
pointer, modifiers])
+ self._client.clipboard_sync.request_clipboards()
def do_button_press_event(self, event):
self._button_action(event.button, event, True)
@@ -276,6 +279,11 @@
self._focused = None
+ self.clipboard_sync = ClipboardSynchronizer(self.send)
+
+ def _process_clipboard(self, packet):
+ self.clipboard_sync.process_clipboard(packet)
+
def run(self):
gtk.main()
@@ -359,6 +367,7 @@
"window-metadata": _process_window_metadata,
"configure-override-redirect": _process_configure_override_redirect,
"lost-window": _process_lost_window,
+ "clipboard": _process_clipboard,
Protocol.CONNECTION_LOST: _process_connection_lost,
}
diff -urwBN ./parti-all-0.0.5-last/xpra/clipboard.py parti-all-0.0.5-clipboard/xpra/clipboard.py
--- ./parti-all-0.0.5-last/xpra/clipboard.py 1970-01-01 07:00:00.000000000 +0700
+++ parti-all-0.0.5-clipboard/xpra/clipboard.py 2009-03-10 18:39:51.000000000 +0700
@@ -0,0 +1,37 @@
+import gtk
+
+class ClipboardSynchronizer(object):
+
+ def __init__(self, send_function):
+ self.clipboard_names = [ "CLIPBOARD", "PRIMARY", "SECONDARY" ]
+ self.send_function = send_function
+ self.clipboard_contents = {}
+ self.clipboard = {}
+ for name in self.clipboard_names:
+ self.clipboard[name] = gtk.Clipboard(gtk.gdk.display_get_default(), name)
+ self.clipboard_contents[name] = None
+
+ def send(self, packet):
+ self.send_function(packet)
+
+ def process_clipboard(self, packet):
+ (_, name, text) = packet
+ print "clipboard text: %s, %s " % (name,text)
+ if self.clipboard_contents[name] != text:
+ self.clipboard[name].set_text(text)
+ self.clipboard_contents[name] = text
+
+ def request_clipboards(self):
+ for name in self.clipboard_names:
+ self.clipboard[name].request_text(self.clipboard_callback, name)
+ # self._clipboard.request_text(self.clipboard_callback)
+ # _clipboard.request_contents("STRING", self.clipboard_callback)
+ # print "clipboard init done"
+
+ def clipboard_callback(self, clipboard, selection_data, name):
+ print "clipboard_callback: %s, %s" % (selection_data, name)
+ if self.clipboard_contents[name] != selection_data:
+ self.clipboard_contents[name] = selection_data
+ if selection_data == None:
+ selection_data = ""
+ self.send(["clipboard", name, selection_data])
diff -urwBN ./parti-all-0.0.5-last/xpra/server.py parti-all-0.0.5-clipboard/xpra/server.py
--- ./parti-all-0.0.5-last/xpra/server.py 2009-03-10 17:16:40.000000000 +0700
+++ parti-all-0.0.5-clipboard/xpra/server.py 2009-03-10 18:39:49.000000000 +0700
@@ -29,6 +29,7 @@
import xpra
from xpra.protocol import Protocol
from xpra.keys import mask_to_names
+from xpra.clipboard import ClipboardSynchronizer
def _get_rgb_data(pixmap, alpha_channel, x, y, width, height):
pixmap_w, pixmap_h = pixmap.get_size()
@@ -202,6 +203,7 @@
def __init__(self, clobber, sockets):
self.init_wm(clobber)
self.init_keymap()
+ self.init_clipboards()
for socket in sockets:
socket.listen(5)
gobject.io_add_watch(socket, gobject.IO_IN, self._new_connection, socket)
@@ -282,6 +283,9 @@
self._has_focus = 0
self._upgrading = False
+ def init_clipboards(self):
+ self.clipboard_sync = ClipboardSynchronizer(self._send)
+
def quit(self, upgrading):
self._upgrading = upgrading
gtk_main_quit_really()
@@ -536,6 +540,9 @@
(_, id) = packet
self._focus(id)
+ def _process_clipboard(self, proto, packet):
+ self.clipboard_sync.process_clipboard(packet)
+
def _process_key_action(self, proto, packet):
(_, id, keyname, depressed, modifiers) = packet
self._make_keymask_match(modifiers)
@@ -543,6 +550,7 @@
log.debug("now %spressing key %s", depressed, keyname)
xtest_fake_key(gtk.gdk.display_get_default(),
self._keycode(keyname), depressed)
+ self.clipboard_sync.request_clipboards()
def _process_button_action(self, proto, packet):
(_, id, button, depressed, pointer, modifiers) = packet
@@ -550,6 +558,7 @@
self._desktop_manager.raise_window(self._id_to_window[id])
self._move_pointer(pointer)
xtest_fake_button(gtk.gdk.display_get_default(), button, depressed)
+ self.clipboard_sync.request_clipboards()
def _process_pointer_position(self, proto, packet):
(_, id, pointer, modifiers) = packet
@@ -586,6 +595,7 @@
"pointer-position": _process_pointer_position,
"close-window": _process_close_window,
"shutdown-server": _process_shutdown_server,
+ "clipboard": _process_clipboard,
Protocol.CONNECTION_LOST: _process_connection_lost,
}
diff -urwBN ./parti-all-0.0.5-last/xpra/server.py.orig parti-all-0.0.5-clipboard/xpra/server.py.orig
--- ./parti-all-0.0.5-last/xpra/server.py.orig 2009-03-10 17:00:17.000000000 +0700
+++ parti-all-0.0.5-clipboard/xpra/server.py.orig 1970-01-01 07:00:00.000000000 +0700
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Parti-discuss mailing list [email protected] http://lists.partiwm.org/cgi-bin/mailman/listinfo/parti-discuss
