Changeset View
Changeset View
Standalone View
Standalone View
kcms/input/backends/x11/x11_backend.cpp
- This file was moved from kcms/input/backends/x11/x11mousebackend.cpp.
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2017 Xuetian Weng <wengxt@gmail.com> | 2 | * Copyright 2017 Xuetian Weng <wengxt@gmail.com> | ||
3 | * Copyright 2018 Roman Gilg <subdiff@gmail.com> | ||||
3 | * | 4 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | 5 | * 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 | * 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 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | 8 | * (at your option) any later version. | ||
8 | * | 9 | * | ||
9 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. | ||
13 | * | 14 | * | ||
14 | * You should have received a copy of the GNU General Public License | 15 | * 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 | * 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 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | 18 | */ | ||
18 | 19 | | |||
19 | #include "x11mousebackend.h" | 20 | #include "x11_backend.h" | ||
20 | #include "mousesettings.h" | 21 | | ||
21 | #include <config-X11.h> | 22 | #include <config-X11.h> | ||
22 | 23 | | |||
23 | #include <QFile> | 24 | #include <QFile> | ||
24 | #include <QX11Info> | 25 | #include <QX11Info> | ||
25 | #include <KLocalizedString> | 26 | #include <KLocalizedString> | ||
26 | #include <evdev-properties.h> | 27 | #include <evdev-properties.h> | ||
27 | #include <libinput-properties.h> | 28 | #include <libinput-properties.h> | ||
28 | 29 | | |||
29 | #include <X11/X.h> | 30 | #include <X11/X.h> | ||
30 | #include <X11/Xlib.h> | 31 | #include <X11/Xlib.h> | ||
31 | #include <X11/Xatom.h> | 32 | #include <X11/Xatom.h> | ||
32 | #include <X11/extensions/XInput2.h> | 33 | #include <X11/extensions/XInput2.h> | ||
33 | #include <X11/extensions/XI.h> | 34 | #include <X11/extensions/XI.h> | ||
34 | #include <X11/Xutil.h> | 35 | #include <X11/Xutil.h> | ||
35 | #ifdef HAVE_XCURSOR | 36 | #ifdef HAVE_XCURSOR | ||
36 | # include <X11/Xcursor/Xcursor.h> | 37 | #include <X11/Xcursor/Xcursor.h> | ||
37 | #include <X11/extensions/XInput.h> | 38 | #include <X11/extensions/XInput.h> | ||
38 | #endif | 39 | #endif | ||
39 | 40 | | |||
40 | static const char PROFILE_NONE[] = I18N_NOOP("None"); | 41 | static const char PROFILE_NONE[] = I18N_NOOP("None"); | ||
41 | static const char PROFILE_ADAPTIVE[] = I18N_NOOP("Adaptive"); | 42 | static const char PROFILE_ADAPTIVE[] = I18N_NOOP("Adaptive"); | ||
42 | static const char PROFILE_FLAT[] = I18N_NOOP("Flat"); | 43 | static const char PROFILE_FLAT[] = I18N_NOOP("Flat"); | ||
43 | 44 | | |||
44 | struct ScopedXDeleter { | 45 | struct ScopedXDeleter { | ||
Show All 32 Lines | 72 | { | |||
77 | for (int i = 0; i < ndevices_return; ++i) { | 78 | for (int i = 0; i < ndevices_return; ++i) { | ||
78 | if (info[i].use == IsXPointer || info[i].use == IsXExtensionPointer) { | 79 | if (info[i].use == IsXPointer || info[i].use == IsXExtensionPointer) { | ||
79 | callback(info + i); | 80 | callback(info + i); | ||
80 | } | 81 | } | ||
81 | } | 82 | } | ||
82 | XFreeDeviceList(info); | 83 | XFreeDeviceList(info); | ||
83 | } | 84 | } | ||
84 | 85 | | |||
85 | X11MouseBackend::X11MouseBackend(QObject* parent) : MouseBackend(parent), m_dpy(nullptr) | 86 | X11Backend::X11Backend(QObject* parent) | ||
87 | : InputBackend(parent) | ||||
86 | { | 88 | { | ||
89 | m_mode = InputBackendMode::XEvdev; | ||||
90 | | ||||
87 | m_platformX11 = QX11Info::isPlatformX11(); | 91 | m_platformX11 = QX11Info::isPlatformX11(); | ||
88 | if (m_platformX11) { | 92 | if (m_platformX11) { | ||
89 | m_dpy = QX11Info::display(); | 93 | m_dpy = QX11Info::display(); | ||
90 | } else { | 94 | } else { | ||
95 | // TODO: remove this - not needed anymore with Wayland backend! | ||||
91 | // let's hope we have a compatibility system like Xwayland ready | 96 | // let's hope we have a compatibility system like Xwayland ready | ||
92 | m_dpy = XOpenDisplay(nullptr); | 97 | m_dpy = XOpenDisplay(nullptr); | ||
93 | } | 98 | } | ||
99 | m_settings = new EvdevSettings(); | ||||
94 | initAtom(); | 100 | initAtom(); | ||
95 | } | 101 | } | ||
96 | 102 | | |||
97 | void X11MouseBackend::initAtom() | 103 | void X11Backend::initAtom() | ||
98 | { | 104 | { | ||
99 | if (!m_dpy) { | 105 | if (!m_dpy) { | ||
100 | return; | 106 | return; | ||
101 | } | 107 | } | ||
102 | 108 | | |||
103 | m_libinputAccelProfileAvailableAtom = XInternAtom(m_dpy, LIBINPUT_PROP_ACCEL_PROFILES_AVAILABLE, True); | 109 | m_libinputAccelProfileAvailableAtom = XInternAtom(m_dpy, LIBINPUT_PROP_ACCEL_PROFILES_AVAILABLE, True); | ||
104 | m_libinputAccelProfileEnabledAtom = XInternAtom(m_dpy, LIBINPUT_PROP_ACCEL_PROFILE_ENABLED, True); | 110 | m_libinputAccelProfileEnabledAtom = XInternAtom(m_dpy, LIBINPUT_PROP_ACCEL_PROFILE_ENABLED, True); | ||
105 | m_libinputNaturalScrollAtom = XInternAtom(m_dpy, LIBINPUT_PROP_NATURAL_SCROLL, True); | 111 | m_libinputNaturalScrollAtom = XInternAtom(m_dpy, LIBINPUT_PROP_NATURAL_SCROLL, True); | ||
106 | 112 | | |||
107 | m_evdevScrollDistanceAtom = XInternAtom(m_dpy, EVDEV_PROP_SCROLL_DISTANCE, True); | 113 | m_evdevScrollDistanceAtom = XInternAtom(m_dpy, EVDEV_PROP_SCROLL_DISTANCE, True); | ||
108 | m_evdevWheelEmulationAtom = XInternAtom(m_dpy, EVDEV_PROP_WHEEL, True); | 114 | m_evdevWheelEmulationAtom = XInternAtom(m_dpy, EVDEV_PROP_WHEEL, True); | ||
109 | m_evdevWheelEmulationAxesAtom = XInternAtom(m_dpy, EVDEV_PROP_WHEEL_AXES, True); | 115 | m_evdevWheelEmulationAxesAtom = XInternAtom(m_dpy, EVDEV_PROP_WHEEL_AXES, True); | ||
110 | 116 | | |||
111 | m_touchpadAtom = XInternAtom(m_dpy, XI_TOUCHPAD, True); | 117 | m_touchpadAtom = XInternAtom(m_dpy, XI_TOUCHPAD, True); | ||
112 | } | 118 | } | ||
113 | 119 | | |||
114 | 120 | | |||
115 | X11MouseBackend::~X11MouseBackend() | 121 | X11Backend::~X11Backend() | ||
116 | { | 122 | { | ||
117 | if (!m_platformX11 && m_dpy) { | 123 | if (!m_platformX11 && m_dpy) { | ||
118 | XCloseDisplay(m_dpy); | 124 | XCloseDisplay(m_dpy); | ||
119 | } | 125 | } | ||
126 | delete m_settings; | ||||
120 | } | 127 | } | ||
121 | 128 | | |||
122 | bool X11MouseBackend::supportScrollPolarity() | 129 | bool X11Backend::supportScrollPolarity() | ||
123 | { | 130 | { | ||
124 | return m_numButtons >= 5; | 131 | return m_numButtons >= 5; | ||
125 | } | 132 | } | ||
126 | 133 | | |||
127 | QStringList X11MouseBackend::supportedAccelerationProfiles() | 134 | QStringList X11Backend::supportedAccelerationProfiles() | ||
128 | { | 135 | { | ||
129 | return m_supportedAccelerationProfiles; | 136 | return m_supportedAccelerationProfiles; | ||
130 | } | 137 | } | ||
131 | 138 | | |||
132 | QString X11MouseBackend::accelerationProfile() | 139 | QString X11Backend::accelerationProfile() | ||
133 | { | 140 | { | ||
134 | return m_accelerationProfile; | 141 | return m_accelerationProfile; | ||
135 | } | 142 | } | ||
136 | 143 | | |||
137 | double X11MouseBackend::accelRate() | 144 | double X11Backend::accelRate() | ||
138 | { | 145 | { | ||
139 | return m_accelRate; | 146 | return m_accelRate; | ||
140 | } | 147 | } | ||
141 | 148 | | |||
142 | MouseHanded X11MouseBackend::handed() | 149 | Handed X11Backend::handed() | ||
143 | { | 150 | { | ||
144 | return m_handed; | 151 | return m_handed; | ||
145 | } | 152 | } | ||
146 | 153 | | |||
147 | int X11MouseBackend::threshold() | 154 | int X11Backend::threshold() | ||
148 | { | 155 | { | ||
149 | return m_threshold; | 156 | return m_threshold; | ||
150 | } | 157 | } | ||
151 | 158 | | |||
152 | void X11MouseBackend::load() | 159 | void X11Backend::load() | ||
153 | { | 160 | { | ||
154 | if (!m_dpy) { | 161 | if (!m_dpy) { | ||
155 | return; | 162 | return; | ||
156 | } | 163 | } | ||
157 | 164 | | |||
158 | m_accelRate = 1.0; | 165 | m_accelRate = 1.0; | ||
159 | int accel_num, accel_den; | 166 | int accel_num, accel_den; | ||
160 | XGetPointerControl(m_dpy, &accel_num, &accel_den, &m_threshold); | 167 | XGetPointerControl(m_dpy, &accel_num, &accel_den, &m_threshold); | ||
161 | m_accelRate = double(accel_num) / double(accel_den); | 168 | m_accelRate = double(accel_num) / double(accel_den); | ||
162 | 169 | | |||
163 | // get settings from X server | 170 | // get settings from X server | ||
164 | unsigned char map[256]; | 171 | unsigned char map[256]; | ||
165 | m_numButtons = XGetPointerMapping(m_dpy, map, 256); | 172 | m_numButtons = XGetPointerMapping(m_dpy, map, 256); | ||
166 | m_middleButton = -1; | 173 | m_middleButton = -1; | ||
167 | 174 | | |||
168 | m_handed = MouseHanded::NotSupported; | 175 | m_handed = Handed::NotSupported; | ||
169 | // ## keep this in sync with KGlobalSettings::mouseSettings | 176 | // ## keep this in sync with KGlobalSettings::mouseSettings | ||
170 | if (m_numButtons == 2) { | 177 | if (m_numButtons == 2) { | ||
171 | if (map[0] == 1 && map[1] == 2) { | 178 | if (map[0] == 1 && map[1] == 2) { | ||
172 | m_handed = MouseHanded::Right; | 179 | m_handed = Handed::Right; | ||
173 | } else if (map[0] == 2 && map[1] == 1) { | 180 | } else if (map[0] == 2 && map[1] == 1) { | ||
174 | m_handed = MouseHanded::Left; | 181 | m_handed = Handed::Left; | ||
175 | } | 182 | } | ||
176 | } else if (m_numButtons >= 3) { | 183 | } else if (m_numButtons >= 3) { | ||
177 | m_middleButton = map[1]; | 184 | m_middleButton = map[1]; | ||
178 | if (map[0] == 1 && map[2] == 3) { | 185 | if (map[0] == 1 && map[2] == 3) { | ||
179 | m_handed = MouseHanded::Right; | 186 | m_handed = Handed::Right; | ||
180 | } else if (map[0] == 3 && map[2] == 1) { | 187 | } else if (map[0] == 3 && map[2] == 1) { | ||
181 | m_handed = MouseHanded::Left; | 188 | m_handed = Handed::Left; | ||
182 | } | 189 | } | ||
183 | } | 190 | } | ||
184 | 191 | | |||
185 | m_supportedAccelerationProfiles.clear(); | 192 | m_supportedAccelerationProfiles.clear(); | ||
186 | bool adaptiveAvailable = false; | 193 | bool adaptiveAvailable = false; | ||
187 | bool flatAvailable = false; | 194 | bool flatAvailable = false; | ||
188 | bool adaptiveEnabled = false; | 195 | bool adaptiveEnabled = false; | ||
189 | bool flatEnabled = false; | 196 | bool flatEnabled = false; | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
234 | } | 241 | } | ||
235 | 242 | | |||
236 | m_accelerationProfile = PROFILE_NONE; | 243 | m_accelerationProfile = PROFILE_NONE; | ||
237 | if (adaptiveEnabled) { | 244 | if (adaptiveEnabled) { | ||
238 | m_accelerationProfile = PROFILE_ADAPTIVE; | 245 | m_accelerationProfile = PROFILE_ADAPTIVE; | ||
239 | } else if (flatEnabled) { | 246 | } else if (flatEnabled) { | ||
240 | m_accelerationProfile = PROFILE_FLAT; | 247 | m_accelerationProfile = PROFILE_FLAT; | ||
241 | } | 248 | } | ||
249 | | ||||
250 | m_settings->load(this); | ||||
242 | } | 251 | } | ||
243 | 252 | | |||
244 | void X11MouseBackend::apply(const MouseSettings& settings, bool force) | 253 | void X11Backend::apply(bool force) | ||
245 | { | 254 | { | ||
246 | // 256 might seems extreme, but X has already been known to return 32, | 255 | // 256 might seems extreme, but X has already been known to return 32, | ||
247 | // and we don't want to truncate things. Xlib limits the table to 256 bytes, | 256 | // and we don't want to truncate things. Xlib limits the table to 256 bytes, | ||
248 | // so it's a good upper bound.. | 257 | // so it's a good upper bound.. | ||
249 | unsigned char map[256]; | 258 | unsigned char map[256]; | ||
250 | XGetPointerMapping(m_dpy, map, 256); | 259 | XGetPointerMapping(m_dpy, map, 256); | ||
251 | 260 | | |||
252 | if (settings.handedEnabled && (settings.handedNeedsApply || force)) { | 261 | if (m_settings->handedEnabled && (m_settings->handedNeedsApply || force)) { | ||
253 | if (m_numButtons == 1) { | 262 | if (m_numButtons == 1) { | ||
254 | map[0] = (unsigned char) 1; | 263 | map[0] = (unsigned char) 1; | ||
255 | } else if (m_numButtons == 2) { | 264 | } else if (m_numButtons == 2) { | ||
256 | if (settings.handed == MouseHanded::Right) { | 265 | if (m_settings->handed == Handed::Right) { | ||
257 | map[0] = (unsigned char) 1; | 266 | map[0] = (unsigned char) 1; | ||
258 | map[1] = (unsigned char) 3; | 267 | map[1] = (unsigned char) 3; | ||
259 | } else { | 268 | } else { | ||
260 | map[0] = (unsigned char) 3; | 269 | map[0] = (unsigned char) 3; | ||
261 | map[1] = (unsigned char) 1; | 270 | map[1] = (unsigned char) 1; | ||
262 | } | 271 | } | ||
263 | } else { // 3 buttons and more | 272 | } else { // 3 buttons and more | ||
264 | if (settings.handed == MouseHanded::Right) { | 273 | if (m_settings->handed == Handed::Right) { | ||
265 | map[0] = (unsigned char) 1; | 274 | map[0] = (unsigned char) 1; | ||
266 | map[1] = (unsigned char) m_middleButton; | 275 | map[1] = (unsigned char) m_middleButton; | ||
267 | map[2] = (unsigned char) 3; | 276 | map[2] = (unsigned char) 3; | ||
268 | } else { | 277 | } else { | ||
269 | map[0] = (unsigned char) 3; | 278 | map[0] = (unsigned char) 3; | ||
270 | map[1] = (unsigned char) m_middleButton; | 279 | map[1] = (unsigned char) m_middleButton; | ||
271 | map[2] = (unsigned char) 1; | 280 | map[2] = (unsigned char) 1; | ||
272 | } | 281 | } | ||
273 | } | 282 | } | ||
274 | 283 | | |||
275 | int retval; | 284 | int retval; | ||
276 | if (m_numButtons >= 1) { | 285 | if (m_numButtons >= 1) { | ||
277 | while ((retval = XSetPointerMapping(m_dpy, map, | 286 | while ((retval = XSetPointerMapping(m_dpy, map, | ||
278 | m_numButtons)) == MappingBusy) | 287 | m_numButtons)) == MappingBusy) | ||
279 | /* keep trying until the pointer is free */ | 288 | /* keep trying until the pointer is free */ | ||
280 | { }; | 289 | { }; | ||
281 | } | 290 | } | ||
282 | 291 | | |||
283 | // apply reverseScrollPolarity for all non-touchpad pointer, touchpad | 292 | // apply reverseScrollPolarity for all non-touchpad pointer, touchpad | ||
284 | // are belong to kcm touchpad. | 293 | // are belong to kcm touchpad. | ||
285 | XIForallPointerDevices(m_dpy, [this, &settings](XDeviceInfo * info) { | 294 | XIForallPointerDevices(m_dpy, [this](XDeviceInfo * info) { | ||
286 | int deviceid = info->id; | 295 | int deviceid = info->id; | ||
287 | if (info->type == m_touchpadAtom) { | 296 | if (info->type == m_touchpadAtom) { | ||
288 | return; | 297 | return; | ||
289 | } | 298 | } | ||
290 | if (libinputApplyReverseScroll(deviceid, settings.reverseScrollPolarity)) { | 299 | if (libinputApplyReverseScroll(deviceid, m_settings->reverseScrollPolarity)) { | ||
291 | return; | 300 | return; | ||
292 | } | 301 | } | ||
293 | evdevApplyReverseScroll(deviceid, settings.reverseScrollPolarity); | 302 | evdevApplyReverseScroll(deviceid, m_settings->reverseScrollPolarity); | ||
294 | }); | 303 | }); | ||
295 | 304 | | |||
296 | } | 305 | } | ||
297 | 306 | | |||
298 | XI2ForallPointerDevices(m_dpy, [&] (XIDeviceInfo *info) { | 307 | XI2ForallPointerDevices(m_dpy, [&] (XIDeviceInfo *info) { | ||
299 | libinputApplyAccelerationProfile(info->deviceid, settings.currentAccelProfile); | 308 | libinputApplyAccelerationProfile(info->deviceid, m_settings->currentAccelProfile); | ||
300 | }); | 309 | }); | ||
301 | 310 | | |||
302 | XChangePointerControl(m_dpy, | 311 | XChangePointerControl(m_dpy, | ||
303 | true, true, int(qRound(settings.accelRate * 10)), 10, settings.thresholdMove); | 312 | true, true, int(qRound(m_settings->accelRate * 10)), 10, m_settings->thresholdMove); | ||
304 | 313 | | |||
305 | XFlush(m_dpy); | 314 | XFlush(m_dpy); | ||
306 | } | 315 | } | ||
307 | 316 | | |||
308 | QString X11MouseBackend::currentCursorTheme() | 317 | QString X11Backend::currentCursorTheme() | ||
309 | { | 318 | { | ||
310 | if (!m_dpy) { | 319 | if (!m_dpy) { | ||
311 | return QString(); | 320 | return QString(); | ||
312 | } | 321 | } | ||
313 | 322 | | |||
314 | QByteArray name = XGetDefault(m_dpy, "Xcursor", "theme"); | 323 | QByteArray name = XGetDefault(m_dpy, "Xcursor", "theme"); | ||
315 | #ifdef HAVE_XCURSOR | 324 | #ifdef HAVE_XCURSOR | ||
316 | if (name.isEmpty()) { | 325 | if (name.isEmpty()) { | ||
317 | name = QByteArray(XcursorGetTheme(m_dpy)); | 326 | name = QByteArray(XcursorGetTheme(m_dpy)); | ||
318 | } | 327 | } | ||
319 | #endif | 328 | #endif | ||
320 | return QFile::decodeName(name); | 329 | return QFile::decodeName(name); | ||
321 | } | 330 | } | ||
322 | 331 | | |||
323 | void X11MouseBackend::applyCursorTheme(const QString& theme, int size) | 332 | void X11Backend::applyCursorTheme(const QString& theme, int size) | ||
324 | { | 333 | { | ||
325 | #ifdef HAVE_XCURSOR | 334 | #ifdef HAVE_XCURSOR | ||
326 | 335 | | |||
327 | // Apply the KDE cursor theme to ourselves | 336 | // Apply the KDE cursor theme to ourselves | ||
328 | if (m_dpy) { | 337 | if (m_dpy) { | ||
329 | return; | 338 | return; | ||
330 | } | 339 | } | ||
331 | if (!theme.isEmpty()) { | 340 | if (!theme.isEmpty()) { | ||
332 | XcursorSetTheme(m_dpy, QFile::encodeName(theme)); | 341 | XcursorSetTheme(m_dpy, QFile::encodeName(theme)); | ||
333 | } | 342 | } | ||
334 | 343 | | |||
335 | if (size >= 0) { | 344 | if (size >= 0) { | ||
336 | XcursorSetDefaultSize(m_dpy, size); | 345 | XcursorSetDefaultSize(m_dpy, size); | ||
337 | } | 346 | } | ||
338 | 347 | | |||
339 | // Load the default cursor from the theme and apply it to the root window. | 348 | // Load the default cursor from the theme and apply it to the root window. | ||
340 | Cursor handle = XcursorLibraryLoadCursor(m_dpy, "left_ptr"); | 349 | Cursor handle = XcursorLibraryLoadCursor(m_dpy, "left_ptr"); | ||
341 | XDefineCursor(m_dpy, DefaultRootWindow(m_dpy), handle); | 350 | XDefineCursor(m_dpy, DefaultRootWindow(m_dpy), handle); | ||
342 | XFreeCursor(m_dpy, handle); // Don't leak the cursor | 351 | XFreeCursor(m_dpy, handle); // Don't leak the cursor | ||
343 | XFlush(m_dpy); | 352 | XFlush(m_dpy); | ||
344 | #endif | 353 | #endif | ||
345 | } | 354 | } | ||
346 | 355 | | |||
347 | bool X11MouseBackend::evdevApplyReverseScroll(int deviceid, bool reverse) | 356 | bool X11Backend::evdevApplyReverseScroll(int deviceid, bool reverse) | ||
348 | { | 357 | { | ||
349 | // Check atom availability first. | 358 | // Check atom availability first. | ||
350 | if (m_evdevWheelEmulationAtom == None || m_evdevScrollDistanceAtom == None || | 359 | if (m_evdevWheelEmulationAtom == None || m_evdevScrollDistanceAtom == None || | ||
351 | m_evdevWheelEmulationAxesAtom == None) { | 360 | m_evdevWheelEmulationAxesAtom == None) { | ||
352 | return false; | 361 | return false; | ||
353 | } | 362 | } | ||
354 | Status status; | 363 | Status status; | ||
355 | Atom type_return; | 364 | Atom type_return; | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 404 | if (status == Success && type_return == XA_INTEGER && | |||
408 | XIChangeProperty(m_dpy, deviceid, m_evdevWheelEmulationAxesAtom, XA_INTEGER, | 417 | XIChangeProperty(m_dpy, deviceid, m_evdevWheelEmulationAxesAtom, XA_INTEGER, | ||
409 | 8, XIPropModeReplace, data.data(), 4); | 418 | 8, XIPropModeReplace, data.data(), 4); | ||
410 | } | 419 | } | ||
411 | } | 420 | } | ||
412 | 421 | | |||
413 | return true; | 422 | return true; | ||
414 | } | 423 | } | ||
415 | 424 | | |||
416 | bool X11MouseBackend::libinputApplyReverseScroll(int deviceid, bool reverse) | 425 | bool X11Backend::libinputApplyReverseScroll(int deviceid, bool reverse) | ||
417 | { | 426 | { | ||
418 | // Check atom availability first. | 427 | // Check atom availability first. | ||
419 | if (m_libinputNaturalScrollAtom == None) { | 428 | if (m_libinputNaturalScrollAtom == None) { | ||
420 | return false; | 429 | return false; | ||
421 | } | 430 | } | ||
422 | Status status; | 431 | Status status; | ||
423 | Atom type_return; | 432 | Atom type_return; | ||
424 | int format_return; | 433 | int format_return; | ||
Show All 14 Lines | 447 | if (type_return != XA_INTEGER || !data || format_return != 8 || num_items_return != 1) { | |||
439 | return false; | 448 | return false; | ||
440 | } | 449 | } | ||
441 | unsigned char natural = reverse ? 1 : 0; | 450 | unsigned char natural = reverse ? 1 : 0; | ||
442 | XIChangeProperty(m_dpy, deviceid, m_libinputNaturalScrollAtom, XA_INTEGER, | 451 | XIChangeProperty(m_dpy, deviceid, m_libinputNaturalScrollAtom, XA_INTEGER, | ||
443 | 8, XIPropModeReplace, &natural, 1); | 452 | 8, XIPropModeReplace, &natural, 1); | ||
444 | return true; | 453 | return true; | ||
445 | } | 454 | } | ||
446 | 455 | | |||
447 | void X11MouseBackend::libinputApplyAccelerationProfile(int deviceid, QString profile) | 456 | void X11Backend::libinputApplyAccelerationProfile(int deviceid, QString profile) | ||
448 | { | 457 | { | ||
449 | // Check atom availability first. | 458 | // Check atom availability first. | ||
450 | if (m_libinputAccelProfileAvailableAtom == None || m_libinputAccelProfileEnabledAtom == None) { | 459 | if (m_libinputAccelProfileAvailableAtom == None || m_libinputAccelProfileEnabledAtom == None) { | ||
451 | return; | 460 | return; | ||
452 | } | 461 | } | ||
453 | 462 | | |||
454 | unsigned char profileData[2]; | 463 | unsigned char profileData[2]; | ||
455 | if (profile == PROFILE_NONE) { | 464 | if (profile == PROFILE_NONE) { | ||
Show All 34 Lines |