diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2014-05-21 13:52:53 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@digia.com> | 2015-03-26 11:00:14 +0100 |
commit | 70f565b6e43b6ab93b01112286a40869155207c8 (patch) | |
tree | ed4c7fee3fdc5a25bce1041e9aa4616155b8eabd /src/gui/kernel/qcursor.cpp | |
parent | 3cede847c39269374c52dcf156dc982d7a51f29c (diff) |
WIP: Add platform independent high-dpi support to QtGui
Add coordinate scaling support to the QWindow/
QWindowSystemInterface layer. The scale factor can
be set with the QT_HIGHDPI_SCALE_FACTOR environment
variable.
Setting a scale factor different than the default (1)
now has the following effects:
QWindow::devicePixelRatio is set accordingly, enabling
the high-dpi code paths.
QWindow and related classes now return geometry in
device independent pixels. This includes screen,
desktop and window geometry as well as event coordinates.
The platform plugins continue to operate in device
pixels, unaware of the scaling.
Task-number: QTBUG-38858
Change-Id: I85b0d1bc682b25196f6db286e672a64f8da0ae5c
Diffstat (limited to 'src/gui/kernel/qcursor.cpp')
-rw-r--r-- | src/gui/kernel/qcursor.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index 7e073370f2..e6bf2b0be9 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -43,6 +43,7 @@ #include <qpa/qplatformcursor.h> #include <private/qguiapplication_p.h> +#include <private/qhighdpiscaling_p.h> QT_BEGIN_NAMESPACE @@ -179,7 +180,7 @@ QPoint QCursor::pos(const QScreen *screen) { if (screen) if (const QPlatformCursor *cursor = screen->handle()->cursor()) - return cursor->pos(); + return qHighDpiToDeviceIndependentPixels(cursor->pos()); return QGuiApplicationPrivate::lastCursorPosition.toPoint(); } @@ -231,12 +232,12 @@ void QCursor::setPos(QScreen *screen, int x, int y) { if (screen) { if (QPlatformCursor *cursor = screen->handle()->cursor()) { - const QPoint pos = QPoint(x, y); + const QPoint devicePos = qHighDpiToDevicePixels(QPoint(x, y)); // Need to check, since some X servers generate null mouse move // events, causing looping in applications which call setPos() on // every mouse move event. - if (pos != cursor->pos()) - cursor->setPos(pos); + if (devicePos != cursor->pos()) + cursor->setPos(devicePos); } } } |