summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qhighdpiscaling_p.h
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@theqtcompany.com>2015-05-26 22:22:37 +0200
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-05-29 15:41:38 +0000
commitf9b1596fe1aeacf4f3d977c32e74b7ad585d3d3e (patch)
tree82c04fce2ef3a56540ebb6e06df5b29a4f1fa71b /src/gui/kernel/qhighdpiscaling_p.h
parentc2d5ecf8766d3da70b17348e92cda31b00e204a7 (diff)
Refactor QHighDpiScaling internals and usage
Overall goal is to simplify, separate concerns, and improve cross-platform-ness and testability. QT_SCALE_FACTOR is now a pure cross-platform global scale factor setter has no "auto". "auto" requires input from the platform plugin via QPlatformScreen:: pixelDensity() and gets a separate environment variable: QT_AUTO_SCREEN_SCALE_FACTOR The effective scale factor (aka devicePixelRatio) is now computed as the product of the global, screen, and window scale factors. This matches how devicePixelRatio is computed in general (the window system devicePixelRatio is also a factor), and makes QT_SCALE_FACTOR work consistently regardless if there is a window scale factor set or not. This also means we can remove the if/else casing from the nativePixels conversion functions. Add QHighDpiScaling initializer which reads the environment variables and sets the "active" variables. Call it during QGuiApplication construction, before the platform plugin is created Add per-screen scale factor setting capability to the manual test. This makes it possible to test this logic on all platforms. The command line argument is --screen-scale-factor. Change-Id: I054337cbae37a01cdd731d26d9cb628fcecdb652 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qhighdpiscaling_p.h')
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 2350ca6fdb..a5d4c40a07 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -83,6 +83,10 @@ class QPlatformScreen;
class Q_GUI_EXPORT QHighDpiScaling {
public:
+ static void initHighDPiScaling();
+ static void setGlobalFactor(qreal factor);
+ static void setScreenFactor(QScreen *window, qreal factor);
+
static bool isActive() { return m_active; }
static qreal factor(const QWindow *window);
static qreal factor(const QScreen *screen);
@@ -91,13 +95,12 @@ public:
static QPoint origin(const QPlatformScreen *platformScreen);
static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen);
static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen);
- static void setFactor(qreal factor);
- static void setWindowFactor(QWindow *window, qreal factor);
private:
+ static qreal screenSubfactor(const QPlatformScreen *screen);
+
static qreal m_factor;
- static bool m_autoFactor;
static bool m_active;
- static bool m_perWindowActive;
+ static bool m_perScreenActive;
};
// Coordinate system conversion functions:
@@ -157,7 +160,6 @@ inline QRect toNative(const QRect &rect, qreal scaleFactor, const QPoint &origin
}
-
inline QRect fromNative(const QRect &rect, const QScreen *screen, const QPoint &screenOrigin)
{
return toNative(rect, QHighDpiScaling::factor(screen), screenOrigin);