diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-30 09:09:03 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-31 20:33:56 +0000 |
commit | 46fc3d3729df9e81e42f87c46907d6eb81a0c669 (patch) | |
tree | a3fff6e5a94ee3e52036d35146fa59ee893cdcc8 /src/plugins/platforms/windows/qwindowscursor.cpp | |
parent | e386cd03d12e401b9e3945602e9621a86009fa11 (diff) |
Windows QPA: Fix override cursor being cleared when crossing window borders
Override cursors can be modified externally when for example crossing
window borders. Add helper function to enforce the cursor again to
QWindowsWindow::applyCursor() which is called for enter events.
Task-number: QTBUG-69637
Change-Id: Ibea4da9f2aac81377002b626daae64b1102f6c2b
Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowscursor.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowscursor.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index e1a5837201..72155a1d1b 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -549,6 +549,7 @@ CursorHandlePtr QWindowsCursor::standardWindowCursor(Qt::CursorShape shape) } HCURSOR QWindowsCursor::m_overriddenCursor = nullptr; +HCURSOR QWindowsCursor::m_overrideCursor = nullptr; /*! \brief Return cached pixmap cursor or create new one. @@ -621,11 +622,20 @@ void QWindowsCursor::changeCursor(QCursor *cursorIn, QWindow *window) } } +// QTBUG-69637: Override cursors can get reset externally when moving across +// window borders. Enforce the cursor again (to be called from enter event). +void QWindowsCursor::enforceOverrideCursor() +{ + if (hasOverrideCursor() && m_overrideCursor != GetCursor()) + SetCursor(m_overrideCursor); +} + void QWindowsCursor::setOverrideCursor(const QCursor &cursor) { const CursorHandlePtr wcursor = cursorHandle(cursor); - if (wcursor->handle()) { - const HCURSOR previousCursor = SetCursor(wcursor->handle()); + if (const auto overrideCursor = wcursor->handle()) { + m_overrideCursor = overrideCursor; + const HCURSOR previousCursor = SetCursor(overrideCursor); if (m_overriddenCursor == nullptr) m_overriddenCursor = previousCursor; } else { @@ -638,7 +648,7 @@ void QWindowsCursor::clearOverrideCursor() { if (m_overriddenCursor) { SetCursor(m_overriddenCursor); - m_overriddenCursor = nullptr; + m_overriddenCursor = m_overrideCursor = nullptr; } } |