From bee52599d1969b963ca341f5eebfba175738d729 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 7 Dec 2022 22:55:32 +0700 Subject: [PATCH] #56 honour dpi when setting initial resolution --- xpra/x11/desktop/desktop_server.py | 2 +- xpra/x11/desktop/monitor_server.py | 2 +- xpra/x11/server.py | 2 +- xpra/x11/vfb_util.py | 7 ++++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/xpra/x11/desktop/desktop_server.py b/xpra/x11/desktop/desktop_server.py index 466956ec8f..45053ffd26 100644 --- a/xpra/x11/desktop/desktop_server.py +++ b/xpra/x11/desktop/desktop_server.py @@ -48,7 +48,7 @@ def server_init(self): log.warn(" using %r", res[0]) res = (res[0], ) with xlog: - set_initial_resolution(res) + set_initial_resolution(res, self.dpi or self.default_dpi) def configure_best_screen_size(self): diff --git a/xpra/x11/desktop/monitor_server.py b/xpra/x11/desktop/monitor_server.py index 824e9e2014..5fed8e1e86 100644 --- a/xpra/x11/desktop/monitor_server.py +++ b/xpra/x11/desktop/monitor_server.py @@ -49,7 +49,7 @@ def server_init(self): return res = self.initial_resolutions or get_desktop_vfb_resolutions(default_refresh_rate=self.refresh_rate) with xlog: - set_initial_resolution(res) + set_initial_resolution(res, self.dpi or self.default_dpi) def get_server_mode(self): diff --git a/xpra/x11/server.py b/xpra/x11/server.py index 925064ae25..c8c99fe481 100644 --- a/xpra/x11/server.py +++ b/xpra/x11/server.py @@ -107,7 +107,7 @@ def server_init(self): from xpra.x11.vfb_util import set_initial_resolution, parse_env_resolutions DEFAULT_VFB_RESOLUTIONS = parse_env_resolutions(default_refresh_rate=self.refresh_rate) with xlog: - set_initial_resolution(self.initial_resolutions or DEFAULT_VFB_RESOLUTIONS) + set_initial_resolution(self.initial_resolutions or DEFAULT_VFB_RESOLUTIONS, self.dpi or self.default_dpi) def validate(self): if not X11Window.displayHasXComposite(): diff --git a/xpra/x11/vfb_util.py b/xpra/x11/vfb_util.py index a061271de6..63d33ef0f2 100644 --- a/xpra/x11/vfb_util.py +++ b/xpra/x11/vfb_util.py @@ -358,7 +358,7 @@ def kill_xvfb(xvfb_pid): os.unlink(xauthority) -def set_initial_resolution(resolutions): +def set_initial_resolution(resolutions, dpi=0): try: log = get_vfb_logger() log("set_initial_resolution(%s)", resolutions) @@ -378,10 +378,15 @@ def set_initial_resolution(resolutions): if not (isinstance(v, int) for v in res): raise ValueError(f"resolution values must be ints, found: {res} ({csv(type(v) for v in res)})") w, h, hz = res + mdpi = dpi or 96 + def rdpi(v): + return round(v * 25.4 / mdpi) monitors[i] = { "name" : f"VFB-{i}", "primary" : i==0, "geometry" : (x, y, w, h), + "width-mm" : rdpi(w), + "height-mm" : rdpi(h), "refresh-rate" : hz*1000, "automatic" : True, }