Exemple #1
0
 def got_token(self, targets):
     # We got the anti-token.
     debug("got token, selection=%s, targets=%s", self._selection, targets)
     self._have_token = True
     for target in targets:
         self.selection_add_target(self._selection, target, 0)
     self.selection_owner_set(self._selection)
Exemple #2
0
 def got_token(self, targets):
     # We got the anti-token.
     debug("got token, selection=%s, targets=%s", self._selection, targets)
     self._have_token = True
     for target in targets:
         self.selection_add_target(self._selection, target, 0)
     self.selection_owner_set(self._selection)
Exemple #3
0
 def local_clipboard_changed(self):
     debug("local_clipboard_changed() greedy_client=%s",
           self._greedy_client)
     if (self._greedy_client
             or not self._have_token) and not self._block_owner_change:
         self._have_token = False
         self.emit("send-clipboard-token", self._selection)
         self._sent_token_events += 1
Exemple #4
0
 def _munge_wire_selection_to_raw(self, encoding, datatype, dataformat, data):
     debug("_munge_wire_selection_to_raw(%s, %s, %s, %s:%s:%s)", encoding, datatype, dataformat, type(data), len(data or ""), list(data or ""))
     if encoding == "atoms":
         import gtk.gdk
         gdk_atoms = [gtk.gdk.atom_intern(a) for a in data]
         atom_array = gdk_atom_array_from_gdk_atom_objects(gdk_atoms)
         bdata = struct.pack("=" + "Q" * len(atom_array), *atom_array)
         debug("_munge_wire_selection_to_raw(%s, %s, %s, %s:%s)=%s=%s=%s", encoding, datatype, dataformat, type(data), len(data or ""), gdk_atoms, atom_array, list(bdata))
         return bdata
     return ClipboardProtocolHelperBase._munge_wire_selection_to_raw(self, encoding, datatype, dataformat, data)
Exemple #5
0
 def timer_clipboard_check():
     global change_count
     c = change_count
     change_count = pasteboard.changeCount()
     debug("timer_clipboard_check() was %s, now %s", c, change_count)
     if c != change_count:
         for x in change_callbacks:
             try:
                 x()
             except Exception, e:
                 debug("error in change callback %s: %s", x, e)
Exemple #6
0
 def timer_clipboard_check():
     global change_count
     c = change_count
     change_count = pasteboard.changeCount()
     debug("timer_clipboard_check() was %s, now %s", c, change_count)
     if c!=change_count:
         for x in change_callbacks:
             try:
                 x()
             except Exception, e:
                 debug("error in change callback %s: %s", x, e)
