Skip to content

Commit

Permalink
#1942 use new packet format for configuring the display
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Apr 2, 2023
1 parent 88fcf23 commit 035e924
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 7 deletions.
25 changes: 24 additions & 1 deletion xpra/client/mixins/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
58 changes: 52 additions & 6 deletions xpra/server/mixins/display_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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<vrefresh<240 and hasattr(ss, "vrefresh") and getattr(ss, "vrefresh")!=vrefresh:
ss.vrefresh = vrefresh
monitors = attrs.dictget("monitors")
if monitors:
ss.set_monitors(monitors)
dpix = attrs.intget("dpi.x")
dpiy = attrs.intget("dpi.y")
if dpix and dpiy:
if dpix!=self.xdpi or dpiy!=self.ydpi:
self.xdpi, self.ydpi = dpix, dpiy
log("new dpi: %ix%i", dpix, dpiy)
self.dpi = round((dpix + dpiy)/2)
self.dpi_changed()
desktop_names = attrs.strtupleget("desktop-names")
if desktop_names:
ss.set_desktops(attrs.intget("desktops", len(desktop_names)), desktop_names)
self.calculate_desktops()
#don't bother with screen-sizes?
bigger = ss.screen_resize_bigger
width, height = desktop_size
log("client requesting new size: %sx%s (bigger=%s)", width, height, bigger)
self.set_screen_size(width, height, bigger)
if len(packet)>=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
Expand Down Expand Up @@ -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,
})

0 comments on commit 035e924

Please sign in to comment.