From 8cce316b1f1a50000e56c141046e215d5ab2df87 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 4 Oct 2017 12:38:34 +0000 Subject: [PATCH] GTK3 can give us the dpi, use that if we don't have a better platform API value git-svn-id: https://xpra.org/svn/Xpra/trunk@17097 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/gtk3/client.py | 13 +++++++++++++ src/xpra/client/ui_client_base.py | 21 ++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/xpra/client/gtk3/client.py b/src/xpra/client/gtk3/client.py index 37b9d2bc54..c2570a2490 100644 --- a/src/xpra/client/gtk3/client.py +++ b/src/xpra/client/gtk3/client.py @@ -7,6 +7,7 @@ from gi.repository import GObject #@UnresolvedImport from gi.repository import Gtk #@UnresolvedImport +from gi.repository import Gdk #@UnresolvedImport #this is an entry point, so do thread init early: #GObject.threads_init() @@ -57,6 +58,18 @@ def do_get_core_encodings(self): cencs.append("rgb32") return cencs + def get_xdpi(self): + xdpi = GTKXpraClient.get_xdpi(self) + if xdpi>0: + return xdpi + return Gdk.Screen.get_default().get_resolution() + + def get_ydpi(self): + ydpi = GTKXpraClient.get_ydpi(self) + if ydpi>0: + return ydpi + return Gdk.Screen.get_default().get_resolution() + def get_tray_menu_helper_classes(self): tmhc = GTKXpraClient.get_tray_menu_helper_classes(self) diff --git a/src/xpra/client/ui_client_base.py b/src/xpra/client/ui_client_base.py index 27c6954451..cf6a6680f6 100644 --- a/src/xpra/client/ui_client_base.py +++ b/src/xpra/client/ui_client_base.py @@ -1050,13 +1050,14 @@ def update_screen_size(self): screenlog("update_screen_size() sizes=%s, %s desktops: %s", sss, ndesktops, desktop_names) if self.dpi>0: #use command line value supplied, but scale it: - xdpi = self.cx(self.dpi) - ydpi = self.cy(self.dpi) + xdpi = ydpi = self.dpi else: #not supplied, use platform detection code: - xdpi = self.cx(get_xdpi()) - ydpi = self.cy(get_ydpi()) - screenlog("dpi: %s -> %s", (get_xdpi(), get_ydpi()), (xdpi, ydpi)) + xdpi = self.get_xdpi() + ydpi = self.get_ydpi() + xdpi = self.cx(xdpi) + ydpi = self.cy(ydpi) + screenlog("dpi: %s -> %s", (get_xdpi(), get_ydpi()), (xdpi, ydpi)) screen_settings = (root_w, root_h, sss, ndesktops, desktop_names, u_root_w, u_root_h, xdpi, ydpi) screenlog("update_screen_size() new settings=%s", screen_settings) screenlog("update_screen_size() current settings=%s", self._last_screen_settings) @@ -1070,6 +1071,12 @@ def update_screen_size(self): #update the max packet size (may have gone up): self.set_max_packet_size() + def get_xdpi(self): + return get_xdpi() + + def get_ydpi(self): + return get_ydpi() + def scaleup(self): scaling = max(self.xscale, self.yscale) @@ -1474,8 +1481,8 @@ def make_hello(self): else: #not supplied, use platform detection code: #platforms may also provide per-axis dpi (later win32 versions do) - xdpi = get_xdpi() - ydpi = get_ydpi() + xdpi = self.get_xdpi() + ydpi = self.get_ydpi() screenlog("xdpi=%i, ydpi=%i", xdpi, ydpi) if xdpi>0 and ydpi>0: xdpi = self.cx(xdpi)