Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpad/src/backends/libinputcommon.h
- This file was copied from kcms/touchpad/src/backends/kwin_wayland/kwinwaylandtouchpad.h.
1 | /* | 1 | #ifndef LIBINPUTCOMMON_H | ||
---|---|---|---|---|---|
romangg: Most of the code in this file was written by me and is now copy-pasted. Please keep in my… | |||||
2 | * Copyright 2017 Roman Gilg <subdiff@gmail.com> | 2 | #define LIBINPUTCOMMON_H | ||
Needs copyright notice (you should of course add yourself to the notice for files with non-marginal changes). romangg: Needs copyright notice (you should of course add yourself to the notice for files with non… | |||||
3 | * | | |||
4 | * This program is free software; you can redistribute it and/or modify | | |||
5 | * it under the terms of the GNU General Public License as published by | | |||
6 | * the Free Software Foundation; either version 2 of the License, or | | |||
7 | * (at your option) any later version. | | |||
8 | * | | |||
9 | * This program is distributed in the hope that it will be useful, | | |||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | | |||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | |||
12 | * GNU General Public License for more details. | | |||
13 | * | | |||
14 | * You should have received a copy of the GNU General Public License | | |||
15 | * along with this program; if not, write to the Free Software | | |||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | | |||
17 | */ | | |||
18 | | ||||
19 | #ifndef KWINWAYLANDTOUCHPAD_H | | |||
20 | #define KWINWAYLANDTOUCHPAD_H | | |||
21 | 3 | | |||
22 | #include <QObject> | 4 | #include <QObject> | ||
23 | #include <QString> | 5 | #include <QVariant> | ||
6 | | ||||
7 | namespace { | ||||
8 | template<typename T> | ||||
9 | T valueLoaderPart(QVariant const &reply) { Q_UNUSED(reply); return T(); } | ||||
10 | | ||||
11 | template<> | ||||
12 | bool valueLoaderPart(QVariant const &reply) { return reply.toBool(); } | ||||
13 | | ||||
14 | template<> | ||||
15 | int valueLoaderPart(QVariant const &reply) { return reply.toInt(); } | ||||
24 | 16 | | |||
25 | class QDBusInterface; | 17 | template<> | ||
18 | quint32 valueLoaderPart(QVariant const &reply) { return reply.toInt(); } | ||||
26 | 19 | | |||
27 | class KWinWaylandTouchpad : public QObject | 20 | template<> | ||
21 | qreal valueLoaderPart(QVariant const &reply) { return reply.toReal(); } | ||||
22 | | ||||
23 | template<> | ||||
24 | QString valueLoaderPart(QVariant const &reply) { return reply.toString(); } | ||||
25 | | ||||
26 | template<> | ||||
27 | Qt::MouseButtons valueLoaderPart(QVariant const &reply) { return static_cast<Qt::MouseButtons>(reply.toInt()); } | ||||
28 | } | ||||
29 | | ||||
30 | class LibinputCommon : public QObject | ||||
28 | { | 31 | { | ||
29 | Q_OBJECT | 32 | Q_OBJECT | ||
30 | 33 | | |||
31 | // | 34 | // | ||
32 | // general | 35 | // general | ||
33 | Q_PROPERTY(QString name READ name CONSTANT) | 36 | Q_PROPERTY(QString name READ name CONSTANT)// | ||
34 | Q_PROPERTY(bool supportsDisableEvents READ supportsDisableEvents CONSTANT) | 37 | Q_PROPERTY(bool supportsDisableEvents READ supportsDisableEvents CONSTANT)// | ||
35 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) | 38 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)// | ||
romangg: rm these comment markers | |||||
36 | 39 | | |||
37 | // | 40 | // | ||
38 | // advanced | 41 | // advanced | ||
39 | Q_PROPERTY(Qt::MouseButtons supportedButtons READ supportedButtons CONSTANT) | 42 | Q_PROPERTY(Qt::MouseButtons supportedButtons READ supportedButtons CONSTANT) | ||
40 | 43 | | |||
41 | Q_PROPERTY(bool supportsLeftHanded READ supportsLeftHanded CONSTANT) | 44 | Q_PROPERTY(bool supportsLeftHanded READ supportsLeftHanded CONSTANT) | ||
42 | Q_PROPERTY(bool leftHandedEnabledByDefault READ leftHandedEnabledByDefault CONSTANT) | 45 | Q_PROPERTY(bool leftHandedEnabledByDefault READ leftHandedEnabledByDefault CONSTANT) | ||
43 | Q_PROPERTY(bool leftHanded READ isLeftHanded WRITE setLeftHanded NOTIFY leftHandedChanged) | 46 | Q_PROPERTY(bool leftHanded READ isLeftHanded WRITE setLeftHanded NOTIFY leftHandedChanged) | ||
Show All 38 Lines | |||||
82 | Q_PROPERTY(bool tapDragLock READ isTapDragLock WRITE setTapDragLock NOTIFY tapDragLockChanged) | 85 | Q_PROPERTY(bool tapDragLock READ isTapDragLock WRITE setTapDragLock NOTIFY tapDragLockChanged) | ||
83 | 86 | | |||
84 | // | 87 | // | ||
85 | // scrolling | 88 | // scrolling | ||
86 | Q_PROPERTY(bool supportsNaturalScroll READ supportsNaturalScroll CONSTANT) | 89 | Q_PROPERTY(bool supportsNaturalScroll READ supportsNaturalScroll CONSTANT) | ||
87 | Q_PROPERTY(bool naturalScrollEnabledByDefault READ naturalScrollEnabledByDefault CONSTANT) | 90 | Q_PROPERTY(bool naturalScrollEnabledByDefault READ naturalScrollEnabledByDefault CONSTANT) | ||
88 | Q_PROPERTY(bool naturalScroll READ isNaturalScroll WRITE setNaturalScroll NOTIFY naturalScrollChanged) | 91 | Q_PROPERTY(bool naturalScroll READ isNaturalScroll WRITE setNaturalScroll NOTIFY naturalScrollChanged) | ||
89 | 92 | | |||
93 | Q_PROPERTY(bool supportsHorizontalScrolling READ supportsHorizontalScrolling CONSTANT) | ||||
94 | Q_PROPERTY(bool horizontalScrollingByDefault READ horizontalScrollingByDefault CONSTANT) | ||||
95 | Q_PROPERTY(bool horizontalScrolling READ horizontalScrolling WRITE setHorizontalScrolling NOTIFY horizontalScrollingChanged) | ||||
96 | | ||||
90 | Q_PROPERTY(bool supportsScrollTwoFinger READ supportsScrollTwoFinger CONSTANT) | 97 | Q_PROPERTY(bool supportsScrollTwoFinger READ supportsScrollTwoFinger CONSTANT) | ||
91 | Q_PROPERTY(bool scrollTwoFingerEnabledByDefault READ scrollTwoFingerEnabledByDefault CONSTANT) | 98 | Q_PROPERTY(bool scrollTwoFingerEnabledByDefault READ scrollTwoFingerEnabledByDefault CONSTANT) | ||
92 | Q_PROPERTY(bool scrollTwoFinger READ isScrollTwoFinger WRITE setScrollTwoFinger NOTIFY scrollMethodChanged) | 99 | Q_PROPERTY(bool scrollTwoFinger READ isScrollTwoFinger WRITE setScrollTwoFinger NOTIFY scrollMethodChanged) | ||
93 | 100 | | |||
94 | Q_PROPERTY(bool supportsScrollEdge READ supportsScrollEdge CONSTANT) | 101 | Q_PROPERTY(bool supportsScrollEdge READ supportsScrollEdge CONSTANT) | ||
95 | Q_PROPERTY(bool scrollEdgeEnabledByDefault READ scrollEdgeEnabledByDefault CONSTANT) | 102 | Q_PROPERTY(bool scrollEdgeEnabledByDefault READ scrollEdgeEnabledByDefault CONSTANT) | ||
96 | Q_PROPERTY(bool scrollEdge READ isScrollEdge WRITE setScrollEdge NOTIFY scrollMethodChanged) | 103 | Q_PROPERTY(bool scrollEdge READ isScrollEdge WRITE setScrollEdge NOTIFY scrollMethodChanged) | ||
97 | 104 | | |||
Show All 9 Lines | |||||
107 | Q_PROPERTY(bool defaultClickMethodAreas READ defaultClickMethodAreas CONSTANT) | 114 | Q_PROPERTY(bool defaultClickMethodAreas READ defaultClickMethodAreas CONSTANT) | ||
108 | Q_PROPERTY(bool clickMethodAreas READ isClickMethodAreas WRITE setClickMethodAreas NOTIFY clickMethodChanged) | 115 | Q_PROPERTY(bool clickMethodAreas READ isClickMethodAreas WRITE setClickMethodAreas NOTIFY clickMethodChanged) | ||
109 | 116 | | |||
110 | Q_PROPERTY(bool supportsClickMethodClickfinger READ supportsClickMethodClickfinger CONSTANT) | 117 | Q_PROPERTY(bool supportsClickMethodClickfinger READ supportsClickMethodClickfinger CONSTANT) | ||
111 | Q_PROPERTY(bool defaultClickMethodClickfinger READ defaultClickMethodClickfinger CONSTANT) | 118 | Q_PROPERTY(bool defaultClickMethodClickfinger READ defaultClickMethodClickfinger CONSTANT) | ||
112 | Q_PROPERTY(bool clickMethodClickfinger READ isClickMethodClickfinger WRITE setClickMethodClickfinger NOTIFY clickMethodChanged) | 119 | Q_PROPERTY(bool clickMethodClickfinger READ isClickMethodClickfinger WRITE setClickMethodClickfinger NOTIFY clickMethodChanged) | ||
113 | 120 | | |||
114 | public: | 121 | public: | ||
115 | KWinWaylandTouchpad(QString dbusName); | | |||
116 | ~KWinWaylandTouchpad() override; | | |||
117 | 122 | | |||
118 | bool init(); | 123 | LibinputCommon() {} | ||
124 | virtual ~LibinputCommon() {} | ||||
119 | 125 | | |||
120 | bool getConfig(); | 126 | virtual QString name() const = 0; | ||
121 | bool getDefaultConfig(); | 127 | virtual bool supportsDisableEvents() const = 0; | ||
122 | bool applyConfig(); | 128 | virtual bool isEnabled() const = 0; | ||
123 | bool isChangedConfig() const; | 129 | virtual void setEnabled(bool set) = 0; | ||
124 | 130 | | |||
125 | // | 131 | // | ||
126 | // general | 132 | // advanced | ||
127 | QString name() const { | | |||
128 | return m_name.val; | | |||
129 | } | | |||
130 | QString sysName() const { | | |||
131 | return m_sysName.val; | | |||
132 | } | | |||
133 | bool supportsDisableEvents() const { | | |||
134 | return m_supportsDisableEvents.val; | | |||
135 | } | | |||
136 | void setEnabled(bool enabled) { | | |||
137 | m_enabled.set(enabled); | | |||
138 | } | | |||
139 | bool isEnabled() const { | | |||
140 | return m_enabled.val; | | |||
141 | } | | |||
142 | Qt::MouseButtons supportedButtons() const { | 133 | Qt::MouseButtons supportedButtons() const { | ||
143 | return m_supportedButtons.val; | 134 | return m_supportedButtons.val; | ||
144 | } | 135 | } | ||
145 | 136 | | |||
146 | // | 137 | virtual bool supportsLeftHanded() const = 0; | ||
147 | // advanced | | |||
148 | bool supportsLeftHanded() const { | | |||
149 | return m_supportsLeftHanded.val; | | |||
150 | } | | |||
151 | bool leftHandedEnabledByDefault() const { | 138 | bool leftHandedEnabledByDefault() const { | ||
152 | return m_leftHandedEnabledByDefault.val; | 139 | return m_leftHandedEnabledByDefault.val; | ||
153 | } | 140 | } | ||
154 | bool isLeftHanded() const { | 141 | bool isLeftHanded() const { | ||
155 | return m_leftHanded.val; | 142 | return m_leftHanded.val; | ||
156 | } | 143 | } | ||
157 | void setLeftHanded(bool set) { | 144 | void setLeftHanded(bool set) { | ||
158 | m_leftHanded.set(set); | 145 | m_leftHanded.set(set); | ||
159 | } | 146 | } | ||
160 | 147 | | |||
161 | bool supportsDisableEventsOnExternalMouse() const { | 148 | virtual bool supportsDisableEventsOnExternalMouse() const = 0; | ||
162 | return m_supportsDisableEventsOnExternalMouse.val; | | |||
163 | } | | |||
164 | 149 | | |||
165 | bool supportsDisableWhileTyping() const { | 150 | virtual bool supportsDisableWhileTyping() const = 0; | ||
166 | return m_supportsDisableWhileTyping.val; | | |||
167 | } | | |||
168 | bool disableWhileTypingEnabledByDefault() const { | 151 | bool disableWhileTypingEnabledByDefault() const { | ||
169 | return m_disableWhileTypingEnabledByDefault.val; | 152 | return m_disableWhileTypingEnabledByDefault.val; | ||
170 | } | 153 | } | ||
171 | bool isDisableWhileTyping() const { | 154 | bool isDisableWhileTyping() const { | ||
172 | return m_disableWhileTyping.val; | 155 | return m_disableWhileTyping.val; | ||
173 | } | 156 | } | ||
174 | void setDisableWhileTyping(bool set) { | 157 | void setDisableWhileTyping(bool set) { | ||
175 | m_disableWhileTyping.set(set); | 158 | m_disableWhileTyping.set(set); | ||
176 | } | 159 | } | ||
177 | 160 | | |||
178 | bool supportsMiddleEmulation() const { | 161 | virtual bool supportsMiddleEmulation() const = 0; | ||
179 | return m_supportsMiddleEmulation.val; | | |||
180 | } | | |||
181 | bool middleEmulationEnabledByDefault() const { | 162 | bool middleEmulationEnabledByDefault() const { | ||
182 | return m_middleEmulationEnabledByDefault.val; | 163 | return m_middleEmulationEnabledByDefault.val; | ||
183 | } | 164 | } | ||
184 | bool isMiddleEmulation() const { | 165 | bool isMiddleEmulation() const { | ||
185 | return m_middleEmulation.val; | 166 | return m_middleEmulation.val; | ||
186 | } | 167 | } | ||
187 | void setMiddleEmulation(bool set) { | 168 | void setMiddleEmulation(bool set) { | ||
188 | m_middleEmulation.set(set); | 169 | m_middleEmulation.set(set); | ||
189 | } | 170 | } | ||
190 | 171 | | |||
191 | // | 172 | virtual bool supportsPointerAcceleration() const = 0; | ||
192 | // acceleration speed and profile | | |||
193 | bool supportsPointerAcceleration() const { | | |||
194 | return m_supportsPointerAcceleration.val; | | |||
195 | } | | |||
196 | qreal pointerAcceleration() const { | 173 | qreal pointerAcceleration() const { | ||
197 | return m_pointerAcceleration.val; | 174 | return m_pointerAcceleration.val; | ||
198 | } | 175 | } | ||
199 | void setPointerAcceleration(qreal acceleration) { | 176 | void setPointerAcceleration(qreal acceleration) { | ||
200 | m_pointerAcceleration.set(acceleration); | 177 | m_pointerAcceleration.set(acceleration); | ||
201 | } | 178 | } | ||
202 | 179 | | |||
203 | bool supportsPointerAccelerationProfileFlat() const { | 180 | virtual bool supportsPointerAccelerationProfileFlat() const = 0; | ||
204 | return m_supportsPointerAccelerationProfileFlat.val; | | |||
205 | } | | |||
206 | bool defaultPointerAccelerationProfileFlat() const { | 181 | bool defaultPointerAccelerationProfileFlat() const { | ||
207 | return m_defaultPointerAccelerationProfileFlat.val; | 182 | return m_defaultPointerAccelerationProfileFlat.val; | ||
208 | } | 183 | } | ||
209 | bool pointerAccelerationProfileFlat() const { | 184 | bool pointerAccelerationProfileFlat() const { | ||
210 | return m_pointerAccelerationProfileFlat.val; | 185 | return m_pointerAccelerationProfileFlat.val; | ||
211 | } | 186 | } | ||
212 | void setPointerAccelerationProfileFlat(bool set) { | 187 | void setPointerAccelerationProfileFlat(bool set) { | ||
213 | m_pointerAccelerationProfileFlat.set(set); | 188 | m_pointerAccelerationProfileFlat.set(set); | ||
214 | } | 189 | } | ||
215 | 190 | | |||
216 | bool supportsPointerAccelerationProfileAdaptive() const { | 191 | virtual bool supportsPointerAccelerationProfileAdaptive() const = 0; | ||
217 | return m_supportsPointerAccelerationProfileAdaptive.val; | | |||
218 | } | | |||
219 | bool defaultPointerAccelerationProfileAdaptive() const { | 192 | bool defaultPointerAccelerationProfileAdaptive() const { | ||
220 | return m_defaultPointerAccelerationProfileAdaptive.val; | 193 | return m_defaultPointerAccelerationProfileAdaptive.val; | ||
221 | } | 194 | } | ||
222 | bool pointerAccelerationProfileAdaptive() const { | 195 | bool pointerAccelerationProfileAdaptive() const { | ||
223 | return m_pointerAccelerationProfileAdaptive.val; | 196 | return m_pointerAccelerationProfileAdaptive.val; | ||
224 | } | 197 | } | ||
225 | void setPointerAccelerationProfileAdaptive(bool set) { | 198 | void setPointerAccelerationProfileAdaptive(bool set) { | ||
226 | m_pointerAccelerationProfileAdaptive.set(set); | 199 | m_pointerAccelerationProfileAdaptive.set(set); | ||
227 | } | 200 | } | ||
228 | 201 | | |||
229 | // | 202 | // | ||
230 | // tapping | | |||
231 | int tapFingerCount() const { | | |||
232 | return m_tapFingerCount.val; | | |||
233 | } | | |||
234 | bool tapToClickEnabledByDefault() const { | | |||
235 | return m_tapToClickEnabledByDefault.val; | | |||
236 | } | | |||
237 | bool isTapToClick() const { | | |||
238 | return m_tapToClick.val; | | |||
239 | } | | |||
240 | void setTapToClick(bool set) { | | |||
241 | m_tapToClick.set(set); | | |||
242 | } | | |||
243 | | ||||
244 | bool supportsLmrTapButtonMap() const { | | |||
245 | return m_tapFingerCount.val > 1; | | |||
246 | } | | |||
247 | bool lmrTapButtonMapEnabledByDefault() const { | | |||
248 | return m_lmrTapButtonMapEnabledByDefault.val; | | |||
249 | } | | |||
250 | bool lmrTapButtonMap() const { | | |||
251 | return m_lmrTapButtonMap.val; | | |||
252 | } | | |||
253 | void setLmrTapButtonMap(bool set) { | | |||
254 | m_lmrTapButtonMap.set(set); | | |||
255 | } | | |||
256 | | ||||
257 | bool tapAndDragEnabledByDefault() const { | | |||
258 | return m_tapAndDragEnabledByDefault.val; | | |||
259 | } | | |||
260 | bool isTapAndDrag() const { | | |||
261 | return m_tapAndDrag.val; | | |||
262 | } | | |||
263 | void setTapAndDrag(bool set) { | | |||
264 | m_tapAndDrag.set(set); | | |||
265 | } | | |||
266 | | ||||
267 | bool tapDragLockEnabledByDefault() const { | | |||
268 | return m_tapDragLockEnabledByDefault.val; | | |||
269 | } | | |||
270 | bool isTapDragLock() const { | | |||
271 | return m_tapDragLock.val; | | |||
272 | } | | |||
273 | void setTapDragLock(bool set) { | | |||
274 | m_tapDragLock.set(set); | | |||
275 | } | | |||
276 | | ||||
277 | // | | |||
278 | // scrolling | 203 | // scrolling | ||
279 | bool supportsNaturalScroll() const { | 204 | virtual bool supportsNaturalScroll() const = 0; | ||
280 | return m_supportsNaturalScroll.val; | | |||
281 | } | | |||
282 | bool naturalScrollEnabledByDefault() const { | 205 | bool naturalScrollEnabledByDefault() const { | ||
283 | return m_naturalScrollEnabledByDefault.val; | 206 | return m_naturalScrollEnabledByDefault.val; | ||
284 | } | 207 | } | ||
285 | bool isNaturalScroll() const { | 208 | bool isNaturalScroll() const { | ||
286 | return m_naturalScroll.val; | 209 | return m_naturalScroll.val; | ||
287 | } | 210 | } | ||
288 | void setNaturalScroll(bool set) { | 211 | void setNaturalScroll(bool set) { | ||
289 | m_naturalScroll.set(set); | 212 | m_naturalScroll.set(set); | ||
290 | } | 213 | } | ||
291 | 214 | | |||
292 | bool supportsScrollTwoFinger() const { | 215 | virtual bool supportsHorizontalScrolling() const = 0; | ||
293 | return m_supportsScrollTwoFinger.val; | 216 | bool horizontalScrollingByDefault() const { | ||
217 | return true; | ||||
218 | } | ||||
219 | bool horizontalScrolling() const { | ||||
220 | return m_horizontalScrolling.val; | ||||
294 | } | 221 | } | ||
222 | void setHorizontalScrolling(bool set) { | ||||
223 | m_horizontalScrolling.set(set); | ||||
224 | } | ||||
225 | | ||||
226 | virtual bool supportsScrollTwoFinger() const = 0; | ||||
295 | bool scrollTwoFingerEnabledByDefault() const { | 227 | bool scrollTwoFingerEnabledByDefault() const { | ||
296 | return m_scrollTwoFingerEnabledByDefault.val; | 228 | return m_scrollTwoFingerEnabledByDefault.val; | ||
297 | } | 229 | } | ||
298 | bool isScrollTwoFinger() const { | 230 | bool isScrollTwoFinger() const { | ||
299 | return m_isScrollTwoFinger.val; | 231 | return m_isScrollTwoFinger.val; | ||
300 | } | 232 | } | ||
301 | void setScrollTwoFinger(bool set) { | 233 | void setScrollTwoFinger(bool set) { | ||
302 | m_isScrollTwoFinger.set(set); | 234 | m_isScrollTwoFinger.set(set); | ||
303 | } | 235 | } | ||
304 | 236 | | |||
305 | bool supportsScrollEdge() const { | 237 | virtual bool supportsScrollEdge() const = 0; | ||
306 | return m_supportsScrollEdge.val; | | |||
307 | } | | |||
308 | bool scrollEdgeEnabledByDefault() const { | 238 | bool scrollEdgeEnabledByDefault() const { | ||
309 | return m_scrollEdgeEnabledByDefault.val; | 239 | return m_scrollEdgeEnabledByDefault.val; | ||
310 | } | 240 | } | ||
311 | bool isScrollEdge() const { | 241 | bool isScrollEdge() const { | ||
312 | return m_isScrollEdge.val; | 242 | return m_isScrollEdge.val; | ||
313 | } | 243 | } | ||
314 | void setScrollEdge(bool set) { | 244 | void setScrollEdge(bool set) { | ||
315 | m_isScrollEdge.set(set); | 245 | m_isScrollEdge.set(set); | ||
316 | } | 246 | } | ||
317 | 247 | | |||
318 | bool supportsScrollOnButtonDown() const { | 248 | virtual bool supportsScrollOnButtonDown() const = 0; | ||
319 | return m_supportsScrollOnButtonDown.val; | | |||
320 | } | | |||
321 | bool scrollOnButtonDownEnabledByDefault() const { | 249 | bool scrollOnButtonDownEnabledByDefault() const { | ||
322 | return m_scrollOnButtonDownEnabledByDefault.val; | 250 | return m_scrollOnButtonDownEnabledByDefault.val; | ||
323 | } | 251 | } | ||
324 | bool isScrollOnButtonDown() const { | 252 | bool isScrollOnButtonDown() const { | ||
325 | return m_isScrollOnButtonDown.val; | 253 | return m_isScrollOnButtonDown.val; | ||
326 | } | 254 | } | ||
327 | void setScrollOnButtonDown(bool set) { | 255 | void setScrollOnButtonDown(bool set) { | ||
328 | m_isScrollOnButtonDown.set(set); | 256 | m_isScrollOnButtonDown.set(set); | ||
329 | } | 257 | } | ||
330 | 258 | | |||
331 | quint32 defaultScrollButton() const { | 259 | quint32 defaultScrollButton() const { | ||
332 | return m_defaultScrollButton.val; | 260 | return m_defaultScrollButton.val; | ||
333 | } | 261 | } | ||
334 | quint32 scrollButton() const { | 262 | quint32 scrollButton() const { | ||
335 | return m_scrollButton.val; | 263 | return m_scrollButton.val; | ||
336 | } | 264 | } | ||
337 | void setScrollButton(quint32 button) { | 265 | void setScrollButton(quint32 button) { | ||
338 | m_scrollButton.set(button); | 266 | m_scrollButton.set(button); | ||
339 | } | 267 | } | ||
340 | 268 | | |||
341 | bool supportsClickMethodAreas() const { | 269 | // | ||
342 | return m_supportsClickMethodAreas.val; | 270 | // tapping | ||
271 | int tapFingerCount() const { | ||||
272 | return m_tapFingerCount.val; | ||||
273 | } | ||||
274 | bool tapToClickEnabledByDefault() const { | ||||
275 | return m_tapToClickEnabledByDefault.val; | ||||
276 | } | ||||
277 | bool isTapToClick() const { | ||||
278 | return m_tapToClick.val; | ||||
343 | } | 279 | } | ||
280 | void setTapToClick(bool set) { | ||||
281 | m_tapToClick.set(set); | ||||
282 | } | ||||
283 | | ||||
284 | bool supportsLmrTapButtonMap() const { | ||||
285 | return m_tapFingerCount.val > 1; | ||||
286 | } | ||||
287 | bool lmrTapButtonMapEnabledByDefault() const { | ||||
288 | return m_lmrTapButtonMapEnabledByDefault.val; | ||||
289 | } | ||||
290 | bool lmrTapButtonMap() const { | ||||
291 | return m_lmrTapButtonMap.val; | ||||
292 | } | ||||
293 | void setLmrTapButtonMap(bool set) { | ||||
294 | m_lmrTapButtonMap.set(set); | ||||
295 | } | ||||
296 | | ||||
297 | bool tapAndDragEnabledByDefault() const { | ||||
298 | return m_tapAndDragEnabledByDefault.val; | ||||
299 | } | ||||
300 | bool isTapAndDrag() const { | ||||
301 | return m_tapAndDrag.val; | ||||
302 | } | ||||
303 | void setTapAndDrag(bool set) { | ||||
304 | m_tapAndDrag.set(set); | ||||
305 | } | ||||
306 | | ||||
307 | bool tapDragLockEnabledByDefault() const { | ||||
308 | return m_tapDragLockEnabledByDefault.val; | ||||
309 | } | ||||
310 | bool isTapDragLock() const { | ||||
311 | return m_tapDragLock.val; | ||||
312 | } | ||||
313 | void setTapDragLock(bool set) { | ||||
314 | m_tapDragLock.set(set); | ||||
315 | } | ||||
316 | | ||||
317 | // | ||||
318 | // click method | ||||
319 | virtual bool supportsClickMethodAreas() const = 0; | ||||
344 | bool defaultClickMethodAreas() const { | 320 | bool defaultClickMethodAreas() const { | ||
345 | return m_defaultClickMethodAreas.val; | 321 | return m_defaultClickMethodAreas.val; | ||
346 | } | 322 | } | ||
347 | bool isClickMethodAreas() const { | 323 | bool isClickMethodAreas() const { | ||
348 | return m_clickMethodAreas.val; | 324 | return m_clickMethodAreas.val; | ||
349 | } | 325 | } | ||
350 | void setClickMethodAreas(bool set) { | 326 | void setClickMethodAreas(bool set) { | ||
351 | m_clickMethodAreas.set(set); | 327 | m_clickMethodAreas.set(set); | ||
352 | } | 328 | } | ||
353 | 329 | | |||
354 | bool supportsClickMethodClickfinger() const { | 330 | virtual bool supportsClickMethodClickfinger() const = 0; | ||
355 | return m_supportsClickMethodClickfinger.val; | | |||
356 | } | | |||
357 | bool defaultClickMethodClickfinger() const { | 331 | bool defaultClickMethodClickfinger() const { | ||
358 | return m_defaultClickMethodClickfinger.val; | 332 | return m_defaultClickMethodClickfinger.val; | ||
359 | } | 333 | } | ||
360 | bool isClickMethodClickfinger() const { | 334 | bool isClickMethodClickfinger() const { | ||
361 | return m_clickMethodClickfinger.val; | 335 | return m_clickMethodClickfinger.val; | ||
362 | } | 336 | } | ||
363 | void setClickMethodClickfinger(bool set) { | 337 | void setClickMethodClickfinger(bool set) { | ||
364 | m_clickMethodClickfinger.set(set); | 338 | m_clickMethodClickfinger.set(set); | ||
365 | } | 339 | } | ||
366 | 340 | | |||
367 | Q_SIGNALS: | 341 | Q_SIGNALS: | ||
368 | void leftHandedChanged(); | | |||
369 | void pointerAccelerationChanged(); | | |||
370 | void pointerAccelerationProfileChanged(); | | |||
371 | void enabledChanged(); | 342 | void enabledChanged(); | ||
343 | // Tapping | ||||
372 | void tapToClickChanged(); | 344 | void tapToClickChanged(); | ||
345 | void lmrTapButtonMapChanged(); | ||||
373 | void tapAndDragChanged(); | 346 | void tapAndDragChanged(); | ||
374 | void tapDragLockChanged(); | 347 | void tapDragLockChanged(); | ||
375 | void lmrTapButtonMapChanged(); | 348 | // Advanced | ||
349 | void leftHandedChanged(); | ||||
376 | void disableWhileTypingChanged(); | 350 | void disableWhileTypingChanged(); | ||
377 | void middleEmulationChanged(); | 351 | void middleEmulationChanged(); | ||
352 | // acceleration speed and profile | ||||
353 | void pointerAccelerationChanged(); | ||||
354 | void pointerAccelerationProfileChanged(); | ||||
355 | // scrolling | ||||
378 | void naturalScrollChanged(); | 356 | void naturalScrollChanged(); | ||
357 | void horizontalScrollingChanged(); | ||||
379 | void scrollMethodChanged(); | 358 | void scrollMethodChanged(); | ||
380 | void scrollButtonChanged(); | 359 | void scrollButtonChanged(); | ||
360 | // click methods | ||||
381 | void clickMethodChanged(); | 361 | void clickMethodChanged(); | ||
382 | 362 | | |||
383 | private: | 363 | protected: | ||
384 | template <typename T> | 364 | template <typename T> | ||
385 | struct Prop { | 365 | struct Prop { | ||
386 | explicit Prop(const QByteArray &dbusName) | 366 | explicit Prop(const QByteArray &name) | ||
387 | : dbus(dbusName) | 367 | : name(name) | ||
388 | {} | 368 | {} | ||
389 | 369 | | |||
390 | void set(T newVal) { | 370 | void set(T newVal) { | ||
391 | if (avail && val != newVal) { | 371 | if (avail && val != newVal) { | ||
392 | val = newVal; | 372 | val = newVal; | ||
393 | } | 373 | } | ||
394 | } | 374 | } | ||
395 | void set(const Prop<T> &p) { | 375 | void set(const Prop<T> &p) { | ||
396 | if (avail && val != p.val) { | 376 | if (avail && val != p.val) { | ||
397 | val = p.val; | 377 | val = p.val; | ||
398 | } | 378 | } | ||
399 | } | 379 | } | ||
400 | bool changed() const { | 380 | bool changed() const { | ||
401 | return avail && (old != val); | 381 | return avail && (old != val); | ||
402 | } | 382 | } | ||
403 | 383 | | |||
404 | QByteArray dbus; | 384 | // In wayland, name will be dbus name | ||
385 | QByteArray name; | ||||
405 | bool avail; | 386 | bool avail; | ||
406 | T old; | 387 | T old; | ||
407 | T val; | 388 | T val; | ||
408 | }; | 389 | }; | ||
409 | 390 | | |||
410 | template<typename T> | | |||
411 | bool valueLoader(Prop<T> &prop); | | |||
412 | 391 | | |||
413 | template<typename T> | | |||
414 | QString valueWriter(const Prop<T> &prop); | | |||
415 | 392 | | |||
416 | // | 393 | // | ||
417 | // general | 394 | // general | ||
418 | Prop<QString> m_name = Prop<QString>("name"); | | |||
419 | Prop<QString> m_sysName = Prop<QString>("sysName"); | | |||
420 | Prop<bool> m_supportsDisableEvents = Prop<bool>("supportsDisableEvents"); | 395 | Prop<bool> m_supportsDisableEvents = Prop<bool>("supportsDisableEvents"); | ||
421 | Prop<bool> m_enabled = Prop<bool>("enabled"); | 396 | Prop<bool> m_enabled = Prop<bool>("enabled"); | ||
422 | 397 | | |||
423 | // | 398 | // | ||
424 | // advanced | 399 | // advanced | ||
425 | Prop<Qt::MouseButtons> m_supportedButtons = Prop<Qt::MouseButtons>("supportedButtons"); | 400 | Prop<Qt::MouseButtons> m_supportedButtons = Prop<Qt::MouseButtons>("supportedButtons"); | ||
426 | 401 | | |||
427 | Prop<bool> m_supportsLeftHanded = Prop<bool>("supportsLeftHanded"); | | |||
428 | Prop<bool> m_leftHandedEnabledByDefault = Prop<bool>("leftHandedEnabledByDefault"); | 402 | Prop<bool> m_leftHandedEnabledByDefault = Prop<bool>("leftHandedEnabledByDefault"); | ||
429 | Prop<bool> m_leftHanded = Prop<bool>("leftHanded"); | 403 | Prop<bool> m_leftHanded = Prop<bool>("leftHanded"); | ||
430 | 404 | | |||
431 | Prop<bool> m_supportsDisableEventsOnExternalMouse = Prop<bool>("supportsDisableEventsOnExternalMouse"); | 405 | Prop<bool> m_supportsDisableEventsOnExternalMouse = Prop<bool>("supportsDisableEventsOnExternalMouse"); | ||
432 | 406 | | |||
433 | Prop<bool> m_supportsDisableWhileTyping = Prop<bool>("supportsDisableWhileTyping"); | | |||
434 | Prop<bool> m_disableWhileTypingEnabledByDefault = Prop<bool>("disableWhileTypingEnabledByDefault"); | 407 | Prop<bool> m_disableWhileTypingEnabledByDefault = Prop<bool>("disableWhileTypingEnabledByDefault"); | ||
435 | Prop<bool> m_disableWhileTyping = Prop<bool>("disableWhileTyping"); | 408 | Prop<bool> m_disableWhileTyping = Prop<bool>("disableWhileTyping"); | ||
436 | 409 | | |||
437 | Prop<bool> m_supportsMiddleEmulation = Prop<bool>("supportsMiddleEmulation"); | | |||
438 | Prop<bool> m_middleEmulationEnabledByDefault = Prop<bool>("middleEmulationEnabledByDefault"); | 410 | Prop<bool> m_middleEmulationEnabledByDefault = Prop<bool>("middleEmulationEnabledByDefault"); | ||
439 | Prop<bool> m_middleEmulation = Prop<bool>("middleEmulation"); | 411 | Prop<bool> m_middleEmulation = Prop<bool>("middleEmulation"); | ||
440 | 412 | | |||
441 | // | 413 | // | ||
442 | // acceleration speed and profile | 414 | // acceleration speed and profile | ||
443 | Prop<bool> m_supportsPointerAcceleration = Prop<bool>("supportsPointerAcceleration"); | | |||
444 | Prop<qreal> m_defaultPointerAcceleration = Prop<qreal>("defaultPointerAcceleration"); | 415 | Prop<qreal> m_defaultPointerAcceleration = Prop<qreal>("defaultPointerAcceleration"); | ||
445 | Prop<qreal> m_pointerAcceleration = Prop<qreal>("pointerAcceleration"); | 416 | Prop<qreal> m_pointerAcceleration = Prop<qreal>("pointerAcceleration"); | ||
446 | 417 | | |||
447 | Prop<bool> m_supportsPointerAccelerationProfileFlat = Prop<bool>("supportsPointerAccelerationProfileFlat"); | 418 | Prop<bool> m_supportsPointerAccelerationProfileFlat = Prop<bool>("supportsPointerAccelerationProfileFlat"); | ||
448 | Prop<bool> m_defaultPointerAccelerationProfileFlat = Prop<bool>("defaultPointerAccelerationProfileFlat"); | 419 | Prop<bool> m_defaultPointerAccelerationProfileFlat = Prop<bool>("defaultPointerAccelerationProfileFlat"); | ||
449 | Prop<bool> m_pointerAccelerationProfileFlat = Prop<bool>("pointerAccelerationProfileFlat"); | 420 | Prop<bool> m_pointerAccelerationProfileFlat = Prop<bool>("pointerAccelerationProfileFlat"); | ||
450 | 421 | | |||
451 | Prop<bool> m_supportsPointerAccelerationProfileAdaptive = Prop<bool>("supportsPointerAccelerationProfileAdaptive"); | 422 | Prop<bool> m_supportsPointerAccelerationProfileAdaptive = Prop<bool>("supportsPointerAccelerationProfileAdaptive"); | ||
Show All 11 Lines | |||||
463 | 434 | | |||
464 | Prop<bool> m_tapAndDragEnabledByDefault = Prop<bool>("tapAndDragEnabledByDefault"); | 435 | Prop<bool> m_tapAndDragEnabledByDefault = Prop<bool>("tapAndDragEnabledByDefault"); | ||
465 | Prop<bool> m_tapAndDrag = Prop<bool>("tapAndDrag"); | 436 | Prop<bool> m_tapAndDrag = Prop<bool>("tapAndDrag"); | ||
466 | Prop<bool> m_tapDragLockEnabledByDefault = Prop<bool>("tapDragLockEnabledByDefault"); | 437 | Prop<bool> m_tapDragLockEnabledByDefault = Prop<bool>("tapDragLockEnabledByDefault"); | ||
467 | Prop<bool> m_tapDragLock = Prop<bool>("tapDragLock"); | 438 | Prop<bool> m_tapDragLock = Prop<bool>("tapDragLock"); | ||
468 | 439 | | |||
469 | // | 440 | // | ||
470 | // scrolling | 441 | // scrolling | ||
471 | Prop<bool> m_supportsNaturalScroll = Prop<bool>("supportsNaturalScroll"); | | |||
472 | Prop<bool> m_naturalScrollEnabledByDefault = Prop<bool>("naturalScrollEnabledByDefault"); | 442 | Prop<bool> m_naturalScrollEnabledByDefault = Prop<bool>("naturalScrollEnabledByDefault"); | ||
473 | Prop<bool> m_naturalScroll = Prop<bool>("naturalScroll"); | 443 | Prop<bool> m_naturalScroll = Prop<bool>("naturalScroll"); | ||
474 | 444 | | |||
445 | Prop<bool> m_horizontalScrolling = Prop<bool>("horizontalScrolling"); | ||||
446 | | ||||
475 | Prop<bool> m_supportsScrollTwoFinger = Prop<bool>("supportsScrollTwoFinger"); | 447 | Prop<bool> m_supportsScrollTwoFinger = Prop<bool>("supportsScrollTwoFinger"); | ||
476 | Prop<bool> m_scrollTwoFingerEnabledByDefault = Prop<bool>("scrollTwoFingerEnabledByDefault"); | 448 | Prop<bool> m_scrollTwoFingerEnabledByDefault = Prop<bool>("scrollTwoFingerEnabledByDefault"); | ||
477 | Prop<bool> m_isScrollTwoFinger = Prop<bool>("scrollTwoFinger"); | 449 | Prop<bool> m_isScrollTwoFinger = Prop<bool>("scrollTwoFinger"); | ||
478 | 450 | | |||
479 | Prop<bool> m_supportsScrollEdge = Prop<bool>("supportsScrollEdge"); | 451 | Prop<bool> m_supportsScrollEdge = Prop<bool>("supportsScrollEdge"); | ||
480 | Prop<bool> m_scrollEdgeEnabledByDefault = Prop<bool>("scrollEdgeEnabledByDefault"); | 452 | Prop<bool> m_scrollEdgeEnabledByDefault = Prop<bool>("scrollEdgeEnabledByDefault"); | ||
481 | Prop<bool> m_isScrollEdge = Prop<bool>("scrollEdge"); | 453 | Prop<bool> m_isScrollEdge = Prop<bool>("scrollEdge"); | ||
482 | 454 | | |||
483 | Prop<bool> m_supportsScrollOnButtonDown = Prop<bool>("supportsScrollOnButtonDown"); | 455 | Prop<bool> m_supportsScrollOnButtonDown = Prop<bool>("supportsScrollOnButtonDown"); | ||
484 | Prop<bool> m_scrollOnButtonDownEnabledByDefault = Prop<bool>("scrollOnButtonDownEnabledByDefault"); | 456 | Prop<bool> m_scrollOnButtonDownEnabledByDefault = Prop<bool>("scrollOnButtonDownEnabledByDefault"); | ||
485 | Prop<bool> m_isScrollOnButtonDown = Prop<bool>("scrollOnButtonDown"); | 457 | Prop<bool> m_isScrollOnButtonDown = Prop<bool>("scrollOnButtonDown"); | ||
486 | 458 | | |||
487 | Prop<quint32> m_defaultScrollButton = Prop<quint32>("defaultScrollButton"); | 459 | Prop<quint32> m_defaultScrollButton = Prop<quint32>("defaultScrollButton"); | ||
488 | Prop<quint32> m_scrollButton = Prop<quint32>("scrollButton"); | 460 | Prop<quint32> m_scrollButton = Prop<quint32>("scrollButton"); | ||
489 | 461 | | |||
462 | // Click Method | ||||
490 | Prop<bool> m_supportsClickMethodAreas = Prop<bool>("supportsClickMethodAreas"); | 463 | Prop<bool> m_supportsClickMethodAreas = Prop<bool>("supportsClickMethodAreas"); | ||
491 | Prop<bool> m_defaultClickMethodAreas = Prop<bool>("defaultClickMethodAreas"); | 464 | Prop<bool> m_defaultClickMethodAreas = Prop<bool>("defaultClickMethodAreas"); | ||
492 | Prop<bool> m_clickMethodAreas = Prop<bool>("clickMethodAreas"); | 465 | Prop<bool> m_clickMethodAreas = Prop<bool>("clickMethodAreas"); | ||
493 | 466 | | |||
494 | Prop<bool> m_supportsClickMethodClickfinger = Prop<bool>("supportsClickMethodClickfinger"); | 467 | Prop<bool> m_supportsClickMethodClickfinger = Prop<bool>("supportsClickMethodClickfinger"); | ||
495 | Prop<bool> m_defaultClickMethodClickfinger = Prop<bool>("defaultClickMethodClickfinger"); | 468 | Prop<bool> m_defaultClickMethodClickfinger = Prop<bool>("defaultClickMethodClickfinger"); | ||
496 | Prop<bool> m_clickMethodClickfinger = Prop<bool>("clickMethodClickfinger"); | 469 | Prop<bool> m_clickMethodClickfinger = Prop<bool>("clickMethodClickfinger"); | ||
497 | | ||||
498 | | ||||
499 | QDBusInterface *m_iface; | | |||
500 | }; | 470 | }; | ||
501 | 471 | | |||
502 | #endif | 472 | #endif // LIBINPUTCOMMON_H |
Most of the code in this file was written by me and is now copy-pasted. Please keep in my copyright and add your own above/below.