From 035e92481cbab4e1011f16d7eec013598386b22b Mon Sep 17 00:00:00 2001 From: totaam Date: Sun, 2 Apr 2023 21:44:47 +0700 Subject: [PATCH] #1942 use new packet format for configuring the display --- xpra/client/mixins/display.py | 25 +++++++++++- xpra/server/mixins/display_manager.py | 58 ++++++++++++++++++++++++--- 2 files changed, 76 insertions(+), 7 deletions(-) diff --git a/xpra/client/mixins/display.py b/xpra/client/mixins/display.py index 6fc773d4d6..b29ecac646 100644 --- a/xpra/client/mixins/display.py +++ b/xpra/client/mixins/display.py @@ -514,7 +514,30 @@ def update_screen_size(self): root_w, root_h, sss = screen_settings[:3] log.info("sending updated screen size to server: %sx%s", root_w, root_h) log_screen_sizes(root_w, root_h, sss) - if self.server_desktop_size: + if "configure-display" in self.server_packet_types: + #new packet format: + root_w, root_h = screen_settings[:2] + sss = screen_settings[2] + ndesktops, desktop_names = screen_settings[3:5] + u_root_w, u_root_h = screen_settings[5:7] + xdpi, ydpi = screen_settings[7:9] + rrate, monitors = screen_settings[9:11] + attrs = { + "desktop-size" : (root_w, root_h), + "desktop-size-unscaled" : (u_root_w, u_root_h), + "monitors" : monitors, + "dpi" : {"x" : xdpi, "y" : ydpi}, + } + if ndesktops: + attrs["desktops"] = ndesktops, + attrs["desktop-names"] = desktop_names or () + if rrate: + attrs["vrefresh"] = rrate + log.warn(f"configure-display: {attrs}") + self.send("configure-display", attrs) + elif self.server_desktop_size: + log(f"sending legacy desktop-size packet: {screen_settings}") + #legacy packet: self.send("desktop_size", *screen_settings) self._last_screen_settings = screen_settings #update the max packet size (may have gone up): diff --git a/xpra/server/mixins/display_manager.py b/xpra/server/mixins/display_manager.py index 56902d8d29..1fc0fc39e3 100644 --- a/xpra/server/mixins/display_manager.py +++ b/xpra/server/mixins/display_manager.py @@ -4,7 +4,7 @@ # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. -from xpra.util import engs, log_screen_sizes +from xpra.util import engs, log_screen_sizes, typedict from xpra.os_util import bytestostr from xpra.scripts.config import FALSE_OPTIONS from xpra.common import get_refresh_rate_for_value, FULL_INFO @@ -311,10 +311,10 @@ def get_client_refresh_rate(self, ss): def _process_desktop_size(self, proto, packet): log("new desktop size from %s: %s", proto, packet) - width, height = packet[1:3] ss = self.get_server_source(proto) if ss is None: return + width, height = packet[1:3] ss.desktop_size = (width, height) if len(packet)>=12: ss.set_monitors(packet[11]) @@ -353,6 +353,51 @@ def _process_desktop_size(self, proto, packet): #ensures that DPI and antialias information gets reset: self.update_all_server_settings() + def _process_configure_display(self, proto, packet): + ss = self.get_server_source(proto) + if ss is None: + return + attrs = typedict(packet[1]) + desktop_size = attrs.intpair("desktop-size") + if desktop_size: + ss.desktop_size = desktop_size + desktop_size_unscaled = attrs.intpair("desktop-size-unscaled") + if desktop_size_unscaled: + ss.desktop_size_unscaled = desktop_size_unscaled + #vrefresh may be overriden in 'monitors' data: + vrefresh = attrs.intget("vrefresh") + if 0=4: + log.info("received updated display dimensions") + log.info(f"client display size is {width}x{height}") + log_screen_sizes(width, height, ss.screen_sizes) + self.calculate_workarea(width, height) + self.apply_refresh_rate(ss) + #ensures that DPI and antialias information gets reset: + self.update_all_server_settings() + + def dpi_changed(self): """ The x11 servers override this method @@ -403,8 +448,9 @@ def send_screenshot(self, proto): def init_packet_handlers(self): self.add_packet_handlers({ - "set-cursors" : self._process_set_cursors, - "set-bell" : self._process_set_bell, - "desktop_size" : self._process_desktop_size, - "screenshot" : self._process_screenshot, + "set-cursors" : self._process_set_cursors, + "set-bell" : self._process_set_bell, + "desktop_size" : self._process_desktop_size, + "configure-display" : self._process_configure_display, + "screenshot" : self._process_screenshot, })