diff --git a/src/xpra/client/gtk_base/gtk_tray_menu_base.py b/src/xpra/client/gtk_base/gtk_tray_menu_base.py index 6b5c3735fd..263c78a8f5 100644 --- a/src/xpra/client/gtk_base/gtk_tray_menu_base.py +++ b/src/xpra/client/gtk_base/gtk_tray_menu_base.py @@ -667,13 +667,17 @@ def set_clipboard_menu(*args): clipboard_submenu.append(gtk.SeparatorMenuItem()) except: clipboardlog.error("make_clipboardmenuitem()", exc_info=True) + items = [] for label in CLIPBOARD_DIRECTION_LABELS: direction_item = CheckMenuItem(label) d = CLIPBOARD_DIRECTION_LABEL_TO_NAME.get(label) direction_item.set_active(d==self.client.client_clipboard_direction) - direction_item.connect("toggled", self.clipboard_direction_changed, clipboard_submenu) clipboard_submenu.append(direction_item) + items.append(direction_item) clipboard_submenu.show_all() + #connect signals: + for direction_item in items: + direction_item.connect("toggled", self.clipboard_direction_changed, clipboard_submenu) self.client.after_handshake(set_clipboard_menu) return self.clipboard_menuitem diff --git a/src/xpra/client/ui_client_base.py b/src/xpra/client/ui_client_base.py index eb19194d70..b8db4b1d5f 100644 --- a/src/xpra/client/ui_client_base.py +++ b/src/xpra/client/ui_client_base.py @@ -1993,8 +1993,6 @@ def process_ui_capabilities(self): #(could have been translated, or limited if the client only has one, etc) clipboardlog("clipboard enabled clipboard helper=%s", self.clipboard_helper) self.send_clipboard_selections(self.clipboard_helper.remote_clipboards) - if self.clipboard_enabled and self.server_clipboard_loop_uuids: - self.send_clipboard_loop_uuids() self.set_max_packet_size() self.send_deflate_level() c = self.server_capabilities @@ -2082,7 +2080,6 @@ def conv(v): if self.server_clipboard: #from now on, we will send a message to the server whenever the clipboard flag changes: self.connect("clipboard-toggled", self.clipboard_toggled) - self.clipboard_toggled() self.connect("keyboard-sync-toggled", self.send_keyboard_sync_enabled_status) self.send_ping() if self.pings>0: diff --git a/src/xpra/clipboard/clipboard_base.py b/src/xpra/clipboard/clipboard_base.py index 113e280b67..78d242ff83 100644 --- a/src/xpra/clipboard/clipboard_base.py +++ b/src/xpra/clipboard/clipboard_base.py @@ -99,6 +99,25 @@ def _filter_targets(targets): return f +def set_string(clipboard, thestring): + if is_gtk3(): + #no other way? + clipboard.set_text(thestring, len(thestring)) + return + value = [thestring] + def get_func(clipboard, selection, info, targets): + log("get_func%s value=%s", (clipboard, selection, info, targets), value[0]) + s = value[0] + if s: + selection.set("STRING", 8, s) + else: + clipboard.clear() + def clear_func(*args): + log("clear_func%s value=%s", args, value[0]) + value[0] = "" + clipboard.set_with_data([("STRING", 0, 0)], get_func, clear_func) + + class ClipboardProtocolHelperBase(object): def __init__(self, send_packet_cb, progress_cb=None, **kwargs): d = typedict(kwargs) @@ -107,6 +126,7 @@ def __init__(self, send_packet_cb, progress_cb=None, **kwargs): self.can_send = d.boolget("can-send", True) self.can_receive = d.boolget("can-receive", True) self.max_clipboard_packet_size = MAX_CLIPBOARD_PACKET_SIZE + self.disabled_by_loop = [] self.filter_res = [] filter_res = d.strlistget("filters") if filter_res: @@ -124,8 +144,6 @@ def __init__(self, send_packet_cb, progress_cb=None, **kwargs): remote_loop_uuids = d.dictget("remote-loop-uuids", {}) self.verify_remote_loop_uuids(remote_loop_uuids) self.remote_clipboards = d.strlistget("clipboards.remote", CLIPBOARDS) - self.disabled_by_loop = [] - self.init_proxies_uuid() def __repr__(self): return "ClipboardProtocolHelperBase" @@ -184,10 +202,11 @@ def _verify_remote_loop_uuids(self, clipboard, value, user_data): proxy, uuids = user_data if value: for selection, rvalue in uuids.items(): + log("%s=%s", proxy._selection, value) if rvalue==proxy._loop_uuid: - clipboard.set_text("") + set_string(clipboard, "") if rvalue and value==rvalue: - clipboard.set_text("") + set_string(clipboard, "") if selection==proxy._selection: log.warn("Warning: loop detected for %s clipboard", selection) else: @@ -584,8 +603,8 @@ def __init__(self, selection): def init_uuid(self): self._loop_uuid = LOOP_PREFIX+get_hex_uuid() - log("init_uuid() %s set_text(%s)", self._selection, self._loop_uuid) - self._clipboard.set_text(self._loop_uuid, -1) + log("init_uuid() %s uuid=%s", self._selection, self._loop_uuid) + set_string(self._clipboard, self._loop_uuid) def set_direction(self, can_send, can_receive): self._can_send = can_send @@ -763,9 +782,7 @@ def nodata(): if is_gtk3() and dtype in (b"UTF8_STRING", b"STRING") and dformat==8: s = bytestostr(data) self._clipboard.set_text(s, len(s)) - #problem here is that we know own the selection... - #this doesn't work either: - #selection_data.set_text(s, len(s)) + #problem here is that we now own the selection... else: boc = self._block_owner_change self._block_owner_change = True @@ -812,7 +829,7 @@ def got_token(self, targets, target_data, claim=True, synchronous_client=False): if text_target in target_data: text_data = target_data.get(text_target) log("clipboard %s set to '%s'", self._selection, repr_ellipsized(text_data)) - self._clipboard.set_text(text_data, len=len(text_data)) + set_string(self._clipboard, text_data) if not claim: log("token packet without claim, not setting the token flag") #the other end is just telling us to send the token again next time something changes, @@ -869,7 +886,8 @@ def unpack(clipboard, selection_data, _user_data=None): log("unpack %s: %s", clipboard, type(selection_data)) global sanitize_gtkselectiondata if selection_data and sanitize_gtkselectiondata(selection_data): - self._clipboard.set_text("") + selection_data = None + return if selection_data is None: cb(None, None, None) return diff --git a/src/xpra/server/server_base.py b/src/xpra/server/server_base.py index f2a1657b20..e692274e66 100644 --- a/src/xpra/server/server_base.py +++ b/src/xpra/server/server_base.py @@ -1563,6 +1563,7 @@ def parse_hello_ui_clipboard(self, ss, c): clipboardlog("another client already owns the clipboard") return self._clipboard_client = ss + self._clipboard_helper.init_proxies_uuid() #deal with buggy win32 clipboards: if "clipboard.greedy" not in c: #old clients without the flag: take a guess based on platform: