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