xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #1835: shared-clipboard.patch

File shared-clipboard.patch, 7.3 KB (added by Antoine Martin, 3 years ago)

switch clipboard driver automatically with user events (clicks, etc)

  • xpra/x11/server.py

     
    812812        if len(packet)>=7:
    813813            self._set_client_properties(proto, wid, window, packet[6])
    814814        if not self.ui_driver:
    815             self.ui_driver = ss.uuid
     815            self.set_ui_driver(ss)
    816816        if self.ui_driver==ss.uuid or not self._desktop_manager.is_shown(window):
    817817            if len(packet)>=8:
    818818                self._set_window_state(proto, wid, window, packet[7])
     
    834834            return
    835835        self._window_mapped_at(proto, wid, window, None)
    836836        if not self.ui_driver:
    837             self.ui_driver = ss.uuid
     837            self.set_ui_driver(ss)
    838838        elif self.ui_driver!=ss.uuid:
    839839            return
    840840        if len(packet)>=4:
     
    887887                metadatalog("window client properties updates: %s", cprops)
    888888                self._set_client_properties(proto, wid, window, cprops)
    889889        if not self.ui_driver:
    890             self.ui_driver = ss.uuid
     890            self.set_ui_driver(ss)
    891891        is_ui_driver = self.ui_driver==ss.uuid
    892892        shown = self._desktop_manager.is_shown(window)
    893893        if window.is_OR() or window.is_tray() or skip_geometry:
  • xpra/server/mixins/clipboard_server.py

     
    5959
    6060
    6161    def get_server_features(self, server_source=None):
    62         clipboard = self._clipboard_helper is not None and self._clipboard_client == server_source
     62        clipboard = self._clipboard_helper is not None
    6363        log("clipboard_helper=%s, clipboard_client=%s, source=%s, clipboard=%s", self._clipboard_helper, self._clipboard_client, server_source, clipboard)
    6464        if not clipboard:
    6565            return {}
     
    127127    def set_clipboard_source(self, ss):
    128128        self._clipboard_client = ss
    129129        self._clipboard_helper.init_proxies_uuid()
    130         self._clipboard_helper.set_greedy_client(ss.clipboard_greedy)
    131         self._clipboard_helper.set_want_targets_client(ss.clipboard_want_targets)
    132         self._clipboard_helper.enable_selections(ss.clipboard_client_selections)
     130        self._clipboard_helper.set_greedy_client(ss and ss.clipboard_greedy)
     131        self._clipboard_helper.set_want_targets_client(ss and ss.clipboard_want_targets)
     132        if ss:
     133            self._clipboard_helper.enable_selections(ss.clipboard_client_selections)
     134        else:
     135            self._clipboard_helper.enable_selections([])
    133136        log("client %s is the clipboard peer", ss)
    134         log(" greedy=%s", ss.clipboard_greedy)
    135         log(" want targets=%s", ss.clipboard_want_targets)
    136         log(" server has selections: %s", csv(self._clipboards))
    137         log(" client initial selections: %s", csv(ss.clipboard_client_selections))
     137        if ss:
     138            log(" greedy=%s", ss.clipboard_greedy)
     139            log(" want targets=%s", ss.clipboard_want_targets)
     140            log(" server has selections: %s", csv(self._clipboards))
     141            log(" client initial selections: %s", csv(ss.clipboard_client_selections))
    138142
     143
     144    def reset_state(self):
     145        ch = self._clipboard_helper
     146        if ch:
     147            ch.client_reset()
     148
     149
     150    def set_session_driver(self, source):
     151        self.set_clipboard_source(source)
     152        self._clipboard_helper.send_all_tokens()
     153
     154
    139155    def _process_clipboard_packet(self, proto, packet):
    140156        assert self.clipboard
    141157        if self.readonly:
     
    144160        if not ss:
    145161            #protocol has been dropped!
    146162            return
    147         assert self._clipboard_client==ss, \
    148                 "the clipboard packet '%s' does not come from the clipboard owner!" % packet[0]
     163        if self._clipboard_client!=ss:
     164            log("the clipboard packet '%s' does not come from the clipboard owner!", packet[0])
     165            return
    149166        if not ss.clipboard_enabled:
    150167            #this can happen when we disable clipboard in the middle of transfers
    151168            #(especially when there is a clipboard loop)
  • xpra/server/mixins/input_server.py

     
    165165            return
    166166        keyname = bytestostr(keyname)
    167167        modifiers = tuple(bytestostr(x) for x in modifiers)
    168         self.ui_driver = ss.uuid
     168        self.set_ui_driver(ss)
    169169        self.set_keyboard_layout_group(group)
    170170        keycode = self.get_keycode(ss, client_keycode, keyname, modifiers)
    171171        keylog("process_key_action(%s) server keycode=%s", packet, keycode)
     
    359359        if ss is None:
    360360            return
    361361        ss.user_event()
    362         self.ui_driver = ss.uuid
     362        self.set_ui_driver(ss)
    363363        self.do_process_button_action(proto, *packet[1:])
    364364
    365365    def do_process_button_action(self, proto, wid, button, pressed, pointer, modifiers, *args):
  • xpra/server/mixins/stub_server_mixin.py

     
    6969        return {}
    7070
    7171    """
     72    When the user in control of the session changes,
     73    this method will be called.
     74    """
     75    def set_session_driver(self, _source):
     76        pass
     77
     78    """
    7279    Runtime information on this mixin, includes state and settings.
    7380    Somewhat overlaps with the capabilities and features,
    7481    but the data is returned in a structured format. (ie: nested dictionaries)
  • xpra/server/server_base.py

     
    772772    def cleanup_source(self, source):
    773773        had_client = len(self._server_sources)>0
    774774        self.server_event("connection-lost", source.uuid)
     775        remaining_sources = tuple(x for x in self._server_sources.values() if x!=source)
    775776        if self.ui_driver==source.uuid:
    776             self.ui_driver = None
     777            if len(remaining_sources)==1:
     778                self.set_ui_driver(remaining_sources[0])
     779            else:
     780                self.set_ui_driver(None)
    777781        source.close()
    778         remaining_sources = [x for x in self._server_sources.values() if x!=source]
    779782        netlog("cleanup_source(%s) remaining sources: %s", source, remaining_sources)
    780783        netlog.info("xpra client %i disconnected.", source.counter)
    781784        has_client = len(remaining_sources)>0
     
    797800                        log("last_client_exited calling %s", c.reset_state, exc_info=True)
    798801
    799802
     803    def set_ui_driver(self, source):
     804        if source and self.ui_driver==source.uuid:
     805            return
     806        log.info("new ui driver: %s", source)
     807        if not source:
     808            self.ui_driver = None
     809        else:
     810            self.ui_driver = source.uuid
     811        for c in SERVER_BASES:
     812            if c!=ServerCore:
     813                c.set_session_driver(self, source)
     814
     815
    800816    def get_all_protocols(self):
    801817        return list(self._potential_protocols) + list(self._server_sources.keys())
    802818