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. Change-Id: If6adac0c88198579332ddebc673f1524f324c0e4 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> (cherry picked from commit 6560778616b090f8cc73700675ec2ef385953fb6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9b0ffccabd
commit
567e7f1518
@ -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()
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user