Windows: Fix QPlatformCursor::pos()/setPos() for DPR scaling.

Task-number: QTBUG-38858
Change-Id: Ibb0355ae19a382e4eb3805fe6d6afab2a2a603e6
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
This commit is contained in:
Friedemann Kleint 2014-08-28 17:01:21 +02:00
parent 1d66c9eba8
commit 83dab766fc
2 changed files with 9 additions and 2 deletions

View File

@ -44,6 +44,7 @@
#include "qwindowscontext.h"
#include "qwindowswindow.h"
#include "qwindowsscreen.h"
#include "qwindowsscaling.h"
#include <QtGui/QBitmap>
#include <QtGui/QImage>
@ -624,9 +625,15 @@ QWindowsCursor::CursorState QWindowsCursor::cursorState()
return CursorHidden;
}
QPoint QWindowsCursor::pos() const
{
return mousePosition() / QWindowsScaling::factor();
}
void QWindowsCursor::setPos(const QPoint &pos)
{
SetCursorPos(pos.x(), pos.y());
const QPoint posDp = pos * QWindowsScaling::factor();
SetCursorPos(posDp.x() , posDp.y());
}
/*!

View File

@ -102,7 +102,7 @@ public:
QWindowsCursor() {}
void changeCursor(QCursor * widgetCursor, QWindow * widget) Q_DECL_OVERRIDE;
QPoint pos() const Q_DECL_OVERRIDE { return mousePosition(); }
QPoint pos() const Q_DECL_OVERRIDE;
void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
static HCURSOR createPixmapCursor(const QPixmap &pixmap, const QPoint &hotSpot);