Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpad/src/backends/x11/libinputtouchpad.cpp
Show All 10 Lines | |||||
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 | #include <QDebug> | ||||
20 | #include <X11/extensions/XInput2.h> | ||||
21 | | ||||
19 | #include "libinputtouchpad.h" | 22 | #include "libinputtouchpad.h" | ||
20 | 23 | | |||
21 | #include <stddef.h> | 24 | #include <stddef.h> | ||
22 | #include <limits.h> | 25 | #include <limits.h> | ||
23 | 26 | | |||
27 | #include <xserver-properties.h> | ||||
28 | #include <libinput-properties.h> | ||||
29 | #include "logging.h" | ||||
30 | | ||||
31 | namespace { | ||||
32 | template<typename T> | ||||
33 | T valueLoaderPart(QVariant const &reply) { Q_UNUSED(reply); return T(); } | ||||
34 | | ||||
35 | template<> | ||||
36 | bool valueLoaderPart(QVariant const &reply) { return reply.toBool(); } | ||||
37 | | ||||
38 | template<> | ||||
39 | int valueLoaderPart(QVariant const &reply) { return reply.toInt(); } | ||||
40 | | ||||
41 | template<> | ||||
42 | quint32 valueLoaderPart(QVariant const &reply) { return reply.toInt(); } | ||||
43 | | ||||
44 | template<> | ||||
45 | qreal valueLoaderPart(QVariant const &reply) { return reply.toReal(); } | ||||
46 | | ||||
47 | template<> | ||||
48 | QString valueLoaderPart(QVariant const &reply) { return reply.toString(); } | ||||
49 | | ||||
50 | template<> | ||||
51 | Qt::MouseButtons valueLoaderPart(QVariant const &reply) { return static_cast<Qt::MouseButtons>(reply.toInt()); } | ||||
52 | } | ||||
53 | | ||||
24 | const struct Parameter libinputProperties[] = { | 54 | const struct Parameter libinputProperties[] = { | ||
55 | | ||||
56 | /* libinput disable supports property */ | ||||
57 | {"SupportsDisableEvents", PT_INT, 0, 1, LIBINPUT_PROP_SENDEVENTS_AVAILABLE, 8, 0}, | ||||
58 | {"Enabled", PT_INT, 0, 1, LIBINPUT_PROP_SENDEVENTS_ENABLED, 8, 0}, | ||||
59 | {"EnabledDefault", PT_INT, 0, 1, LIBINPUT_PROP_SENDEVENTS_ENABLED_DEFAULT, 8, 0}, | ||||
60 | | ||||
61 | /* LeftHandSupport */ | ||||
62 | {"LeftHandedEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_LEFT_HANDED_DEFAULT, 8, 0}, | ||||
63 | {"LeftHanded", PT_INT, 0, 1, LIBINPUT_PROP_LEFT_HANDED, 8, 0}, | ||||
64 | | ||||
65 | /* Disable on external mouse */ | ||||
66 | {"SupportsDisableEventsOnExternalMouse",PT_INT, 0, 1, LIBINPUT_PROP_SENDEVENTS_AVAILABLE, 8, 1}, | ||||
67 | {"DisableEventsOnExternalMouse", PT_INT, 0, 1, LIBINPUT_PROP_SENDEVENTS_ENABLED, 8, 1}, | ||||
68 | {"DisableEventsOnExternalMouseDefault", PT_INT, 0, 1, LIBINPUT_PROP_SENDEVENTS_ENABLED_DEFAULT, 8, 1}, | ||||
69 | | ||||
70 | /* Disable while typing */ | ||||
71 | {"DisableWhileTypingEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_DISABLE_WHILE_TYPING_DEFAULT, 8, 0}, | ||||
72 | {"DisableWhileTyping", PT_INT, 0, 1, LIBINPUT_PROP_DISABLE_WHILE_TYPING, 8, 0}, | ||||
73 | | ||||
74 | /* Middle Emulation */ | ||||
75 | {"MiddleEmulationEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED_DEFAULT, 8, 0}, | ||||
76 | {"MiddleEmulation", PT_INT, 0, 1, LIBINPUT_PROP_MIDDLE_EMULATION_ENABLED, 8, 0}, | ||||
77 | | ||||
25 | /* This is a boolean for all three fingers, no per-finger config */ | 78 | /* This is a boolean for all three fingers, no per-finger config */ | ||
26 | {"Tapping", PT_INT, 0, 1, "libinput Tapping Enabled", 8, 0}, | 79 | {"Tapping", PT_INT, 0, 1, LIBINPUT_PROP_TAP, 8, 0}, | ||
80 | {"TapToClickEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_TAP_DEFAULT, 8, 0}, | ||||
81 | | ||||
82 | /* LMR */ | ||||
83 | {"LmrTapButtonMapEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_TAP_BUTTONMAP_DEFAULT, 8, 1}, | ||||
84 | {"LmrTapButtonMap", PT_INT, 0, 1, LIBINPUT_PROP_TAP_BUTTONMAP, 8, 1}, | ||||
85 | | ||||
86 | /* Tap and Drag Enabled */ | ||||
87 | {"TapAndDragEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_TAP_DRAG_DEFAULT, 8, 0}, | ||||
88 | {"TapAndDrag", PT_INT, 0, 1, LIBINPUT_PROP_TAP_DRAG, 8, 0}, | ||||
89 | | ||||
90 | /* Tap and Drag Lock Enabled */ | ||||
91 | {"TapDragLockEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT, 8, 0}, | ||||
92 | {"TapDragLock", PT_INT, 0, 1, LIBINPUT_PROP_TAP_DRAG_LOCK, 8, 0}, | ||||
93 | | ||||
27 | /* libinput normalizes the accel to -1/1 */ | 94 | /* libinput normalizes the accel to -1/1 */ | ||
28 | {"AccelFactor", PT_DOUBLE, -1.0, 1.0, "libinput Accel Speed", 0 /*float */, 0}, | 95 | {"DefaultPointerAcceleration", PT_DOUBLE, -1.0, 1.0, LIBINPUT_PROP_ACCEL_DEFAULT, 0 /*float */, 0}, | ||
29 | /* Only one of these may be set at one time */ | 96 | {"PointerAcceleration", PT_DOUBLE, -1.0, 1.0, LIBINPUT_PROP_ACCEL, 0 /*float */, 0}, | ||
30 | {"VertEdgeScroll", PT_INT, 0, 1, "libinput Scroll Method Enabled", 8, 1}, | 97 | | ||
31 | {"VertTwoFingerScroll", PT_INT, 0, 1, "libinput Scroll Method Enabled", 8, 0}, | 98 | /* Libinput Accel Profile */ | ||
32 | {"InvertVertScroll", PT_INT, 0, 1, "libinput Natural Scrolling Enabled", 8, 0}, | 99 | {"SupportsPointerAccelerationProfileAdaptive", PT_BOOL, 0, 1, LIBINPUT_PROP_ACCEL_PROFILES_AVAILABLE, 8, 0}, | ||
100 | {"DefaultPointerAccelerationProfileAdaptive", PT_BOOL, 0, 1, LIBINPUT_PROP_ACCEL_PROFILE_ENABLED_DEFAULT, 8, 0}, | ||||
101 | {"PointerAccelerationProfileAdaptive", PT_BOOL, 0, 1, LIBINPUT_PROP_ACCEL_PROFILE_ENABLED, 8, 0}, | ||||
102 | {"SupportsPointerAccelerationProfileFlat", PT_BOOL, 0, 1, LIBINPUT_PROP_ACCEL_PROFILES_AVAILABLE, 8, 1}, | ||||
103 | {"DefaultPointerAccelerationProfileFlat", PT_BOOL, 0, 1, LIBINPUT_PROP_ACCEL_PROFILE_ENABLED_DEFAULT, 8, 1}, | ||||
104 | {"PointerAccelerationProfileFlat", PT_BOOL, 0, 1, LIBINPUT_PROP_ACCEL_PROFILE_ENABLED, 8, 1}, | ||||
105 | | ||||
106 | /* Natural Scrolling */ | ||||
107 | {"NaturalScrollEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_NATURAL_SCROLL_DEFAULT, 8, 0}, | ||||
108 | {"NaturalScroll", PT_INT, 0, 1, LIBINPUT_PROP_NATURAL_SCROLL, 8, 0}, | ||||
109 | | ||||
110 | /* Two-Finger Scrolling */ | ||||
111 | {"SupportsScrollTwoFinger", PT_INT, 0, 1, LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE, 8, 0}, | ||||
112 | {"ScrollTwoFingerEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_SCROLL_METHOD_ENABLED_DEFAULT, 8, 0}, | ||||
113 | {"ScrollTwoFinger", PT_INT, 0, 1, LIBINPUT_PROP_SCROLL_METHOD_ENABLED, 8, 0}, | ||||
114 | | ||||
115 | /* Edge Scrolling */ | ||||
116 | {"SupportsScrollEdge", PT_INT, 0, 1, LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE, 8, 1}, | ||||
117 | {"ScrollEdgeEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_SCROLL_METHOD_ENABLED_DEFAULT, 8, 1}, | ||||
118 | {"ScrollEdge", PT_INT, 0, 1, LIBINPUT_PROP_SCROLL_METHOD_ENABLED, 8, 1}, | ||||
119 | | ||||
120 | /* scroll on button */ | ||||
121 | {"SupportsScrollOnButtonDown", PT_INT, 0, 1, LIBINPUT_PROP_SCROLL_METHODS_AVAILABLE, 8, 2}, | ||||
122 | {"ScrollOnButtonDownEnabledByDefault", PT_INT, 0, 1, LIBINPUT_PROP_SCROLL_METHOD_ENABLED_DEFAULT, 8, 2}, | ||||
123 | {"ScrollOnButtonDown", PT_INT, 0, 1, LIBINPUT_PROP_SCROLL_METHOD_ENABLED, 8, 2}, | ||||
124 | | ||||
125 | /* Scroll Button for scroll on button Down */ | ||||
126 | {"DefaultScrollButton", PT_INT, 0, INT_MAX, LIBINPUT_PROP_SCROLL_BUTTON_DEFAULT, 32, 0}, | ||||
127 | {"ScrollButton", PT_INT, 0, INT_MAX, LIBINPUT_PROP_SCROLL_BUTTON, 32, 0}, | ||||
128 | | ||||
129 | /* Click Methods */ | ||||
130 | {"SupportsClickMethodAreas", PT_INT, 0, 1, LIBINPUT_PROP_CLICK_METHODS_AVAILABLE, 8, 0}, | ||||
131 | {"DefaultClickMethodAreas", PT_INT, 0, 1, LIBINPUT_PROP_CLICK_METHOD_ENABLED_DEFAULT, 8, 0}, | ||||
132 | {"ClickMethodAreas", PT_INT, 0, 1, LIBINPUT_PROP_CLICK_METHOD_ENABLED, 8, 0}, | ||||
133 | | ||||
134 | {"SupportsClickMethodClickfinger", PT_INT, 0, 1, LIBINPUT_PROP_CLICK_METHODS_AVAILABLE, 8, 1}, | ||||
135 | {"DefaultClickMethodClickfinger", PT_INT, 0, 1, LIBINPUT_PROP_CLICK_METHOD_ENABLED_DEFAULT, 8, 1}, | ||||
136 | {"ClickMethodClickfinger", PT_INT, 0, 1, LIBINPUT_PROP_CLICK_METHOD_ENABLED, 8, 1}, | ||||
137 | | ||||
33 | /* libinput doesn't have a separate toggle for horiz scrolling */ | 138 | /* libinput doesn't have a separate toggle for horiz scrolling */ | ||
34 | { NULL, PT_INT, 0, 0, 0, 0, 0 } | 139 | { NULL, PT_INT, 0, 0, 0, 0, 0 } | ||
35 | }; | 140 | }; | ||
36 | 141 | | |||
37 | LibinputTouchpad::LibinputTouchpad(Display *display, int deviceId): XlibTouchpad(display, deviceId) | 142 | Qt::MouseButtons maskBtns(Display *display, XIButtonClassInfo *buttonInfo) | ||
143 | { | ||||
144 | Qt::MouseButtons buttons = Qt::NoButton; | ||||
145 | for (int i = 0; i < buttonInfo->num_buttons; ++i) { | ||||
146 | QByteArray reply = XGetAtomName(display, buttonInfo->labels[i]); | ||||
147 | | ||||
148 | if (reply == BTN_LABEL_PROP_BTN_LEFT) { | ||||
149 | buttons |= Qt::LeftButton; | ||||
150 | } | ||||
151 | if (reply == BTN_LABEL_PROP_BTN_RIGHT) { | ||||
152 | buttons |= Qt::RightButton; | ||||
153 | } | ||||
154 | if (reply == BTN_LABEL_PROP_BTN_MIDDLE) { | ||||
155 | buttons |= Qt::MiddleButton; | ||||
156 | } | ||||
157 | if (reply == BTN_LABEL_PROP_BTN_SIDE) { | ||||
158 | buttons |= Qt::ExtraButton1; | ||||
159 | } | ||||
160 | if (reply == BTN_LABEL_PROP_BTN_EXTRA) { | ||||
161 | buttons |= Qt::ExtraButton2; | ||||
162 | } | ||||
163 | if (reply == BTN_LABEL_PROP_BTN_FORWARD) { | ||||
164 | buttons |= Qt::ForwardButton; | ||||
165 | } | ||||
166 | if (reply == BTN_LABEL_PROP_BTN_BACK) { | ||||
167 | buttons |= Qt::BackButton; | ||||
168 | } | ||||
169 | if (reply == BTN_LABEL_PROP_BTN_TASK) { | ||||
170 | buttons |= Qt::TaskButton; | ||||
171 | } | ||||
172 | } | ||||
173 | return buttons; | ||||
174 | } | ||||
175 | | ||||
176 | LibinputTouchpad::LibinputTouchpad(Display *display, int deviceId): | ||||
177 | XlibTouchpad(nullptr, display, deviceId) | ||||
38 | { | 178 | { | ||
39 | loadSupportedProperties(libinputProperties); | 179 | loadSupportedProperties(libinputProperties); | ||
40 | 180 | | |||
41 | /* FIXME: has a different format than Synaptics Off but we don't expose | 181 | int nDevices = 0; | ||
42 | the toggle so this is just to stop it from crashing when we check | 182 | XIDeviceInfo *deviceInfo = XIQueryDevice(m_display, m_deviceId, &nDevices); | ||
43 | m_touchpadOffAtom */ | 183 | m_name = deviceInfo->name; | ||
44 | m_touchpadOffAtom.intern(m_connection, | 184 | | ||
45 | "libinput Send Events Mode enabled"); | 185 | for (int i = 0; i < deviceInfo->num_classes; ++i) { | ||
46 | 186 | XIAnyClassInfo *classInfo = deviceInfo->classes[i]; | |||
47 | 187 | | |||
48 | XcbAtom scroll_methods(m_connection, | 188 | if (classInfo->type == XIButtonClass) { | ||
49 | "libinput Scroll Methods Available", | 189 | XIButtonClassInfo *btnInfo = (XIButtonClassInfo*) classInfo; | ||
50 | true); | 190 | m_supportedButtons.avail = true; | ||
51 | if (scroll_methods.atom() != 0) { | 191 | m_supportedButtons.set(maskBtns(m_display, btnInfo)); | ||
52 | PropertyInfo methods(m_display, | 192 | } | ||
53 | m_deviceId, | 193 | if (classInfo->type == XITouchClass) { | ||
54 | scroll_methods.atom(), | 194 | XITouchClassInfo *touchInfo = (XITouchClassInfo*) classInfo; | ||
55 | 0); | 195 | m_tapFingerCount.avail = true; | ||
56 | if (!methods.value(0).toInt()) | 196 | m_tapFingerCount.set(touchInfo->num_touches); | ||
57 | m_supported.removeAll("VertTwoFingerScroll"); | 197 | } | ||
58 | else if (!methods.value(1).toInt()) | 198 | } | ||
59 | m_supported.removeAll("VertEdgeScroll"); | 199 | XIFreeDeviceInfo(deviceInfo); | ||
200 | | ||||
201 | /* FingerCount cannot be zero */ | ||||
202 | if (!m_tapFingerCount.val) { | ||||
203 | m_tapFingerCount.avail = true; | ||||
204 | m_tapFingerCount.set(1); | ||||
205 | } | ||||
206 | } | ||||
207 | | ||||
208 | bool LibinputTouchpad::getConfig() | ||||
209 | { | ||||
210 | bool success = true; | ||||
211 | | ||||
212 | success &= valueLoader(m_supportsDisableEvents); | ||||
213 | success &= valueLoader(m_enabled); | ||||
214 | success &= valueLoader(m_enabledDefault); | ||||
215 | | ||||
216 | success &= valueLoader(m_tapToClickEnabledByDefault); | ||||
217 | success &= valueLoader(m_tapToClick); | ||||
218 | success &= valueLoader(m_lmrTapButtonMapEnabledByDefault); | ||||
219 | success &= valueLoader(m_lmrTapButtonMap); | ||||
220 | success &= valueLoader(m_tapAndDragEnabledByDefault); | ||||
221 | success &= valueLoader(m_tapAndDrag); | ||||
222 | success &= valueLoader(m_tapDragLockEnabledByDefault); | ||||
223 | success &= valueLoader(m_tapDragLock); | ||||
224 | | ||||
225 | success &= valueLoader(m_leftHandedEnabledByDefault); | ||||
226 | success &= valueLoader(m_leftHanded); | ||||
227 | | ||||
228 | success &= valueLoader(m_supportsDisableEventsOnExternalMouse); | ||||
229 | success &= valueLoader(m_disableEventsOnExternalMouse); | ||||
230 | success &= valueLoader(m_disableEventsOnExternalMouseDefault); | ||||
231 | | ||||
232 | success &= valueLoader(m_disableWhileTypingEnabledByDefault); | ||||
233 | success &= valueLoader(m_disableWhileTyping); | ||||
234 | | ||||
235 | success &= valueLoader(m_middleEmulationEnabledByDefault); | ||||
236 | success &= valueLoader(m_middleEmulation); | ||||
237 | | ||||
238 | success &= valueLoader(m_defaultPointerAcceleration); | ||||
239 | success &= valueLoader(m_pointerAcceleration); | ||||
240 | | ||||
241 | success &= valueLoader(m_supportsPointerAccelerationProfileFlat); | ||||
242 | success &= valueLoader(m_defaultPointerAccelerationProfileFlat); | ||||
243 | success &= valueLoader(m_pointerAccelerationProfileFlat); | ||||
244 | success &= valueLoader(m_supportsPointerAccelerationProfileAdaptive); | ||||
245 | success &= valueLoader(m_defaultPointerAccelerationProfileAdaptive); | ||||
246 | success &= valueLoader(m_pointerAccelerationProfileAdaptive); | ||||
247 | | ||||
248 | success &= valueLoader(m_naturalScrollEnabledByDefault); | ||||
249 | success &= valueLoader(m_naturalScroll); | ||||
250 | | ||||
251 | success &= valueLoader(m_supportsScrollTwoFinger); | ||||
252 | success &= valueLoader(m_scrollTwoFingerEnabledByDefault); | ||||
253 | success &= valueLoader(m_isScrollTwoFinger); | ||||
254 | | ||||
255 | success &= valueLoader(m_supportsScrollEdge); | ||||
256 | success &= valueLoader(m_scrollEdgeEnabledByDefault); | ||||
257 | success &= valueLoader(m_isScrollEdge); | ||||
258 | | ||||
259 | success &= valueLoader(m_supportsScrollOnButtonDown); | ||||
260 | success &= valueLoader(m_scrollOnButtonDownEnabledByDefault); | ||||
261 | success &= valueLoader(m_isScrollOnButtonDown); | ||||
262 | | ||||
263 | success &= valueLoader(m_defaultScrollButton); | ||||
264 | success &= valueLoader(m_scrollButton); | ||||
265 | | ||||
266 | // click methods | ||||
267 | success &= valueLoader(m_supportsClickMethodAreas); | ||||
268 | success &= valueLoader(m_supportsClickMethodClickfinger); | ||||
269 | success &= valueLoader(m_defaultClickMethodAreas); | ||||
270 | success &= valueLoader(m_defaultClickMethodClickfinger); | ||||
271 | success &= valueLoader(m_clickMethodAreas); | ||||
272 | success &= valueLoader(m_clickMethodClickfinger); | ||||
273 | | ||||
274 | return success; | ||||
275 | } | ||||
276 | | ||||
277 | bool LibinputTouchpad::applyConfig() | ||||
278 | { | ||||
279 | QVector<QString> msgs; | ||||
280 | | ||||
281 | msgs << valueWriter(m_enabled) | ||||
282 | << valueWriter(m_tapToClick) | ||||
283 | << valueWriter(m_lmrTapButtonMap) | ||||
284 | << valueWriter(m_tapAndDrag) | ||||
285 | << valueWriter(m_tapDragLock) | ||||
286 | << valueWriter(m_leftHanded) | ||||
287 | << valueWriter(m_disableWhileTyping) | ||||
288 | << valueWriter(m_middleEmulation) | ||||
289 | << valueWriter(m_pointerAcceleration) | ||||
290 | << valueWriter(m_pointerAccelerationProfileFlat) | ||||
291 | << valueWriter(m_pointerAccelerationProfileAdaptive) | ||||
292 | << valueWriter(m_naturalScroll) | ||||
293 | << valueWriter(m_isScrollTwoFinger) | ||||
294 | << valueWriter(m_isScrollEdge) | ||||
295 | << valueWriter(m_isScrollOnButtonDown) | ||||
296 | << valueWriter(m_scrollButton) | ||||
297 | << valueWriter(m_clickMethodAreas) | ||||
298 | << valueWriter(m_clickMethodClickfinger); | ||||
299 | | ||||
300 | bool success = true; | ||||
301 | QString error_msg; | ||||
302 | | ||||
303 | for (QString m : msgs) { | ||||
304 | if (!m.isNull()) { | ||||
305 | qCCritical(KCM_TOUCHPAD) << "in error:" << m; | ||||
306 | if (!success) { | ||||
307 | error_msg.append("\n"); | ||||
308 | } | ||||
309 | error_msg.append(m); | ||||
310 | success = false; | ||||
311 | } | ||||
312 | } | ||||
313 | | ||||
314 | if (!success) { | ||||
315 | qCCritical(KCM_TOUCHPAD) << error_msg; | ||||
316 | } | ||||
317 | | ||||
318 | flush(); | ||||
319 | return success; | ||||
320 | } | ||||
321 | | ||||
322 | bool LibinputTouchpad::getDefaultConfig() | ||||
323 | { | ||||
324 | m_enabled.set(m_enabledDefault); | ||||
325 | m_tapToClick.set(m_tapToClickEnabledByDefault); | ||||
326 | m_lmrTapButtonMap.set(m_lmrTapButtonMapEnabledByDefault); | ||||
327 | m_tapAndDrag.set(m_tapAndDragEnabledByDefault); | ||||
328 | m_tapDragLock.set(m_tapDragLockEnabledByDefault); | ||||
329 | m_leftHanded.set(m_leftHandedEnabledByDefault); | ||||
330 | m_disableEventsOnExternalMouse.set(m_disableEventsOnExternalMouseDefault); | ||||
331 | m_disableWhileTyping.set(m_disableWhileTypingEnabledByDefault); | ||||
332 | m_middleEmulation.set(m_middleEmulationEnabledByDefault); | ||||
333 | m_pointerAcceleration.set(m_defaultPointerAcceleration); | ||||
334 | m_pointerAccelerationProfileFlat.set(m_defaultPointerAccelerationProfileFlat); | ||||
335 | m_pointerAccelerationProfileAdaptive.set(m_defaultPointerAccelerationProfileAdaptive); | ||||
336 | m_naturalScroll.set(m_naturalScrollEnabledByDefault); | ||||
337 | m_isScrollTwoFinger.set(m_scrollTwoFingerEnabledByDefault); | ||||
338 | m_isScrollEdge.set(m_scrollEdgeEnabledByDefault); | ||||
339 | m_isScrollOnButtonDown.set(m_scrollOnButtonDownEnabledByDefault); | ||||
340 | m_scrollButton.set(m_defaultScrollButton); | ||||
341 | m_clickMethodAreas.set(m_defaultClickMethodAreas); | ||||
342 | m_clickMethodClickfinger.set(m_defaultClickMethodClickfinger); | ||||
343 | | ||||
344 | return true; | ||||
345 | } | ||||
346 | | ||||
347 | bool LibinputTouchpad::isChangedConfig() | ||||
348 | { | ||||
349 | | ||||
350 | bool changed = m_enabled.changed() || | ||||
351 | m_tapToClick.changed() || | ||||
352 | m_lmrTapButtonMap.changed() || | ||||
353 | m_tapAndDrag.changed() || | ||||
354 | m_tapDragLock.changed() || | ||||
355 | m_leftHanded.changed() || | ||||
356 | m_disableEventsOnExternalMouse.changed() || | ||||
357 | m_disableWhileTyping.changed() || | ||||
358 | m_middleEmulation.changed() || | ||||
359 | m_pointerAcceleration.changed() || | ||||
360 | m_pointerAccelerationProfileFlat.changed() || | ||||
361 | m_pointerAccelerationProfileAdaptive.changed() || | ||||
362 | m_naturalScroll.changed() || | ||||
363 | m_isScrollTwoFinger.changed() || | ||||
364 | m_isScrollEdge.changed() || | ||||
365 | m_isScrollOnButtonDown.changed() || | ||||
366 | m_scrollButton.changed() || | ||||
367 | m_clickMethodAreas.changed() || | ||||
368 | m_clickMethodClickfinger.changed(); | ||||
369 | | ||||
370 | return changed; | ||||
371 | } | ||||
372 | | ||||
373 | template<typename T> | ||||
374 | bool LibinputTouchpad::valueLoader(Prop<T> &prop) | ||||
375 | { | ||||
376 | const Parameter *p = findParameter(QString::fromAscii(prop.name)); | ||||
377 | | ||||
378 | if (!p) { | ||||
379 | qCCritical(KCM_TOUCHPAD) << "Error on read of " << QString::fromAscii(prop.name); | ||||
380 | } | ||||
381 | | ||||
382 | QVariant reply = getParameter(p); | ||||
383 | if (!reply.isValid()) { | ||||
384 | qCDebug(KCM_TOUCHPAD) << "Property not available : " << QString::fromAscii(prop.name); | ||||
385 | prop.avail = false; | ||||
386 | return true; | ||||
387 | } | ||||
388 | prop.avail = true; | ||||
389 | | ||||
390 | T replyValue = valueLoaderPart<T>(reply); | ||||
391 | | ||||
392 | prop.old = replyValue; | ||||
393 | prop.val = replyValue; | ||||
394 | return true; | ||||
395 | } | ||||
396 | | ||||
397 | template<typename T> | ||||
398 | QString LibinputTouchpad::valueWriter(const Prop<T> &prop) | ||||
399 | { | ||||
400 | const Parameter *p = findParameter(QString::fromAscii(prop.name)); | ||||
401 | | ||||
402 | if (!p || !prop.changed()) { | ||||
403 | return QString(); | ||||
404 | } | ||||
405 | | ||||
406 | bool error = !setParameter( p, prop.val); | ||||
407 | if (error) { | ||||
408 | qCCritical(KCM_TOUCHPAD) << "Cannot set property " + QString::fromAscii(prop.name); | ||||
409 | return QStringLiteral("Cannot set property ") + QString::fromAscii(prop.name); | ||||
60 | } | 410 | } | ||
411 | return QString(); | ||||
61 | } | 412 | } |