Skip to content

Commit ffcb518

Browse files
committed
input: upgrade to libinput 1.28
1 parent 8194f75 commit ffcb518

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ libinput_1_21 = ["input-sys/libinput_1_21", "libinput_1_19"]
4040
libinput_1_23 = ["input-sys/libinput_1_23", "libinput_1_21"]
4141
libinput_1_26 = ["input-sys/libinput_1_26", "libinput_1_23"]
4242
libinput_1_27 = ["input-sys/libinput_1_27", "libinput_1_26"]
43+
libinput_1_28 = ["input-sys/libinput_1_28", "libinput_1_27"]
4344

4445
[workspace]
4546
members = [

src/device.rs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ pub enum DragLockState {
170170
EnabledSticky,
171171
}
172172

173+
/// A config status to distinguish or set 3-finger dragging on a device.
174+
pub enum ThreeFingerDragState {
175+
/// Drag is to be disabled, or is currently disabled
176+
Disabled,
177+
/// Drag is to be enabled for 3 fingers, or is currently enabled
178+
EnabledThreeFinger,
179+
/// Drag is to be enabled for 4 fingers, or is currently enabled
180+
EnabledFourFinger,
181+
}
182+
173183
/// Whenever scroll button lock is enabled or not
174184
#[cfg(feature = "libinput_1_15")]
175185
#[allow(missing_docs)]
@@ -1966,6 +1976,82 @@ impl Device {
19661976
/// See `config_tap_set_enabled` for more information.
19671977
pub fn config_tap_finger_count, ffi::libinput_device_config_tap_get_finger_count, u32);
19681978

1979+
#[cfg(feature = "libinput_1_28")]
1980+
ffi_func!(
1981+
/// Returns the maximum number of fingers available for 3-finger dragging.
1982+
pub fn config_3fg_drag_get_finger_count, ffi::libinput_device_config_3fg_drag_get_finger_count, u32);
1983+
1984+
/// Enable or disable 3-finger drag on this device.
1985+
///
1986+
/// When enabled, three fingers down will result in a button down event,
1987+
/// subsequent finger motion triggers a drag. The button is released shortly
1988+
/// after all fingers are logically up.
1989+
///
1990+
/// See [Three-finger drag](https://wayland.freedesktop.org/libinput/doc/latest/configuration.html#three-finger-drag) for details.
1991+
#[cfg(feature = "libinput_1_28")]
1992+
pub fn config_3fg_drag_set_enabled(&self, state: ThreeFingerDragState) -> DeviceConfigResult {
1993+
match unsafe {
1994+
ffi::libinput_device_config_3fg_drag_set_enabled(
1995+
self.as_raw_mut(),
1996+
match state {
1997+
ThreeFingerDragState::Disabled => {
1998+
ffi::libinput_config_3fg_drag_state_LIBINPUT_CONFIG_3FG_DRAG_DISABLED
1999+
}
2000+
ThreeFingerDragState::EnabledThreeFinger => {
2001+
ffi::libinput_config_3fg_drag_state_LIBINPUT_CONFIG_3FG_DRAG_ENABLED_3FG
2002+
}
2003+
ThreeFingerDragState::EnabledFourFinger => {
2004+
ffi::libinput_config_3fg_drag_state_LIBINPUT_CONFIG_3FG_DRAG_ENABLED_4FG
2005+
}
2006+
},
2007+
)
2008+
} {
2009+
ffi::libinput_config_status_LIBINPUT_CONFIG_STATUS_SUCCESS => Ok(()),
2010+
ffi::libinput_config_status_LIBINPUT_CONFIG_STATUS_UNSUPPORTED => {
2011+
Err(DeviceConfigError::Unsupported)
2012+
}
2013+
ffi::libinput_config_status_LIBINPUT_CONFIG_STATUS_INVALID => {
2014+
Err(DeviceConfigError::Invalid)
2015+
}
2016+
_ => panic!("libinput returned invalid 'libinput_config_status'"),
2017+
}
2018+
}
2019+
2020+
/// Return whether 3-finger drag is enabled or disabled on this device.
2021+
#[cfg(feature = "libinput_1_28")]
2022+
pub fn config_3fg_drag_get_enabled(&self) -> ThreeFingerDragState {
2023+
match unsafe { ffi::libinput_device_config_3fg_drag_get_enabled(self.as_raw_mut()) } {
2024+
ffi::libinput_config_3fg_drag_state_LIBINPUT_CONFIG_3FG_DRAG_DISABLED => {
2025+
ThreeFingerDragState::Disabled
2026+
}
2027+
ffi::libinput_config_3fg_drag_state_LIBINPUT_CONFIG_3FG_DRAG_ENABLED_3FG => {
2028+
ThreeFingerDragState::EnabledThreeFinger
2029+
}
2030+
ffi::libinput_config_3fg_drag_state_LIBINPUT_CONFIG_3FG_DRAG_ENABLED_4FG => {
2031+
ThreeFingerDragState::EnabledFourFinger
2032+
}
2033+
_ => panic!("libinput returned invalid 'libinput_config_3fg_drag_state'"),
2034+
}
2035+
}
2036+
2037+
/// Return whether 3-finger drag is enabled or disabled by default on this device.
2038+
#[cfg(feature = "libinput_1_28")]
2039+
pub fn config_3fg_drag_get_default_enabled(&self) -> ThreeFingerDragState {
2040+
match unsafe { ffi::libinput_device_config_3fg_drag_get_default_enabled(self.as_raw_mut()) }
2041+
{
2042+
ffi::libinput_config_3fg_drag_state_LIBINPUT_CONFIG_3FG_DRAG_DISABLED => {
2043+
ThreeFingerDragState::Disabled
2044+
}
2045+
ffi::libinput_config_3fg_drag_state_LIBINPUT_CONFIG_3FG_DRAG_ENABLED_3FG => {
2046+
ThreeFingerDragState::EnabledThreeFinger
2047+
}
2048+
ffi::libinput_config_3fg_drag_state_LIBINPUT_CONFIG_3FG_DRAG_ENABLED_4FG => {
2049+
ThreeFingerDragState::EnabledFourFinger
2050+
}
2051+
_ => panic!("libinput returned invalid 'libinput_config_3fg_drag_state'"),
2052+
}
2053+
}
2054+
19692055
/// Set the finger number to button number mapping for
19702056
/// tap-to-click.
19712057
///

0 commit comments

Comments
 (0)