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>
bb10
Morten Johan Sørvig 2020-06-16 00:48:38 +02:00
parent 00f2d1a09b
commit ec82a44b40
1 changed files with 14 additions and 0 deletions

View File

@ -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()