Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Vogtinator:boo1185048
libqt5-qtbase
0001-Use-the-physical-DPI-on-X11-as-logical-DPI...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Use-the-physical-DPI-on-X11-as-logical-DPI-by-defaul.patch of Package libqt5-qtbase
From eb5545318cc8a62750adc9ff6a803d935c832e27 Mon Sep 17 00:00:00 2001 From: Fabian Vogt <fabian@ritter-vogt.de> Date: Wed, 5 May 2021 11:42:51 +0200 Subject: [PATCH] Use the physical DPI on X11 as logical DPI by default If Xft.dpi is not set and QT_USE_PHYSICAL_DPI isn't explicitly set to 0, then use the physical size of the screen to calculate the logical DPI. Apply some heuristics to catch invalid EDID values and fall back to 96dpi in such cases. QTBUG-67928 QTBUG-93454 --- src/plugins/platforms/xcb/qxcbscreen.cpp | 33 ++++++++++++++++++++---- src/plugins/platforms/xcb/qxcbscreen.h | 1 + 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index e637ed827c..1932a2716f 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -717,12 +717,18 @@ QDpi QXcbScreen::logicalDpi() const if (forcedDpi > 0) return QDpi(forcedDpi, forcedDpi); - // 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)); + + // By default, X fakes the virtual size to be 96 dpi (+-rounding), + // so if it's different the user overwrote it. + // Prevent using DPI values lower than 96. This ensuers that connecting + // to e.g. a TV works somewhat predictabilly. + if (qRound(virtualDesktopPhysicalDPi.first) > 96 + && qRound(virtualDesktopPhysicalDPi.second) > 96) { + return virtualDesktopPhysicalDPi; + } + + return QDpi(m_pixelDensity * 96, m_pixelDensity * 96); } QPlatformCursor *QXcbScreen::cursor() const @@ -788,6 +794,23 @@ void QXcbScreen::updateGeometry(const QRect &geometry, uint8_t rotation) if (m_sizeMillimeters.isEmpty()) m_sizeMillimeters = sizeInMillimeters(geometry.size(), m_virtualDesktop->dpi()); + qreal dpi = geometry.width() / m_sizeMillimeters.width() * qreal(25.4); + qreal referenceDpi = physicalSize().width() <= 320 ? 128 : 96; + m_pixelDensity = qMax(1, qRound(dpi/referenceDpi)); + + bool usePhysicalDpiSet = false; + if(qEnvironmentVariableIntValue("QT_USE_PHYSICAL_DPI", &usePhysicalDpiSet) == 0 && usePhysicalDpiSet) + m_pixelDensity = 1; + + if(m_pixelDensity > 1) { + // If we have no physical size or the resolution is untypical, fall back to 1x + if (physicalSize().height() <= 0 + || geometry.height() < 1440 + || m_pixelDensity > 3) { + m_pixelDensity = 1; + } + } + m_geometry = geometry; m_availableGeometry = geometry & m_virtualDesktop->workArea(); QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index ad2980b55e..b627006b53 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -231,6 +231,7 @@ private: QXcbCursor *m_cursor; qreal m_refreshRate = 60.0; QEdidParser m_edid; + int m_pixelDensity = 1; }; #ifndef QT_NO_DEBUG_STREAM -- 2.25.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor