From 97bc28778227d00affb8cbd6a1ac9a2258cdf95d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 27 Jan 2014 13:19:22 +0100 Subject: [PATCH] QWindowsCursor: Add API for determining the cursor state. Detect the 'suppressed' state new in Windows 8. Change-Id: I0faa994aa7b91869cedba36b777b1784818efcce Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowscursor.cpp | 16 ++++++++++++++++ src/plugins/platforms/windows/qwindowscursor.h | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index e0d7d0c919..d574730328 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -465,6 +465,22 @@ QPoint QWindowsCursor::mousePosition() return QPoint(p.x, p.y); } +QWindowsCursor::CursorState QWindowsCursor::cursorState() +{ +#ifndef Q_OS_WINCE + enum { cursorShowing = 0x1, cursorSuppressed = 0x2 }; // Windows 8: CURSOR_SUPPRESSED + CURSORINFO cursorInfo; + cursorInfo.cbSize = sizeof(CURSORINFO); + if (GetCursorInfo(&cursorInfo)) { + if (cursorInfo.flags & CursorShowing) + return CursorShowing; + if (cursorInfo.flags & cursorSuppressed) + return CursorSuppressed; + } +#endif // !Q_OS_WINCE + return CursorHidden; +} + void QWindowsCursor::setPos(const QPoint &pos) { SetCursorPos(pos.x(), pos.y()); diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index b366d9a06a..31da4e367d 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -93,6 +93,12 @@ private: class QWindowsCursor : public QPlatformCursor { public: + enum CursorState { + CursorShowing, + CursorHidden, + CursorSuppressed // Cursor suppressed by touch interaction (Windows 8). + }; + QWindowsCursor() {} virtual void changeCursor(QCursor * widgetCursor, QWindow * widget); @@ -102,6 +108,7 @@ public: static HCURSOR createPixmapCursor(const QPixmap &pixmap, int hotX, int hotY); static HCURSOR createSystemCursor(const QCursor &c); static QPoint mousePosition(); + static CursorState cursorState(); QWindowsWindowCursor standardWindowCursor(Qt::CursorShape s = Qt::ArrowCursor); QWindowsWindowCursor pixmapWindowCursor(const QCursor &c);