Skip to content

Commit

Permalink
#99 when we munge the data, pass the target so we can remove things t…
Browse files Browse the repository at this point in the history
…hat are known not to work, ie: some values for TARGET like "COMPOUND_TEXT"

git-svn-id: https://xpra.org/svn/Xpra/trunk@706 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 5, 2012
1 parent 62bc016 commit f805b2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/xpra/platform/clipboard_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,27 @@ def _send_clipboard_token_handler(self, proxy, selection):
debug("send clipboard token: %s", selection)
self.send(["clipboard-token", self.local_to_remote(selection)])

def _munge_raw_selection_to_wire(self, type, format, data):
def _munge_raw_selection_to_wire(self, target, type, format, data):
# Some types just cannot be marshalled:
if type in ("WINDOW", "PIXMAP", "BITMAP", "DRAWABLE",
"PIXEL", "COLORMAP"):
debug("skipping clipboard data of type: %s, format=%s, len(data)=%s", type, format, len(data))
return (None, None)
return self._do_munge_raw_selection_to_wire(type, format, data)
return self._do_munge_raw_selection_to_wire(target, type, format, data)

def _do_munge_raw_selection_to_wire(self, type, format, data):
def _do_munge_raw_selection_to_wire(self, target, type, format, data):
""" this method is overriden in xclipboard to parse X11 atoms """
# Other types need special handling, and all types need to be
# converting into an endian-neutral format:
if format == 32:
sizeof_long = struct.calcsize("=L")
assert sizeof_long == 32
binfmt = "=" + "L" * (len(data) // sizeof_long)
sizeof_long = struct.calcsize("=I")
assert sizeof_long == 4, "struct.calcsize('=I)=%s" % sizeof_long
binfmt = "=" + "I" * (len(data) // sizeof_long)
ints = struct.unpack(binfmt, data)
return ("integers", ints)
elif format == 16:
sizeof_short = struct.calcsize("=H")
assert sizeof_short == 16
assert sizeof_short == 2
binfmt = "=" + "H" * (len(data) // sizeof_short)
ints = struct.unpack(binfmt, data)
return ("integers", ints)
Expand Down Expand Up @@ -134,7 +134,7 @@ def no_contents():
if type is None or data is None:
no_contents()
return
munged = self._munge_raw_selection_to_wire(type, format, data)
munged = self._munge_raw_selection_to_wire(target, type, format, data)
(wire_encoding, wire_data) = munged
log("clipboard raw -> wire: %r -> %r", (type, format, data), munged)
if wire_encoding is None:
Expand Down
10 changes: 7 additions & 3 deletions src/xpra/xposix/xclipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ class ClipboardProtocolHelper(ClipboardProtocolHelperBase):
def __init__(self, send_packet_cb):
ClipboardProtocolHelperBase.__init__(self, send_packet_cb, ["CLIPBOARD", "PRIMARY", "SECONDARY"])

def _do_munge_raw_selection_to_wire(self, type, format, data):
def _do_munge_raw_selection_to_wire(self, target, ype, format, data):
if format == 32 and type in ("ATOM", "ATOM_PAIR"):
# Convert to strings and send that. Bizarrely, the atoms are
# not actual X atoms, but an array of GdkAtom's reinterpreted
# as a byte buffer.
atoms = gdk_atom_objects_from_gdk_atom_array(data)
return ("atoms", [str(atom) for atom in atoms])
return ClipboardProtocolHelperBase._do_munge_raw_selection_to_wire(self, type, format, data)
atom_names = [str(atom) for atom in atoms]
if target=="TARGET":
atom_names.remove("SAVE_TARGETS")
atom_names.remove("COMPOUND_TEXT")
return ("atoms", atom_names)
return ClipboardProtocolHelperBase._do_munge_raw_selection_to_wire(self, target, type, format, data)

def _munge_wire_selection_to_raw(self, encoding, datatype, format, data):
if encoding == "atoms":
Expand Down

0 comments on commit f805b2e

Please sign in to comment.