Skip to content

Commit

Permalink
#3592 move clipboard caps to a prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Aug 8, 2022
1 parent c52d8ac commit df36fcc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 36 deletions.
32 changes: 17 additions & 15 deletions xpra/client/mixins/clipboard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is part of Xpra.
# Copyright (C) 2010-2021 Antoine Martin <[email protected]>
# Copyright (C) 2010-2022 Antoine Martin <[email protected]>
# Copyright (C) 2008, 2010 Nathaniel Smith <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
Expand Down Expand Up @@ -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:
Expand Down
30 changes: 16 additions & 14 deletions xpra/server/mixins/clipboard_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# This file is part of Xpra.
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Copyright (C) 2010-2022 Antoine Martin <[email protected]>
# Copyright (C) 2008 Nathaniel Smith <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
Expand Down Expand Up @@ -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):
Expand Down
25 changes: 18 additions & 7 deletions xpra/server/source/clipboard_connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# This file is part of Xpra.
# Copyright (C) 2010-2020 Antoine Martin <[email protected]>
# Copyright (C) 2010-2022 Antoine Martin <[email protected]>
# Copyright (C) 2008 Nathaniel Smith <[email protected]>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit df36fcc

Please sign in to comment.