summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-08-06 09:02:13 +0200
committerFriedemann Kleint <Friedemann.Kleint@digia.com>2014-08-06 14:00:35 +0200
commit07bbc4da320c7f4710af0139516b9c8bafe33c52 (patch)
tree81bfb8d174cff5af4cac08e6c4a6f2824342ca3e /src
parent8b75ae4b82ae689dd8f9cf6db16cd7a8d2f402a1 (diff)
Windows: Refactor QWindowsDragCursorWindow().
QWindowsDragCursorWindow is a helper window used to display the drag cursor when doing DnD by touch, in which case Windows hides the mouse cursor. Base it on QRasterWindow and fix the size calculation for device pixel ratio scaling. Task-number: QTBUG-38858 Task-number: QTBUG-38993 Change-Id: I462ece3e5c8fe8be914e039ba391a28a77e0d771 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp42
1 files changed, 13 insertions, 29 deletions
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index 861ddbe5b6..716d892472 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -54,9 +54,7 @@
#include <QtGui/QMouseEvent>
#include <QtGui/QPixmap>
#include <QtGui/QPainter>
-#include <QtGui/QPaintDevice>
-#include <QtGui/QBackingStore>
-#include <QtGui/QWindow>
+#include <QtGui/QRasterWindow>
#include <QtGui/QGuiApplication>
#include <qpa/qwindowsysteminterface_p.h>
#include <QtGui/private/qguiapplication_p.h>
@@ -78,7 +76,7 @@ QT_BEGIN_NAMESPACE
\ingroup qt-lighthouse-win
*/
-class QWindowsDragCursorWindow : public QWindow
+class QWindowsDragCursorWindow : public QRasterWindow
{
public:
explicit QWindowsDragCursorWindow(QWindow *parent = 0);
@@ -86,18 +84,18 @@ public:
void setPixmap(const QPixmap &p);
protected:
- void exposeEvent(QExposeEvent *);
+ void paintEvent(QPaintEvent *)
+ {
+ QPainter painter(this);
+ painter.drawPixmap(0, 0, m_pixmap);
+ }
private:
- void render();
-
- QBackingStore m_backingStore;
QPixmap m_pixmap;
};
QWindowsDragCursorWindow::QWindowsDragCursorWindow(QWindow *parent)
- : QWindow(parent)
- , m_backingStore(this)
+ : QRasterWindow(parent)
{
QSurfaceFormat windowFormat = format();
windowFormat.setAlphaBufferSize(8);
@@ -113,31 +111,17 @@ void QWindowsDragCursorWindow::setPixmap(const QPixmap &p)
if (p.cacheKey() == m_pixmap.cacheKey())
return;
const QSize oldSize = m_pixmap.size();
- const QSize newSize = p.size();
+ QSize newSize = p.size();
qCDebug(lcQpaMime) << __FUNCTION__ << p.cacheKey() << newSize;
m_pixmap = p;
if (oldSize != newSize) {
+ const qreal pixDevicePixelRatio = p.devicePixelRatio();
+ if (pixDevicePixelRatio > 1.0 && qFuzzyCompare(pixDevicePixelRatio, devicePixelRatio()))
+ newSize /= qRound(pixDevicePixelRatio);
resize(newSize);
- m_backingStore.resize(newSize);
}
if (isVisible())
- render();
-}
-
-void QWindowsDragCursorWindow::exposeEvent(QExposeEvent *)
-{
- Q_ASSERT(!m_pixmap.isNull());
- render();
-}
-
-void QWindowsDragCursorWindow::render()
-{
- const QRect rect(QPoint(0, 0), m_pixmap.size());
- m_backingStore.beginPaint(rect);
- QPainter painter(m_backingStore.paintDevice());
- painter.drawPixmap(0, 0, m_pixmap);
- m_backingStore.endPaint();
- m_backingStore.flush(rect);
+ update();
}
/*!