# Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import struct from xpra.util import envbool from xpra.gtk_common.gobject_compat import is_gtk3 from xpra.clipboard.clipboard_base import ClipboardProtocolHelperBase, _filter_targets, log try: if is_gtk3(): from xpra.gtk_common.gtk3 import gdk_atoms #@UnresolvedImport, @UnusedImport else: from xpra.gtk_common.gtk2 import gdk_atoms #@UnresolvedImport, @Reimport except ImportError as e: log.error("Error: gdk atoms library not found:") log.error(" %s", e) del e gdk_atoms = None SANITIZE_GTKSELECTIONDATA = envbool("XPRA_SANITIZE_GTKSELECTIONDATA", True) if not is_gtk3() and SANITIZE_GTKSELECTIONDATA: try: from xpra.gtk_common.gtk2.gdk_bindings import sanitize_gtkselectiondata from xpra.clipboard import clipboard_base clipboard_base.sanitize_gtkselectiondata = sanitize_gtkselectiondata except ImportError as e: log.error("Error: sanitize_gtkselectiondata not found:") log.error(" %s", e) del e
from xpra.gtk_common.gdk_atoms import ( gdk_atom_objects_from_gdk_atom_array, #@UnresolvedImport gdk_atom_array_from_gdk_atom_objects #@UnresolvedImport ) from xpra.clipboard.clipboard_base import ClipboardProtocolHelperBase, log import sys if sys.platform.startswith("linux"): try: from xpra.x11.gtk2.gdk_bindings import sanitize_gtkselectiondata from xpra.clipboard import clipboard_base clipboard_base.sanitize_gtkselectiondata = sanitize_gtkselectiondata except ImportError as e: log.error("Error: sanitize_gtkselectiondata not found: %s", e) class GDKClipboardProtocolHelper(ClipboardProtocolHelperBase): """ This clipboard helper adds the ability to parse raw X11 atoms to and from a form suitable for transport over the wire. """ def __repr__(self): return "GDKClipboardProtocolHelper" def _do_munge_raw_selection_to_wire(self, target, datatype, dataformat, data): if dataformat == 32 and datatype in ("ATOM", "ATOM_PAIR"): log("_do_munge_raw_selection_to_wire(%s, %s, %s, %s:%s:%s) using gdk atom code", target, datatype, dataformat, type(data), len(data), list(data)) # Convert to strings and send that. Bizarrely, the atoms are