diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-06-02 09:49:31 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-06-13 06:13:39 +0000 |
commit | b05d1c2ebfebf0f427a92668c0a7b177d0952012 (patch) | |
tree | 53bbf9a22cd2190984c4c348cbbc0102ce62bb11 /src/gui/kernel/qplatformcursor.h | |
parent | 8b23133e50b01dd1daf53b0e7561719c17a043d6 (diff) |
QPlatformCursor: Add functions for setting/clearing override cursors
QPA is modeled on the assumption that the cursor is a property
of the window and therefore sets the override cursors on all windows.
However, on macOS and Windows, the cursor is set per application (or
screen). On these platforms, the per window cursor setting needs
to be emulated which is a source of bugs especially for override
cursors.
Add new virtuals to QPlatformCursor allowing to set override
cursors which can be implemented by directly setting the cursor
on those platforms.
Task-number: QTBUG-40122
Task-number: QTBUG-61133
Change-Id: I31d6a927128d22bb1620a8ace35988c0e126236e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src/gui/kernel/qplatformcursor.h')
-rw-r--r-- | src/gui/kernel/qplatformcursor.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/gui/kernel/qplatformcursor.h b/src/gui/kernel/qplatformcursor.h index dddd9e5831..40e8a562f8 100644 --- a/src/gui/kernel/qplatformcursor.h +++ b/src/gui/kernel/qplatformcursor.h @@ -78,21 +78,36 @@ private: class Q_GUI_EXPORT QPlatformCursor : public QObject { public: + enum Capability { + OverrideCursor = 0x1 + }; + Q_DECLARE_FLAGS(Capabilities, Capability) + QPlatformCursor(); // input methods virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } #ifndef QT_NO_CURSOR virtual void changeCursor(QCursor * windowCursor, QWindow * window) = 0; -#endif + virtual void setOverrideCursor(const QCursor &); + virtual void clearOverrideCursor(); +#endif // QT_NO_CURSOR virtual QPoint pos() const; virtual void setPos(const QPoint &pos); + static Capabilities capabilities() { return m_capabilities; } + static void setCapabilities(Capabilities c) { m_capabilities = c; } + static void setCapability(Capability c) { m_capabilities.setFlag(c); } + private: friend void qt_qpa_set_cursor(QWidget * w, bool force); friend class QApplicationPrivate; + + static Capabilities m_capabilities; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformCursor::Capabilities) + QT_END_NAMESPACE #endif // QPLATFORMCURSOR_H |