Exemple #7
0
 def _do_munge_raw_selection_to_wire(self, target, datatype, dataformat, data):
     if dataformat == 32 and datatype in ("ATOM", "ATOM_PAIR"):
         debug("_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
         # not actual X atoms, but an array of GdkAtom's reinterpreted
         # as a byte buffer.
         atoms = gdk_atom_objects_from_gdk_atom_array(data)
         debug("_do_munge_raw_selection_to_wire(%s, %s, %s, %s:%s) atoms=%s", target, datatype, dataformat, type(data), len(data), list(atoms))
         atom_names = [str(atom) for atom in atoms]
         debug("_do_munge_raw_selection_to_wire(%s, %s, %s, %s:%s) atom_names=%s", target, datatype, dataformat, type(data), len(data), atom_names)
         if target=="TARGETS":
             atom_names = self._filter_targets(atom_names)
         return "atoms", atom_names
     return ClipboardProtocolHelperBase._do_munge_raw_selection_to_wire(self, target, datatype, dataformat, data)
Exemple #8
0
 def got_token(self, targets, target_data):
     # We got the anti-token.
     debug("got token, selection=%s, targets=%s, target_data=%s", self._selection, targets, target_data)
     self._block_owner_change = True
     self._have_token = True
     for target in targets:
         self.selection_add_target(self._selection, target, 0)
     self.selection_owner_set(self._selection)
     if target_data:
         for text_target in TEXT_TARGETS:
             if text_target in target_data:
                 text_data = target_data.get(text_target)
                 debug("clipboard %s set to '%s'", self._selection, text_data)
                 self._clipboard.set_text(text_data)
     #prevent our change from firing another clipboard update:
     c = update_clipboard_change_count()
     debug("change count now at %s", c)
     gobject.idle_add(self.remove_block)
Exemple #9
0
 def got_token(self, targets, target_data):
     # We got the anti-token.
     debug("got token, selection=%s, targets=%s, target_data=%s",
           self._selection, targets, target_data)
     self._block_owner_change = True
     self._have_token = True
     for target in targets:
         self.selection_add_target(self._selection, target, 0)
     self.selection_owner_set(self._selection)
     if target_data:
         for text_target in TEXT_TARGETS:
             if text_target in target_data:
                 text_data = target_data.get(text_target)
                 debug("clipboard %s set to '%s'", self._selection,
                       text_data)
                 self._clipboard.set_text(text_data)
     #prevent our change from firing another clipboard update:
     c = update_clipboard_change_count()
     debug("change count now at %s", c)
     gobject.idle_add(self.remove_block)
 def remote_to_local(self, selection):
     debug("remote_to_local(%s) local_clipboard=%s, remote_clipboard=%s", selection, self.local_clipboard, self.remote_clipboard)
     if selection==self.remote_clipboard:
         return  self.local_clipboard
     return  selection
Exemple #11
0
        def timer_clipboard_check():
            global change_count
            c = change_count
            change_count = pasteboard.changeCount()
            debug("timer_clipboard_check() was %s, now %s", c, change_count)
            if c != change_count:
                for x in change_callbacks:
                    try:
                        x()
                    except Exception, e:
                        debug("error in change callback %s: %s", x, e)

        from xpra.platform.ui_thread_watcher import get_UI_watcher
        w = get_UI_watcher()
        debug("UI watcher=%s", w)
        if w:
            w.add_alive_callback(timer_clipboard_check)
except ImportError, e:
    log.warn("cannot monitor OSX clipboard count: %s", e)


class OSXClipboardProtocolHelper(GDKClipboardProtocolHelper):
    """
        Full of OSX quirks!
        darwin/features.py should be set
        * CLIPBOARD_GREEDY: request the other end to send tokens for all owner change events
        * CLIPBOARD_WANT_TARGETS: include targets with the tokens
    """
    def __init__(self, send_packet_cb, progress_cb=None):
        GDKClipboardProtocolHelper.__init__(self, send_packet_cb, progress_cb,
Exemple #12
0
 def local_clipboard_changed(self):
     debug("local_clipboard_changed() greedy_client=%s", self._greedy_client)
     if (self._greedy_client or not self._have_token) and not self._block_owner_change:
         self._have_token = False
         self.emit("send-clipboard-token", self._selection)
         self._sent_token_events += 1
Exemple #13
0
            change_count = pasteboard.changeCount()
            return change_count
        def timer_clipboard_check():
            global change_count
            c = change_count
            change_count = pasteboard.changeCount()
            debug("timer_clipboard_check() was %s, now %s", c, change_count)
            if c!=change_count:
                for x in change_callbacks:
                    try:
                        x()
                    except Exception, e:
                        debug("error in change callback %s: %s", x, e)
        from xpra.platform.ui_thread_watcher import get_UI_watcher
        w = get_UI_watcher()
        debug("UI watcher=%s", w)
        if w:
            w.add_alive_callback(timer_clipboard_check)
except ImportError, e:
    log.warn("cannot monitor OSX clipboard count: %s", e)


class OSXClipboardProtocolHelper(GDKClipboardProtocolHelper):
    """
        Full of OSX quirks!
        darwin/features.py should be set
        * CLIPBOARD_GREEDY: request the other end to send tokens for all owner change events
        * CLIPBOARD_WANT_TARGETS: include targets with the tokens
    """

    def __init__(self, send_packet_cb, progress_cb=None):