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