summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2020-06-08 22:38:15 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2020-08-26 16:37:43 +0200
commit77e04acb4e0266d7da2f9e7100ec22836d9889d0 (patch)
tree777b515337b33f19c3f12a82d4d25a9bb9fdd38e /src/plugins
parented813c19fa422cd0858dda25a3c401e428fd6e0b (diff)
X11: restrict fallback logical DPI to 96 and higher
QXcbScreen determines logical DPI using the following priority: 1) use Xft.dpi if set 2) virtual desktop size / virtual desktop physical size (This change does not restrict or alter the value obtained from Xft.dpi in any way) The fallback option 2) has several problems: - It is a physical DPI, which does not account for viewing distance or user preference - It is a global value for the entire virtual desktop (not per-screen) - X servers usually fake the virtual desktop physical size such that the computed DPI ends up at 96; in cases where this does not happen we can end up with a surprising DPI value. We might be better off just hardcoding 96 here, to avoid picking up an incorrect physical DPI when for example connecting to a TV (as reported in QTBUG-67928). This change does not go as far as hardcoding 96, but instead restricts the (fallback) DPI value to be 96 or higher. Pick-to: 5.15 Task-number: QTBUG-67928 Change-Id: Ieea6c7a137261282b40302fb4c19273c5def10af Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 4d3f269cf4..6ce8a91f36 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -698,7 +698,12 @@ QDpi QXcbScreen::logicalDpi() const
if (forcedDpi > 0)
return QDpi(forcedDpi, forcedDpi);
- return m_virtualDesktop->dpi();
+ // Fall back to physical virtual desktop DPI, but prevent
+ // using DPI values lower than 96. This ensuers that connecting
+ // to e.g. a TV works somewhat predictabilly.
+ QDpi virtualDesktopPhysicalDPi = m_virtualDesktop->dpi();
+ return QDpi(std::max(virtualDesktopPhysicalDPi.first, 96.0),
+ std::max(virtualDesktopPhysicalDPi.second, 96.0));
}
QPlatformCursor *QXcbScreen::cursor() const