Changeset View
Changeset View
Standalone View
Standalone View
libinput/device.cpp
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 73 | enum class ConfigKey { | |||
---|---|---|---|---|---|
78 | PointerAccelerationProfile, | 78 | PointerAccelerationProfile, | ||
79 | TapToClick, | 79 | TapToClick, | ||
80 | LmrTapButtonMap, | 80 | LmrTapButtonMap, | ||
81 | TapAndDrag, | 81 | TapAndDrag, | ||
82 | TapDragLock, | 82 | TapDragLock, | ||
83 | MiddleButtonEmulation, | 83 | MiddleButtonEmulation, | ||
84 | NaturalScroll, | 84 | NaturalScroll, | ||
85 | ScrollMethod, | 85 | ScrollMethod, | ||
86 | ScrollButton | 86 | ScrollButton, | ||
87 | ClickMethod | ||||
87 | }; | 88 | }; | ||
88 | 89 | | |||
89 | struct ConfigData { | 90 | struct ConfigData { | ||
90 | explicit ConfigData(QByteArray _key, void (Device::*_setter)(bool), bool (Device::*_defaultValue)() const = nullptr) | 91 | explicit ConfigData(QByteArray _key, void (Device::*_setter)(bool), bool (Device::*_defaultValue)() const = nullptr) | ||
91 | : key(_key) | 92 | : key(_key) | ||
92 | { booleanSetter.setter = _setter; booleanSetter.defaultValue = _defaultValue; } | 93 | { booleanSetter.setter = _setter; booleanSetter.defaultValue = _defaultValue; } | ||
93 | 94 | | |||
94 | explicit ConfigData(QByteArray _key, void (Device::*_setter)(quint32), quint32 (Device::*_defaultValue)() const = nullptr) | 95 | explicit ConfigData(QByteArray _key, void (Device::*_setter)(quint32), quint32 (Device::*_defaultValue)() const = nullptr) | ||
Show All 29 Lines | 120 | static const QMap<ConfigKey, ConfigData> s_configData { | |||
124 | {ConfigKey::PointerAccelerationProfile, ConfigData(QByteArrayLiteral("PointerAccelerationProfile"), &Device::setPointerAccelerationProfileFromInt, &Device::defaultPointerAccelerationProfileToInt)}, | 125 | {ConfigKey::PointerAccelerationProfile, ConfigData(QByteArrayLiteral("PointerAccelerationProfile"), &Device::setPointerAccelerationProfileFromInt, &Device::defaultPointerAccelerationProfileToInt)}, | ||
125 | {ConfigKey::TapToClick, ConfigData(QByteArrayLiteral("TapToClick"), &Device::setTapToClick, &Device::tapToClickEnabledByDefault)}, | 126 | {ConfigKey::TapToClick, ConfigData(QByteArrayLiteral("TapToClick"), &Device::setTapToClick, &Device::tapToClickEnabledByDefault)}, | ||
126 | {ConfigKey::TapAndDrag, ConfigData(QByteArrayLiteral("TapAndDrag"), &Device::setTapAndDrag, &Device::tapAndDragEnabledByDefault)}, | 127 | {ConfigKey::TapAndDrag, ConfigData(QByteArrayLiteral("TapAndDrag"), &Device::setTapAndDrag, &Device::tapAndDragEnabledByDefault)}, | ||
127 | {ConfigKey::TapDragLock, ConfigData(QByteArrayLiteral("TapDragLock"), &Device::setTapDragLock, &Device::tapDragLockEnabledByDefault)}, | 128 | {ConfigKey::TapDragLock, ConfigData(QByteArrayLiteral("TapDragLock"), &Device::setTapDragLock, &Device::tapDragLockEnabledByDefault)}, | ||
128 | {ConfigKey::MiddleButtonEmulation, ConfigData(QByteArrayLiteral("MiddleButtonEmulation"), &Device::setMiddleEmulation, &Device::middleEmulationEnabledByDefault)}, | 129 | {ConfigKey::MiddleButtonEmulation, ConfigData(QByteArrayLiteral("MiddleButtonEmulation"), &Device::setMiddleEmulation, &Device::middleEmulationEnabledByDefault)}, | ||
129 | {ConfigKey::LmrTapButtonMap, ConfigData(QByteArrayLiteral("LmrTapButtonMap"), &Device::setLmrTapButtonMap, &Device::lmrTapButtonMapEnabledByDefault)}, | 130 | {ConfigKey::LmrTapButtonMap, ConfigData(QByteArrayLiteral("LmrTapButtonMap"), &Device::setLmrTapButtonMap, &Device::lmrTapButtonMapEnabledByDefault)}, | ||
130 | {ConfigKey::NaturalScroll, ConfigData(QByteArrayLiteral("NaturalScroll"), &Device::setNaturalScroll, &Device::naturalScrollEnabledByDefault)}, | 131 | {ConfigKey::NaturalScroll, ConfigData(QByteArrayLiteral("NaturalScroll"), &Device::setNaturalScroll, &Device::naturalScrollEnabledByDefault)}, | ||
131 | {ConfigKey::ScrollMethod, ConfigData(QByteArrayLiteral("ScrollMethod"), &Device::activateScrollMethodFromInt, &Device::defaultScrollMethodToInt)}, | 132 | {ConfigKey::ScrollMethod, ConfigData(QByteArrayLiteral("ScrollMethod"), &Device::activateScrollMethodFromInt, &Device::defaultScrollMethodToInt)}, | ||
132 | {ConfigKey::ScrollButton, ConfigData(QByteArrayLiteral("ScrollButton"), &Device::setScrollButton, &Device::defaultScrollButton)} | 133 | {ConfigKey::ScrollButton, ConfigData(QByteArrayLiteral("ScrollButton"), &Device::setScrollButton, &Device::defaultScrollButton)}, | ||
134 | {ConfigKey::ClickMethod, ConfigData(QByteArrayLiteral("ClickMethod"), &Device::setClickMethodFromInt, &Device::defaultClickMethodToInt)} | ||||
133 | }; | 135 | }; | ||
134 | 136 | | |||
135 | namespace { | 137 | namespace { | ||
136 | QMatrix4x4 defaultCalibrationMatrix(libinput_device *device) | 138 | QMatrix4x4 defaultCalibrationMatrix(libinput_device *device) | ||
137 | { | 139 | { | ||
138 | float matrix[6]; | 140 | float matrix[6]; | ||
139 | const int ret = libinput_device_config_calibration_get_default_matrix(device, matrix); | 141 | const int ret = libinput_device_config_calibration_get_default_matrix(device, matrix); | ||
140 | if (ret == 0) { | 142 | if (ret == 0) { | ||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | 166 | #endif | |||
204 | , m_defaultPointerAcceleration(libinput_device_config_accel_get_default_speed(m_device)) | 206 | , m_defaultPointerAcceleration(libinput_device_config_accel_get_default_speed(m_device)) | ||
205 | , m_pointerAcceleration(libinput_device_config_accel_get_speed(m_device)) | 207 | , m_pointerAcceleration(libinput_device_config_accel_get_speed(m_device)) | ||
206 | , m_supportedPointerAccelerationProfiles(libinput_device_config_accel_get_profiles(m_device)) | 208 | , m_supportedPointerAccelerationProfiles(libinput_device_config_accel_get_profiles(m_device)) | ||
207 | , m_defaultPointerAccelerationProfile(libinput_device_config_accel_get_default_profile(m_device)) | 209 | , m_defaultPointerAccelerationProfile(libinput_device_config_accel_get_default_profile(m_device)) | ||
208 | , m_pointerAccelerationProfile(libinput_device_config_accel_get_profile(m_device)) | 210 | , m_pointerAccelerationProfile(libinput_device_config_accel_get_profile(m_device)) | ||
209 | , m_enabled(m_supportsDisableEvents ? libinput_device_config_send_events_get_mode(m_device) == LIBINPUT_CONFIG_SEND_EVENTS_ENABLED : true) | 211 | , m_enabled(m_supportsDisableEvents ? libinput_device_config_send_events_get_mode(m_device) == LIBINPUT_CONFIG_SEND_EVENTS_ENABLED : true) | ||
210 | , m_config() | 212 | , m_config() | ||
211 | , m_defaultCalibrationMatrix(m_supportsCalibrationMatrix ? defaultCalibrationMatrix(m_device) : QMatrix4x4{}) | 213 | , m_defaultCalibrationMatrix(m_supportsCalibrationMatrix ? defaultCalibrationMatrix(m_device) : QMatrix4x4{}) | ||
214 | , m_supportedClickMethods(libinput_device_config_click_get_methods(m_device)) | ||||
215 | , m_defaultClickMethod(libinput_device_config_click_get_default_method(m_device)) | ||||
216 | , m_clickMethod(libinput_device_config_click_get_method(m_device)) | ||||
212 | { | 217 | { | ||
213 | libinput_device_ref(m_device); | 218 | libinput_device_ref(m_device); | ||
214 | 219 | | |||
215 | qreal width = 0; | 220 | qreal width = 0; | ||
216 | qreal height = 0; | 221 | qreal height = 0; | ||
217 | if (libinput_device_get_size(m_device, &width, &height) == 0) { | 222 | if (libinput_device_get_size(m_device, &width, &height) == 0) { | ||
218 | m_size = QSizeF(width, height); | 223 | m_size = QSizeF(width, height); | ||
219 | } | 224 | } | ||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | 355 | if (libinput_device_config_accel_set_profile(m_device, profile) == LIBINPUT_CONFIG_STATUS_SUCCESS) { | |||
351 | if (m_pointerAccelerationProfile != profile) { | 356 | if (m_pointerAccelerationProfile != profile) { | ||
352 | m_pointerAccelerationProfile = profile; | 357 | m_pointerAccelerationProfile = profile; | ||
353 | emit pointerAccelerationProfileChanged(); | 358 | emit pointerAccelerationProfileChanged(); | ||
354 | writeEntry(ConfigKey::PointerAccelerationProfile, (quint32) profile); | 359 | writeEntry(ConfigKey::PointerAccelerationProfile, (quint32) profile); | ||
355 | } | 360 | } | ||
356 | } | 361 | } | ||
357 | } | 362 | } | ||
358 | 363 | | |||
364 | void Device::setClickMethod(bool set, enum libinput_config_click_method method) | ||||
davidedmundson: Current we switch modes, but there's also a:
LIBINPUT_CONFIG_CLICK_METHOD_NONE
Is there a… | |||||
If the user device already has physical buttons We need not to change anything default setting will be applicable and no ui will be exposed . else if it doesn't has physical buttons then user needs to select either areas or clickfinger mode So i don't think we ever need to set method as LIBINPUT_CONFIG_CLICK_METHOD_NONE atulbi:
If the user device already has physical buttons
We need not to change anything
default… | |||||
365 | { | ||||
366 | if (!(m_supportedClickMethods & method)) { | ||||
In terms of whitespace we follow: davidedmundson: In terms of whitespace we follow:
https://community.kde. | |||||
367 | return; | ||||
368 | } | ||||
369 | if (!set) { | ||||
370 | method = (method == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) ? LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER : LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; | ||||
371 | if (!(m_supportedClickMethods & method)) { | ||||
372 | return; | ||||
373 | } | ||||
374 | } | ||||
375 | | ||||
376 | if (libinput_device_config_click_set_method(m_device, method) == LIBINPUT_CONFIG_STATUS_SUCCESS) { | ||||
377 | if (m_clickMethod != method) { | ||||
378 | m_clickMethod = method; | ||||
379 | emit clickMethodChanged(); | ||||
380 | writeEntry(ConfigKey::ClickMethod, (quint32) method); | ||||
381 | } | ||||
382 | } | ||||
383 | } | ||||
384 | | ||||
359 | void Device::setScrollMethod(bool set, enum libinput_config_scroll_method method) | 385 | void Device::setScrollMethod(bool set, enum libinput_config_scroll_method method) | ||
360 | { | 386 | { | ||
361 | if (!(m_supportedScrollMethods & method)) { | 387 | if (!(m_supportedScrollMethods & method)) { | ||
362 | return; | 388 | return; | ||
363 | } | 389 | } | ||
364 | 390 | | |||
365 | bool isCurrent = m_scrollMethod == method; | 391 | bool isCurrent = m_scrollMethod == method; | ||
366 | if (!set) { | 392 | if (!set) { | ||
▲ Show 20 Lines • Show All 134 Lines • Show Last 20 Lines |
Current we switch modes, but there's also a:
LIBINPUT_CONFIG_CLICK_METHOD_NONE
Is there a need for the KCM to ever set libinput to this?
If so as a general rule exposing a 3 state enum states as 2 bools can lead to things becoming more complicated. Especially if we have async connections to the config.