diff --git a/api/rust/src/input.rs b/api/rust/src/input.rs index 91304e4..475b928 100644 --- a/api/rust/src/input.rs +++ b/api/rust/src/input.rs @@ -1,3 +1,5 @@ +pub mod libinput; + use xkbcommon::xkb::Keysym; use crate::{ @@ -5,7 +7,11 @@ use crate::{ send_msg, CALLBACK_VEC, }; -pub struct Input; +use self::libinput::Libinput; + +pub struct Input { + pub libinput: Libinput, +} impl Input { /// Set a keybind. diff --git a/api/rust/src/input/libinput.rs b/api/rust/src/input/libinput.rs new file mode 100644 index 0000000..9f2a7d3 --- /dev/null +++ b/api/rust/src/input/libinput.rs @@ -0,0 +1,55 @@ +use crate::{msg::Msg, send_msg}; + +pub struct Libinput; + +impl Libinput { + pub fn set(&self, setting: LibinputSetting) { + let msg = Msg::SetLibinputSetting(setting); + send_msg(msg).unwrap(); + } +} + +#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)] +pub enum AccelProfile { + Flat, + Adaptive, +} + +#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)] +pub enum ClickMethod { + ButtonAreas, + Clickfinger, +} + +#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)] +pub enum ScrollMethod { + NoScroll, + TwoFinger, + Edge, + OnButtonDown, +} + +#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)] +pub enum TapButtonMap { + LeftRightMiddle, + LeftMiddleRight, +} + +#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)] +pub enum LibinputSetting { + AccelProfile(AccelProfile), + AccelSpeed(f64), + CalibrationMatrix([f32; 6]), + ClickMethod(ClickMethod), + DisableWhileTypingEnabled(bool), + LeftHanded(bool), + MiddleEmulationEnabled(bool), + RotationAngle(u32), + ScrollMethod(ScrollMethod), + NaturalScrollEnabled(bool), + ScrollButton(u32), + TapButtonMap(TapButtonMap), + TapDragEnabled(bool), + TapDragLockEnabled(bool), + TapEnabled(bool), +} diff --git a/api/rust/src/lib.rs b/api/rust/src/lib.rs index d6a2814..6bdc922 100644 --- a/api/rust/src/lib.rs +++ b/api/rust/src/lib.rs @@ -9,6 +9,7 @@ mod process; mod tag; mod window; +use input::libinput::Libinput; use input::Input; pub use input::Modifier; pub use input::MouseButton; @@ -53,7 +54,7 @@ pub fn setup(config_func: impl FnOnce(Pinnacle)) -> anyhow::Result<()> { let pinnacle = Pinnacle { process: Process, - input: Input, + input: Input { libinput: Libinput }, window: Window { rules: WindowRules }, output: Output, tag: Tag, diff --git a/api/rust/src/msg.rs b/api/rust/src/msg.rs index 754645a..73b5115 100644 --- a/api/rust/src/msg.rs +++ b/api/rust/src/msg.rs @@ -1,6 +1,7 @@ use std::num::NonZeroU32; use crate::{ + input::libinput::LibinputSetting, output::OutputName, tag::{Layout, TagId}, window::{FloatingOrTiled, FullscreenOrMaximized, WindowId}, @@ -52,51 +53,6 @@ pub struct WindowRule { pub location: Option<(i32, i32)>, } -#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)] -pub enum AccelProfile { - Flat, - Adaptive, -} - -#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)] -pub enum ClickMethod { - ButtonAreas, - Clickfinger, -} - -#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)] -pub enum ScrollMethod { - NoScroll, - TwoFinger, - Edge, - OnButtonDown, -} - -#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)] -pub enum TapButtonMap { - LeftRightMiddle, - LeftMiddleRight, -} - -#[derive(Debug, PartialEq, Copy, Clone, serde::Serialize)] -pub enum LibinputSetting { - AccelProfile(AccelProfile), - AccelSpeed(f64), - CalibrationMatrix([f32; 6]), - ClickMethod(ClickMethod), - DisableWhileTypingEnabled(bool), - LeftHanded(bool), - MiddleEmulationEnabled(bool), - RotationAngle(u32), - ScrollMethod(ScrollMethod), - NaturalScrollEnabled(bool), - ScrollButton(u32), - TapButtonMap(TapButtonMap), - TapDragEnabled(bool), - TapDragLockEnabled(bool), - TapEnabled(bool), -} - #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub struct RequestId(pub u32); @@ -166,6 +122,7 @@ pub(crate) enum Msg { output_name: OutputName, tag_names: Vec, }, + // TODO: RemoveTags { /// The name of the output you want these tags removed from. tag_ids: Vec,