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