diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2020-06-16 00:48:38 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2020-08-05 09:23:09 +0000 |
commit | ec82a44b40821d334d3fcecc1f18f57add590416 (patch) | |
tree | 5097cf47b3f2f622b21ca40b0b37ba0f5d2d498d /src/plugins/platforms | |
parent | 00f2d1a09bf9bb2d6fb9be4bdd12fa8229a11def (diff) |
XCB: Update logical DPI on “Xft/DPI” change
Install XSettings property change callback on the “Xft/DPI”
property. Update QxcbVirtualDesktop::m_forcedDpi and QScreen
logicalDPI on change.
Pick-to: 5.15
Change-Id: I578ebe9017fee58acd7a5c432cbd614fd35f2f55
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbscreen.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 9dc7c97eab..4d3f269cf4 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -112,6 +112,20 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t xcb_depth_next(&depth_iterator); } + + auto dpiChangedCallback = [](QXcbVirtualDesktop *desktop, const QByteArray &, const QVariant &property, void *) { + bool ok; + int dpiTimes1k = property.toInt(&ok); + if (!ok) + return; + int dpi = dpiTimes1k / 1024; + if (desktop->m_forcedDpi == dpi) + return; + desktop->m_forcedDpi = dpi; + for (QXcbScreen *screen : desktop->connection()->screens()) + QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(screen->QPlatformScreen::screen(), dpi, dpi); + }; + xSettings()->registerCallbackForProperty("Xft/DPI", dpiChangedCallback, nullptr); } QXcbVirtualDesktop::~QXcbVirtualDesktop() |