Commit ead253cc authored by Giusy Margarita's avatar Giusy Margarita Committed by Nate Graham

Increase values for touchpad acceleration that can be set from kcm libinput UI

Summary:
Plasma System settings can set only 11 values for touchpad acceleration. The option accept a float number between -1 and 1 but, because of the slider limitation, only 11 values in between multiple of 0,2 con be set.

I think this is a great limitation since some touchpad models need specific values to give the user the proper comfort in handling the pointer. Libinput has already less options than the old synaptic, at least let's give the user the ability to set the acceleration with more precision.

In example, the best value for my touchpad is 0,15, but I can't set it, and even if 0,2 is the nearest, I feel better with 0,15 and want to set it. Unfortunately I can't from the kcm UI and I have to modify //~/.config/touchpadxlibinputrc// config manually. I think this is unacceptable for a DE like Plasma that claims to be highly customizable.

So, in order to increase values that can be set with the slider, I suggest to modify the formula in //touchpad.qml// to pick 41 values in the middle, multiple of 0,05.

Reviewers: #vdg, #plasma, ngraham

Reviewed By: #vdg, ngraham

Subscribers: ndavis, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D29365
parent 9083b394
......@@ -69,7 +69,8 @@ Kirigami.ScrollablePage {
dwt.load()
leftHanded.load()
middleEmulation.load()
accelSpeed.load()
accelSpeedSpinbox.load()
accelSpeedSlider.load()
accelProfile.load()
tapToClick.load()
tapAndDrag.load()
......@@ -237,33 +238,99 @@ Kirigami.ScrollablePage {
}
// Acceleration
Controls.Slider {
Kirigami.FormData.label: i18nd("kcm_touchpad", "Pointer speed:")
Layouts.RowLayout {
Kirigami.FormData.label: i18nd("kcm_touchpad", "Pointer acceleration:")
id: accelSpeed
from: 1
to: 11
stepSize: 1
function onAccelSpeedChanged(val) {
// check slider
if (val != accelSpeedSlider.accelSpeedValue) {
accelSpeedSlider.accelSpeedValue = val
accelSpeedSlider.value = Math.round(6 + (val / 100) / 0.2)
}
function load() {
enabled = touchpad.supportsPointerAcceleration
if (!enabled) {
value = 0.1
return
// check spinbox
if (val != accelSpeedSpinbox.value) {
accelSpeedSpinbox.value = val
}
// transform libinput's pointer acceleration range [-1, 1] to slider range [1, 11]
value = 6 + touchpad.pointerAcceleration / 0.2
}
onValueChanged: {
if (touchpad != undefined && enabled && !root.loading) {
// transform slider range [1, 11] to libinput's pointer acceleration range [-1, 1]
// by *10 and /10, we ignore the floating points after 1 digit. This prevents from
// having a libinput value like 0.60000001
touchpad.pointerAcceleration = Math.round(((value-6) * 0.2) * 10) / 10
// check libinput accelspeed
if ((val / 100) != touchpad.pointerAcceleration) {
touchpad.pointerAcceleration = val / 100
root.changeSignal()
}
}
Controls.Slider {
id: accelSpeedSlider
from: 1
to: 11
stepSize: 1
property int accelSpeedValue: 0 // [-100, 100]
function load() {
enabled = touchpad.supportsPointerAcceleration
if (!enabled) {
return
}
accelSpeedValue = Math.round(touchpad.pointerAcceleration * 100)
// convert libinput pointer acceleration range [-1, 1] to slider range [1, 11]
value = Math.round(6 + touchpad.pointerAcceleration / 0.2)
}
onValueChanged: {
if (touchpad != undefined && enabled && !root.loading) {
// convert slider range [1, 11] to accelSpeedValue range [-100, 100]
accelSpeedValue = Math.round(((value - 6) * 0.2) * 100)
accelSpeed.onAccelSpeedChanged(accelSpeedValue)
}
}
}
Controls.SpinBox {
id: accelSpeedSpinbox
Layouts.Layout.minimumWidth: Kirigami.Units.gridUnit * 4
from: -100
to: 100
stepSize: 1
editable: true
validator: DoubleValidator {
bottom: accelSpeedSpinbox.from
top: accelSpeedSpinbox.to
}
function load() {
enabled = touchpad.supportsPointerAcceleration
if (!enabled) {
return
}
// if existing configuration or another application set a value with more than 2 decimals
// we reduce the precision to 2
value = Math.round(touchpad.pointerAcceleration * 100)
}
onValueChanged: {
if (touchpad != undefined && enabled && !root.loading) {
accelSpeed.onAccelSpeedChanged(value)
}
}
textFromValue: function(val, locale) {
return Number(val / 100).toLocaleString(locale, "f", 2)
}
valueFromText: function(text, locale) {
return Number.fromLocaleString(locale, text) * 100
}
}
}
Layouts.ColumnLayout {
......@@ -669,7 +736,7 @@ Kirigami.ScrollablePage {
Kirigami.FormData.buddyFor: rightClickMethodAreas
id: rightClickMethod
enabled: touchpad.supportsClickMethodAreas && touchpad.supportsClickMethodClickfinger
spacing: Kirigami.Units.smallSpacing
function load() {
......@@ -736,7 +803,7 @@ Kirigami.ScrollablePage {
Kirigami.FormData.label: i18nd("kcm_touchpad", "Middle-click: ")
Kirigami.FormData.buddyFor: middleSoftwareEmulation
id: middleClickMethod
spacing: Kirigami.Units.smallSpacing
function load() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment