pub mod acceleration;
pub mod capability;
pub mod clickmethod;
use {
crate::{
_private::{DEFAULT_SEAT_NAME, ipc::WorkspaceSource},
Axis, Direction, ModifiedKeySym, Workspace,
input::{acceleration::AccelProfile, capability::Capability, clickmethod::ClickMethod},
keyboard::{Keymap, mods::Modifiers, syms::KeySym},
video::Connector,
window::Window,
},
serde::{Deserialize, Serialize},
std::time::Duration,
};
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct InputDevice(pub u64);
impl InputDevice {
pub fn set_seat(self, seat: Seat) {
get!().set_seat(self, seat)
}
pub fn set_keymap(self, keymap: Keymap) {
get!().set_device_keymap(self, keymap)
}
pub fn has_capability(self, cap: Capability) -> bool {
get!(false).has_capability(self, cap)
}
pub fn set_left_handed(self, left_handed: bool) {
get!().set_left_handed(self, left_handed);
}
pub fn set_accel_profile(self, profile: AccelProfile) {
get!().set_accel_profile(self, profile);
}
pub fn set_accel_speed(self, speed: f64) {
get!().set_accel_speed(self, speed);
}
pub fn set_transform_matrix(self, matrix: [[f64; 2]; 2]) {
get!().set_transform_matrix(self, matrix);
}
pub fn set_calibration_matrix(self, matrix: [[f32; 3]; 2]) {
get!().set_calibration_matrix(self, matrix);
}
pub fn name(self) -> String {
get!(String::new()).device_name(self)
}
pub fn set_px_per_wheel_scroll(self, px: f64) {
get!().set_px_per_wheel_scroll(self, px);
}
pub fn set_tap_enabled(self, enabled: bool) {
get!().set_input_tap_enabled(self, enabled);
}
pub fn set_drag_enabled(self, enabled: bool) {
get!().set_input_drag_enabled(self, enabled);
}
pub fn set_drag_lock_enabled(self, enabled: bool) {
get!().set_input_drag_lock_enabled(self, enabled);
}
pub fn set_natural_scrolling_enabled(self, enabled: bool) {
get!().set_input_natural_scrolling_enabled(self, enabled);
}
pub fn set_click_method(self, method: ClickMethod) {
get!().set_input_click_method(self, method);
}
pub fn set_middle_button_emulation_enabled(self, enabled: bool) {
get!().set_input_middle_button_emulation_enabled(self, enabled);
}
pub fn syspath(self) -> String {
get!(String::new()).input_device_syspath(self)
}
pub fn devnode(self) -> String {
get!(String::new()).input_device_devnode(self)
}
pub fn on_switch_event<F: FnMut(SwitchEvent) + 'static>(self, f: F) {
get!().on_switch_event(self, f)
}
pub fn set_connector(self, connector: Connector) {
get!().set_input_device_connector(self, connector);
}
pub fn remove_mapping(self) {
get!().remove_input_mapping(self);
}
}
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum Timeline {
Older,
Newer,
}
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum LayerDirection {
Below,
Above,
}
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub struct Seat(pub u64);
impl Seat {
pub const INVALID: Self = Self(0);
pub fn is_invalid(self) -> bool {
self == Self::INVALID
}
#[doc(hidden)]
pub fn raw(self) -> u64 {
self.0
}
#[doc(hidden)]
pub fn from_raw(raw: u64) -> Self {
Self(raw)
}
pub fn use_hardware_cursor(self, use_hardware_cursor: bool) {
get!().set_use_hardware_cursor(self, use_hardware_cursor);
}
pub fn set_cursor_size(self, size: i32) {
get!().set_cursor_size(self, size)
}
pub fn bind<T: Into<ModifiedKeySym>, F: FnMut() + 'static>(self, mod_sym: T, f: F) {
self.bind_masked(Modifiers(!0), mod_sym, f)
}
pub fn bind_masked<T: Into<ModifiedKeySym>, F: FnMut() + 'static>(
self,
mod_mask: Modifiers,
mod_sym: T,
f: F,
) {
get!().bind_masked(self, mod_mask, mod_sym.into(), f)
}
pub fn latch<F: FnOnce() + 'static>(self, f: F) {
get!().latch(self, f)
}
pub fn unbind<T: Into<ModifiedKeySym>>(self, mod_sym: T) {
get!().unbind(self, mod_sym.into())
}
pub fn focus_history(self, timeline: Timeline) {
get!().seat_focus_history(self, timeline)
}
pub fn focus_history_set_only_visible(self, only_visible: bool) {
get!().seat_focus_history_set_only_visible(self, only_visible)
}
pub fn focus_history_set_same_workspace(self, same_workspace: bool) {
get!().seat_focus_history_set_same_workspace(self, same_workspace)
}
pub fn focus_layer_rel(self, direction: LayerDirection) {
get!().seat_focus_layer_rel(self, direction)
}
pub fn focus_tiles(self) {
get!().seat_focus_tiles(self)
}
pub fn focus(self, direction: Direction) {
get!().seat_focus(self, direction)
}
pub fn move_(self, direction: Direction) {
get!().seat_move(self, direction)
}
pub fn set_keymap(self, keymap: Keymap) {
get!().seat_set_keymap(self, keymap)
}
pub fn repeat_rate(self) -> (i32, i32) {
get!((25, 250)).seat_get_repeat_rate(self)
}
pub fn set_repeat_rate(self, rate: i32, delay: i32) {
get!().seat_set_repeat_rate(self, rate, delay)
}
pub fn mono(self) -> bool {
get!(false).seat_mono(self)
}
pub fn set_mono(self, mono: bool) {
get!().set_seat_mono(self, mono)
}
pub fn toggle_mono(self) {
self.set_mono(!self.mono());
}
pub fn split(self) -> Axis {
get!(Axis::Horizontal).seat_split(self)
}
pub fn set_split(self, axis: Axis) {
get!().set_seat_split(self, axis)
}
pub fn toggle_split(self) {
self.set_split(self.split().other());
}
pub fn input_devices(self) -> Vec<InputDevice> {
get!().get_input_devices(Some(self))
}
pub fn create_split(self, axis: Axis) {
get!().create_seat_split(self, axis);
}
pub fn focus_parent(self) {
get!().focus_seat_parent(self);
}
pub fn close(self) {
get!().seat_close(self);
}
pub fn get_floating(self) -> bool {
get!().get_seat_floating(self)
}
pub fn set_floating(self, floating: bool) {
get!().set_seat_floating(self, floating);
}
pub fn toggle_floating(self) {
get!().toggle_seat_floating(self);
}
pub fn get_workspace(self) -> Workspace {
get!(Workspace(0)).get_seat_cursor_workspace(self)
}
pub fn get_keyboard_workspace(self) -> Workspace {
get!(Workspace(0)).get_seat_keyboard_workspace(self)
}
pub fn show_workspace(self, workspace: Workspace) {
get!().show_workspace(self, workspace)
}
pub fn show_workspace_on(self, workspace: Workspace, connector: Connector) {
get!().show_workspace_on(self, workspace, connector)
}
pub fn set_workspace(self, workspace: Workspace) {
get!().set_seat_workspace(self, workspace)
}
pub fn toggle_fullscreen(self) {
let c = get!();
c.set_seat_fullscreen(self, !c.get_seat_fullscreen(self));
}
pub fn fullscreen(self) -> bool {
get!(false).get_seat_fullscreen(self)
}
pub fn set_fullscreen(self, fullscreen: bool) {
get!().set_seat_fullscreen(self, fullscreen)
}
pub fn disable_pointer_constraint(self) {
get!().disable_pointer_constraint(self)
}
pub fn move_to_output(self, connector: Connector) {
get!().move_to_output(WorkspaceSource::Seat(self), connector);
}
pub fn set_forward(self, forward: bool) {
get!().set_forward(self, forward);
}
pub fn forward(self) {
self.set_forward(true)
}
pub fn consume(self) {
self.set_forward(false)
}
pub fn set_focus_follows_mouse_mode(self, mode: FocusFollowsMouseMode) {
get!().set_focus_follows_mouse_mode(self, mode);
}
pub fn set_fallback_output_mode(self, mode: FallbackOutputMode) {
get!().set_fallback_output_mode(self, mode);
}
pub fn set_window_management_enabled(self, enabled: bool) {
get!().set_window_management_enabled(self, enabled);
}
pub fn set_window_management_key<T: Into<ModifiedKeySym>>(self, mod_sym: T) {
self.bind(mod_sym, move || {
self.set_window_management_enabled(true);
self.forward();
self.latch(move || {
self.set_window_management_enabled(false);
});
});
}
pub fn float_pinned(self) -> bool {
get!().get_pinned(self)
}
pub fn set_float_pinned(self, pinned: bool) {
get!().set_pinned(self, pinned);
}
pub fn toggle_float_pinned(self) {
self.set_float_pinned(!self.float_pinned());
}
pub fn window(self) -> Window {
get!(Window(0)).get_seat_keyboard_window(self)
}
pub fn focus_window(self, window: Window) {
get!().focus_window(self, window)
}
pub fn set_pointer_revert_key(self, sym: KeySym) {
get!().set_pointer_revert_key(self, sym);
}
pub fn create_mark(self, kc: Option<u32>) {
get!().seat_create_mark(self, kc);
}
pub fn jump_to_mark(self, kc: Option<u32>) {
get!().seat_jump_to_mark(self, kc);
}
pub fn copy_mark(self, src: u32, dst: u32) {
get!().seat_copy_mark(self, src, dst);
}
pub fn set_simple_im_enabled(self, enabled: bool) {
get!().seat_set_simple_im_enabled(self, enabled);
}
pub fn simple_im_enabled(self) -> bool {
get!(true).seat_get_simple_im_enabled(self)
}
pub fn toggle_simple_im_enabled(self) {
let get = get!();
get.seat_set_simple_im_enabled(self, !get.seat_get_simple_im_enabled(self));
}
pub fn reload_simple_im(self) {
get!().seat_reload_simple_im(self);
}
pub fn enable_unicode_input(self) {
get!().seat_enable_unicode_input(self);
}
}
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum FocusFollowsMouseMode {
True,
False,
}
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
#[non_exhaustive]
pub enum FallbackOutputMode {
Cursor,
Focus,
}
pub fn get_seats() -> Vec<Seat> {
get!().seats()
}
pub fn input_devices() -> Vec<InputDevice> {
get!().get_input_devices(None)
}
pub fn get_seat(name: &str) -> Seat {
get!(Seat(0)).get_seat(name)
}
pub fn get_default_seat() -> Seat {
get_seat(DEFAULT_SEAT_NAME)
}
pub fn on_new_seat<F: FnMut(Seat) + 'static>(f: F) {
get!().on_new_seat(f)
}
pub fn on_new_input_device<F: FnMut(InputDevice) + 'static>(f: F) {
get!().on_new_input_device(f)
}
pub fn on_input_device_removed<F: FnMut(InputDevice) + 'static>(f: F) {
get!().on_input_device_removed(f)
}
pub fn set_double_click_time(duration: Duration) {
let usec = duration.as_micros().min(u64::MAX as u128);
get!().set_double_click_interval(usec as u64)
}
pub fn set_double_click_distance(distance: i32) {
get!().set_double_click_distance(distance)
}
pub fn disable_default_seat() {
get!().disable_default_seat();
}
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
pub enum SwitchEvent {
LidOpened,
LidClosed,
ConvertedToLaptop,
ConvertedToTablet,
}
pub fn set_libei_socket_enabled(enabled: bool) {
get!().set_ei_socket_enabled(enabled);
}