Commit d6813d00 authored by Paul Olav Tvete's avatar Paul Olav Tvete
Browse files

Add application attribute to disable highDPI scaling


Main use case is for KDE Plasma, which needs to know about real
window system coordinates. Can also be used by applications that
do all the scaling manually, and that do not want to have Qt
scale the coordinate systems and painters.

Change-Id: Ic595131c5e2fb4c0af95e9b5bd3e40beee86760b
Reviewed-by: default avatarMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
No related merge requests found
Showing with 14 additions and 0 deletions
......@@ -496,6 +496,7 @@ public:
AA_UseSoftwareOpenGL = 17,
AA_ShareOpenGLContexts = 18,
AA_SetPalette = 19,
AA_NoHighDpiScaling = 20,
// Add new attributes before this line
AA_AttributeCount
......
......@@ -197,6 +197,11 @@
\value AA_SetPalette Indicates whether a palette was explicitly set on the
QApplication/QGuiApplication. This value has been added in Qt 5.5.
\value AA_NoHighDpiScaling Disables all high-DPI scaling in Qt, exposing window
system coordinates. Note that the window system may do its own scaling,
so this does not guarantee that QPaintDevice::devicePixelRatio() will
be equal to 1. This value has been added in Qt 5.6.
The following values are obsolete:
\value AA_ImmediateWidgetCreation This attribute is no longer fully
......
......@@ -142,6 +142,11 @@ QDpi QHighDpiScaling::m_logicalDpi; // The scaled logical DPI of the primary scr
*/
void QHighDpiScaling::initHighDpiScaling()
{
if (QCoreApplication::testAttribute(Qt::AA_NoHighDpiScaling)) {
m_factor = 1;
m_active = false;
return;
}
m_factor = initialScaleFactor();
bool usePlatformPluginPixelDensity = qEnvironmentVariableIsSet(autoScreenEnvVar)
|| qgetenv(legacyDevicePixelEnvVar).toLower() == "auto";
......@@ -157,6 +162,9 @@ void QHighDpiScaling::initHighDpiScaling()
void QHighDpiScaling::updateHighDpiScaling()
{
if (QCoreApplication::testAttribute(Qt::AA_NoHighDpiScaling))
return;
if (m_usePixelDensity && !m_pixelDensityScalingActive) {
Q_FOREACH (QScreen *screen, QGuiApplication::screens()) {
if (!qFuzzyCompare(screenSubfactor(screen->handle()), qreal(1))) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment