summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
authorIlya Fedin <fedin-ilja2010@ya.ru>2021-04-12 13:14:52 +0400
committerIlya Fedin <fedin-ilja2010@ya.ru>2021-04-20 17:20:10 +0400
commit6560778616b090f8cc73700675ec2ef385953fb6 (patch)
tree651648ec7cd99df65d080dc2764da7609e97e0a6 /src/plugins/platforms/xcb
parentc7a27678d6916a51848c991fb3ee21acc6a6f8ca (diff)
Read DPI from X Settings initially as well
Currently, Xft.dpi from X Resources is read initially, while changes are monitored for Xft/DPI from X Settings. These protocols are different and can have different values. E.g. MATE sets X Resources' Xft.dpi to 96.30859375, while X Settings' Xft/DPI is set to 197240 at 2x scale. This results in a very weird bug when Qt can't determine 2x scale initially, but if scale is changed at run time, Qt changes scale to the right value. The difference could be checked via xrdb -query and dump_xsettings (the second is from xsettingsd project). [ChangeLog] Qt now reads Xft/DPI from X settings at startup, and will prefer this value over Xft.dpi from X resources. Pick-to: 6.0 6.1 5.15 Change-Id: If6adac0c88198579332ddebc673f1524f324c0e4 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp23
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h2
2 files changed, 18 insertions, 7 deletions
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 3c57ffc7b0..c084b17782 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -114,17 +114,13 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t
}
auto dpiChangedCallback = [](QXcbVirtualDesktop *desktop, const QByteArray &, const QVariant &property, void *) {
- bool ok;
- int dpiTimes1k = property.toInt(&ok);
- if (!ok)
+ if (!desktop->setDpiFromXSettings(property))
return;
- int dpi = dpiTimes1k / 1024;
- if (desktop->m_forcedDpi == dpi)
- return;
- desktop->m_forcedDpi = dpi;
+ const auto dpi = desktop->forcedDpi();
for (QXcbScreen *screen : desktop->connection()->screens())
QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(screen->QPlatformScreen::screen(), dpi, dpi);
};
+ setDpiFromXSettings(xSettings()->setting("Xft/DPI"));
xSettings()->registerCallbackForProperty("Xft/DPI", dpiChangedCallback, nullptr);
}
@@ -425,6 +421,19 @@ void QXcbVirtualDesktop::readXResources()
}
}
+bool QXcbVirtualDesktop::setDpiFromXSettings(const QVariant &property)
+{
+ bool ok;
+ int dpiTimes1k = property.toInt(&ok);
+ if (!ok)
+ return false;
+ int dpi = dpiTimes1k / 1024;
+ if (m_forcedDpi == dpi)
+ return false;
+ m_forcedDpi = dpi;
+ return true;
+}
+
QSurfaceFormat QXcbVirtualDesktop::surfaceFormatFor(const QSurfaceFormat &format) const
{
const xcb_visualid_t xcb_visualid = connection()->hasDefaultVisualId() ? connection()->defaultVisualId()
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index 9ca68d1eca..ff30f599d6 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -117,6 +117,8 @@ private:
QByteArray &stringValue);
void readXResources();
+ bool setDpiFromXSettings(const QVariant &property);
+
xcb_screen_t *m_screen;
const int m_number;
QList<QPlatformScreen *> m_screens;