From df36fccffe3d7c6e268ee9c6379a033b159d2a2a Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 8 Aug 2022 11:10:22 +0200 Subject: [PATCH] #3592 move clipboard caps to a prefix --- xpra/client/mixins/clipboard.py | 32 ++++++++++++---------- xpra/server/mixins/clipboard_server.py | 30 ++++++++++---------- xpra/server/source/clipboard_connection.py | 25 ++++++++++++----- 3 files changed, 51 insertions(+), 36 deletions(-) diff --git a/xpra/client/mixins/clipboard.py b/xpra/client/mixins/clipboard.py index 4ae936d014..9fc2b0470a 100644 --- a/xpra/client/mixins/clipboard.py +++ b/xpra/client/mixins/clipboard.py @@ -1,5 +1,5 @@ # This file is part of Xpra. -# Copyright (C) 2010-2021 Antoine Martin +# Copyright (C) 2010-2022 Antoine Martin # Copyright (C) 2008, 2010 Nathaniel Smith # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. @@ -85,20 +85,22 @@ def get_info(self) -> dict: def get_caps(self) -> dict: if not self.client_supports_clipboard: return {} - caps = flatten_dict({ - "clipboard" : { - "" : True, - "notifications" : True, - "selections" : CLIPBOARDS, - #buggy osx clipboards: - "want_targets" : CLIPBOARD_WANT_TARGETS, - #buggy osx and win32 clipboards: - "greedy" : CLIPBOARD_GREEDY, - "preferred-targets" : CLIPBOARD_PREFERRED_TARGETS, - "set_enabled" : True, #v4 servers no longer use or show this flag - "contents-slice-fix" : True, #fixed in v2.4, removed check in v4.3 - }, - }) + ccaps = { + "" : True, + "notifications" : True, + "selections" : CLIPBOARDS, + #buggy osx clipboards: + "want_targets" : CLIPBOARD_WANT_TARGETS, + #buggy osx and win32 clipboards: + "greedy" : CLIPBOARD_GREEDY, + "preferred-targets" : CLIPBOARD_PREFERRED_TARGETS, + "set_enabled" : True, #v4 servers no longer use or show this flag + "contents-slice-fix" : True, #fixed in v2.4, removed check in v4.3 + } + #legacy flat format: + caps = flatten_dict({"clipboard" : ccaps}) + #v4.4 uses namespace: + caps["clipboard"] = ccaps return caps def parse_server_capabilities(self, c : typedict) -> bool: diff --git a/xpra/server/mixins/clipboard_server.py b/xpra/server/mixins/clipboard_server.py index 8ba7d7dd71..54342bc459 100644 --- a/xpra/server/mixins/clipboard_server.py +++ b/xpra/server/mixins/clipboard_server.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # This file is part of Xpra. -# Copyright (C) 2010-2020 Antoine Martin +# Copyright (C) 2010-2022 Antoine Martin # Copyright (C) 2008 Nathaniel Smith # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. @@ -72,22 +72,24 @@ def get_server_features(self, server_source=None) -> dict: self._clipboard_helper, self._clipboard_client, server_source, clipboard) if not clipboard: return {} + ccaps = { + "notifications" : True, + "selections" : self._clipboards, + "enable-selections" : True, #client check removed in v4 + "contents-slice-fix" : True, #fixed in v2.4, removed check in v4.3 + "preferred-targets" : CLIPBOARD_PREFERRED_TARGETS, + "want_targets" : CLIPBOARD_WANT_TARGETS, + "greedy" : CLIPBOARD_GREEDY, + "preferred-targets" : CLIPBOARD_PREFERRED_TARGETS, + "set_enabled" : True, #v4 servers no longer use or show this flag + "direction" : self.clipboard_direction, + } f = { + #duplicated in the sub-dict in v4.4: "clipboards" : self._clipboards, "clipboard-direction" : self.clipboard_direction, - "clipboard" : { - "" : True, - "notifications" : True, - "selections" : CLIPBOARDS, - "enable-selections" : True, #client check removed in v4 - "contents-slice-fix" : True, #fixed in v2.4, removed check in v4.3 - "preferred-targets" : CLIPBOARD_PREFERRED_TARGETS, - "want_targets" : CLIPBOARD_WANT_TARGETS, - "greedy" : CLIPBOARD_GREEDY, - "preferred-targets" : CLIPBOARD_PREFERRED_TARGETS, - "set_enabled" : True, #v4 servers no longer use or show this flag - }, - } + "clipboard" : ccaps, + } return f def init_clipboard(self): diff --git a/xpra/server/source/clipboard_connection.py b/xpra/server/source/clipboard_connection.py index fc6d8b4029..1a64305f8e 100644 --- a/xpra/server/source/clipboard_connection.py +++ b/xpra/server/source/clipboard_connection.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # This file is part of Xpra. -# Copyright (C) 2010-2020 Antoine Martin +# Copyright (C) 2010-2022 Antoine Martin # Copyright (C) 2008 Nathaniel Smith # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. @@ -41,14 +41,25 @@ def cleanup(self): self.cancel_clipboard_progress_timer() def parse_client_caps(self, c : typedict): - self.clipboard_enabled = c.boolget("clipboard", False) - self.clipboard_notifications = c.boolget("clipboard.notifications") + ccaps = c.get("clipboard") + if ccaps and isinstance(ccaps, dict): + ccaps = typedict(ccaps) + self.clipboard_enabled = True + self.clipboard_notifications = ccaps.boolget("notifications") + self.clipboard_greedy = ccaps.boolget("greedy") + self.clipboard_want_targets = ccaps.boolget("want_targets") + self.clipboard_selections = ccaps.strtupleget("selections", CLIPBOARDS) + self.clipboard_preferred_targets = ccaps.strtupleget("preferred-targets", ()) + else: + #no namespace in v4.3 and earlier: + self.clipboard_enabled = c.boolget("clipboard", False) + self.clipboard_notifications = c.boolget("clipboard.notifications") + self.clipboard_greedy = c.boolget("clipboard.greedy") + self.clipboard_want_targets = c.boolget("clipboard.want_targets") + self.clipboard_selections = c.strtupleget("clipboard.selections", CLIPBOARDS) + self.clipboard_preferred_targets = c.strtupleget("clipboard.preferred-targets", ()) log("client clipboard: enabled=%s, notifications=%s", self.clipboard_enabled, self.clipboard_notifications) - self.clipboard_greedy = c.boolget("clipboard.greedy") - self.clipboard_want_targets = c.boolget("clipboard.want_targets") - self.clipboard_selections = c.strtupleget("clipboard.selections", CLIPBOARDS) - self.clipboard_preferred_targets = c.strtupleget("clipboard.preferred-targets", ()) log("client clipboard: greedy=%s, want_targets=%s, selections=%s", self.clipboard_greedy, self.clipboard_want_targets, self.clipboard_selections)