input: Add a scroll_factor config option
This is not a setting handled by libinput; we have to scale the scrolling ourselves. This should match the behavior of the `scroll_factor` defined in sway-input(5).
This commit is contained in:
parent
511ee8d87a
commit
20159a6c8c
4 changed files with 39 additions and 6 deletions
|
|
@ -412,13 +412,26 @@ impl Config {
|
|||
}
|
||||
|
||||
pub fn read_device(&self, device: &mut InputDevice) {
|
||||
let (device_config, default_config) = self.get_device_config(device);
|
||||
input_config::update_device(device, device_config, default_config);
|
||||
}
|
||||
|
||||
pub fn scroll_factor(&self, device: &InputDevice) -> f64 {
|
||||
let (device_config, default_config) = self.get_device_config(device);
|
||||
input_config::get_config(device_config, default_config, |x| {
|
||||
x.scroll_config.as_ref()?.scroll_factor
|
||||
})
|
||||
.map_or(1.0, |x| x.0)
|
||||
}
|
||||
|
||||
fn get_device_config(&self, device: &InputDevice) -> (Option<&InputConfig>, &InputConfig) {
|
||||
let default_config = if device.config_tap_finger_count() > 0 {
|
||||
&self.input_touchpad
|
||||
} else {
|
||||
&self.input_default
|
||||
};
|
||||
let device_config = self.input_devices.get(device.name());
|
||||
input_config::update_device(device, device_config, default_config);
|
||||
(device_config, default_config)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue