1
0
Fork 0
forked from wry/wry

config: allow handling switch events

This commit is contained in:
Julian Orth 2024-04-28 13:35:52 +02:00
parent 55d55bf161
commit cf233abb5a
21 changed files with 443 additions and 27 deletions

View file

@ -138,6 +138,11 @@ impl InputDevice {
pub fn devnode(self) -> String {
get!(String::new()).input_device_devnode(self)
}
/// Sets a callback that will be run if this device triggers a switch event.
pub fn on_switch_event<F: FnMut(SwitchEvent) + 'static>(self, f: F) {
get!().on_switch_event(self, f)
}
}
/// A seat.
@ -479,3 +484,26 @@ pub fn set_double_click_distance(distance: i32) {
pub fn disable_default_seat() {
get!().disable_default_seat();
}
/// An event generated by a switch.
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum SwitchEvent {
/// The lid of the device (usually a laptop) has been opened.
///
/// This is the default state.
LidOpened,
/// The lid of the device (usually a laptop) has been closed.
///
/// If the device is already in this state when the device is discovered, a synthetic
/// event of this kind is generated.
LidClosed,
/// The device has been converted from tablet to laptop mode.
///
/// This is the default state.
ConvertedToLaptop,
/// The device has been converted from laptop to tablet mode.
///
/// If the device is already in this state when the device is discovered, a synthetic
/// event of this kind is generated.
ConvertedToTablet,
}