Changeset View
Changeset View
Standalone View
Standalone View
cursor.h
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 40 | enum Shape { | |||
---|---|---|---|---|---|
46 | SizeSouthEast = 0x100 + 5, | 46 | SizeSouthEast = 0x100 + 5, | ||
47 | SizeSouth = 0x100 + 6, | 47 | SizeSouth = 0x100 + 6, | ||
48 | SizeSouthWest = 0x100 + 7 | 48 | SizeSouthWest = 0x100 + 7 | ||
49 | }; | 49 | }; | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | /** | 52 | /** | ||
53 | * @brief Wrapper round Qt::CursorShape with extensions enums into a single entity | 53 | * @brief Wrapper round Qt::CursorShape with extensions enums into a single entity | ||
54 | */ | 54 | **/ | ||
55 | class KWIN_EXPORT CursorShape { | 55 | class KWIN_EXPORT CursorShape { | ||
56 | public: | 56 | public: | ||
57 | CursorShape() = default; | 57 | CursorShape() = default; | ||
58 | CursorShape(Qt::CursorShape qtShape) { | 58 | CursorShape(Qt::CursorShape qtShape) { | ||
59 | m_shape = qtShape; | 59 | m_shape = qtShape; | ||
60 | } | 60 | } | ||
61 | CursorShape(KWin::ExtendedCursor::Shape kwinShape) { | 61 | CursorShape(KWin::ExtendedCursor::Shape kwinShape) { | ||
62 | m_shape = kwinShape; | 62 | m_shape = kwinShape; | ||
63 | } | 63 | } | ||
64 | bool operator==(const CursorShape &o) const { | 64 | bool operator==(const CursorShape &o) const { | ||
65 | return m_shape == o.m_shape; | 65 | return m_shape == o.m_shape; | ||
66 | } | 66 | } | ||
67 | operator int() const { | 67 | operator int() const { | ||
68 | return m_shape; | 68 | return m_shape; | ||
69 | } | 69 | } | ||
70 | /** | 70 | /** | ||
71 | * @brief The name of a cursor shape in the theme. | 71 | * @brief The name of a cursor shape in the theme. | ||
72 | */ | 72 | **/ | ||
73 | QByteArray name() const; | 73 | QByteArray name() const; | ||
74 | private: | 74 | private: | ||
75 | int m_shape = Qt::ArrowCursor; | 75 | int m_shape = Qt::ArrowCursor; | ||
76 | }; | 76 | }; | ||
77 | 77 | | |||
78 | /** | 78 | /** | ||
79 | * @short Replacement for QCursor. | 79 | * @short Replacement for QCursor. | ||
80 | * | 80 | * | ||
Show All 26 Lines | 99 | public: | |||
107 | * whenever a change to the cursor image is recognized. | 107 | * whenever a change to the cursor image is recognized. | ||
108 | * | 108 | * | ||
109 | * Use stopCursorTracking to no longer emit this signal. Note: the signal will be | 109 | * Use stopCursorTracking to no longer emit this signal. Note: the signal will be | ||
110 | * emitted until each call of this method has been matched with a call to stopCursorTracking. | 110 | * emitted until each call of this method has been matched with a call to stopCursorTracking. | ||
111 | * | 111 | * | ||
112 | * This tracking is not about pointer position tracking. | 112 | * This tracking is not about pointer position tracking. | ||
113 | * @see stopCursorTracking | 113 | * @see stopCursorTracking | ||
114 | * @see cursorChanged | 114 | * @see cursorChanged | ||
115 | */ | 115 | **/ | ||
116 | void startCursorTracking(); | 116 | void startCursorTracking(); | ||
117 | /** | 117 | /** | ||
118 | * @brief Disables tracking changes of cursor images. | 118 | * @brief Disables tracking changes of cursor images. | ||
119 | * | 119 | * | ||
120 | * Only call after using startCursorTracking. | 120 | * Only call after using startCursorTracking. | ||
121 | * | 121 | * | ||
122 | * @see startCursorTracking | 122 | * @see startCursorTracking | ||
123 | */ | 123 | **/ | ||
124 | void stopCursorTracking(); | 124 | void stopCursorTracking(); | ||
125 | 125 | | |||
126 | /** | 126 | /** | ||
127 | * @brief The name of the currently used Cursor theme. | 127 | * @brief The name of the currently used Cursor theme. | ||
128 | * | 128 | * | ||
129 | * @return const QString& | 129 | * @return const QString& | ||
130 | */ | 130 | **/ | ||
131 | const QString &themeName() const; | 131 | const QString &themeName() const; | ||
132 | /** | 132 | /** | ||
133 | * @brief The size of the currently used Cursor theme. | 133 | * @brief The size of the currently used Cursor theme. | ||
134 | * | 134 | * | ||
135 | * @return int | 135 | * @return int | ||
136 | */ | 136 | **/ | ||
137 | int themeSize() const; | 137 | int themeSize() const; | ||
138 | /** | 138 | /** | ||
139 | * @return list of alternative names for the cursor with @p name | 139 | * @return list of alternative names for the cursor with @p name | ||
140 | **/ | 140 | **/ | ||
141 | QVector<QByteArray> cursorAlternativeNames(const QByteArray &name) const; | 141 | QVector<QByteArray> cursorAlternativeNames(const QByteArray &name) const; | ||
142 | 142 | | |||
143 | /** | 143 | /** | ||
144 | * Returns the current cursor position. This method does an update of the mouse position if | 144 | * Returns the current cursor position. This method does an update of the mouse position if | ||
Show All 22 Lines | 165 | void mouseChanged(const QPoint& pos, const QPoint& oldpos, | |||
167 | Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); | 167 | Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); | ||
168 | /** | 168 | /** | ||
169 | * @brief Signal emitted when the cursor image changes. | 169 | * @brief Signal emitted when the cursor image changes. | ||
170 | * | 170 | * | ||
171 | * To enable these signals use startCursorTracking. | 171 | * To enable these signals use startCursorTracking. | ||
172 | * | 172 | * | ||
173 | * @see startCursorTracking | 173 | * @see startCursorTracking | ||
174 | * @see stopCursorTracking | 174 | * @see stopCursorTracking | ||
175 | */ | 175 | **/ | ||
176 | void cursorChanged(); | 176 | void cursorChanged(); | ||
177 | void themeChanged(); | 177 | void themeChanged(); | ||
178 | 178 | | |||
179 | protected: | 179 | protected: | ||
180 | /** | 180 | /** | ||
181 | * Called from x11Cursor to actually retrieve the X11 cursor. Base implementation returns | 181 | * Called from x11Cursor to actually retrieve the X11 cursor. Base implementation returns | ||
182 | * a null cursor, an implementing subclass should implement this method if it can provide X11 | 182 | * a null cursor, an implementing subclass should implement this method if it can provide X11 | ||
183 | * mouse cursors. | 183 | * mouse cursors. | ||
Show All 22 Lines | |||||
206 | /** | 206 | /** | ||
207 | * Called from stopMousePolling when the mouse polling gets deactivated. Base implementation | 207 | * Called from stopMousePolling when the mouse polling gets deactivated. Base implementation | ||
208 | * does nothing, inheriting classes can overwrite to e.g. stop a timer. | 208 | * does nothing, inheriting classes can overwrite to e.g. stop a timer. | ||
209 | **/ | 209 | **/ | ||
210 | virtual void doStopMousePolling(); | 210 | virtual void doStopMousePolling(); | ||
211 | /** | 211 | /** | ||
212 | * Called from startCursorTracking when cursor image tracking gets activated. Inheriting class needs | 212 | * Called from startCursorTracking when cursor image tracking gets activated. Inheriting class needs | ||
213 | * to overwrite to enable platform specific code for the tracking. | 213 | * to overwrite to enable platform specific code for the tracking. | ||
214 | */ | 214 | **/ | ||
215 | virtual void doStartCursorTracking(); | 215 | virtual void doStartCursorTracking(); | ||
216 | /** | 216 | /** | ||
217 | * Called from stopCursorTracking when cursor image tracking gets deactivated. Inheriting class needs | 217 | * Called from stopCursorTracking when cursor image tracking gets deactivated. Inheriting class needs | ||
218 | * to overwrite to disable platform specific code for the tracking. | 218 | * to overwrite to disable platform specific code for the tracking. | ||
219 | */ | 219 | **/ | ||
220 | virtual void doStopCursorTracking(); | 220 | virtual void doStopCursorTracking(); | ||
221 | bool isCursorTracking() const; | 221 | bool isCursorTracking() const; | ||
222 | /** | 222 | /** | ||
223 | * Provides the actual internal cursor position to inheriting classes. If an inheriting class needs | 223 | * Provides the actual internal cursor position to inheriting classes. If an inheriting class needs | ||
224 | * access to the cursor position this method should be used instead of the static @ref pos, as | 224 | * access to the cursor position this method should be used instead of the static @ref pos, as | ||
225 | * the static method syncs with the underlying system's cursor. | 225 | * the static method syncs with the underlying system's cursor. | ||
226 | **/ | 226 | **/ | ||
227 | const QPoint ¤tPos() const; | 227 | const QPoint ¤tPos() const; | ||
Show All 19 Lines | 239 | private: | |||
247 | 247 | | |||
248 | KWIN_SINGLETON(Cursor) | 248 | KWIN_SINGLETON(Cursor) | ||
249 | }; | 249 | }; | ||
250 | 250 | | |||
251 | /** | 251 | /** | ||
252 | * @brief Implementation using the InputRedirection framework to get pointer positions. | 252 | * @brief Implementation using the InputRedirection framework to get pointer positions. | ||
253 | * | 253 | * | ||
254 | * Does not support warping of cursor. | 254 | * Does not support warping of cursor. | ||
255 | * | 255 | **/ | ||
256 | */ | | |||
257 | class InputRedirectionCursor : public Cursor | 256 | class InputRedirectionCursor : public Cursor | ||
258 | { | 257 | { | ||
259 | Q_OBJECT | 258 | Q_OBJECT | ||
260 | public: | 259 | public: | ||
261 | explicit InputRedirectionCursor(QObject *parent); | 260 | explicit InputRedirectionCursor(QObject *parent); | ||
262 | virtual ~InputRedirectionCursor(); | 261 | virtual ~InputRedirectionCursor(); | ||
263 | protected: | 262 | protected: | ||
264 | virtual void doSetPos(); | 263 | virtual void doSetPos(); | ||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |