Skip to content

Commit b2b2657

Browse files
committed
input: upgrade to libinput 1.28
1 parent b96d9a0 commit b2b2657

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-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: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ pub enum DragLockState {
173173
EnabledSticky,
174174
}
175175

176+
/// A config status to distinguish or set 3-finger dragging on a device.
177+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
178+
#[non_exhaustive]
179+
#[cfg(feature = "libinput_1_28")]
180+
pub enum ThreeFingerDragState {
181+
/// Drag is to be disabled, or is currently disabled
182+
Disabled,
183+
/// Drag is to be enabled for 3 fingers, or is currently enabled
184+
EnabledThreeFinger,
185+
/// Drag is to be enabled for 4 fingers, or is currently enabled
186+
EnabledFourFinger,
187+
}
188+
176189
/// Whenever scroll button lock is enabled or not
177190
#[cfg(feature = "libinput_1_15")]
178191
#[allow(missing_docs)]
@@ -1968,6 +1981,82 @@ impl Device {
19681981
/// See `config_tap_set_enabled` for more information.
19691982
pub fn config_tap_finger_count, ffi::libinput_device_config_tap_get_finger_count, u32);
19701983

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

0 commit comments

Comments
 (0)