Add libinput stuff

This commit is contained in:
Ottatop 2023-10-19 20:51:45 -05:00
parent 8fd50eff5a
commit fc7132c0e4
4 changed files with 66 additions and 47 deletions

View file

@ -1,3 +1,5 @@
pub mod libinput;
use xkbcommon::xkb::Keysym; use xkbcommon::xkb::Keysym;
use crate::{ use crate::{
@ -5,7 +7,11 @@ use crate::{
send_msg, CALLBACK_VEC, send_msg, CALLBACK_VEC,
}; };
pub struct Input; use self::libinput::Libinput;
pub struct Input {
pub libinput: Libinput,
}
impl Input { impl Input {
/// Set a keybind. /// Set a keybind.

View file

@ -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),
}

View file

@ -9,6 +9,7 @@ mod process;
mod tag; mod tag;
mod window; mod window;
use input::libinput::Libinput;
use input::Input; use input::Input;
pub use input::Modifier; pub use input::Modifier;
pub use input::MouseButton; pub use input::MouseButton;
@ -53,7 +54,7 @@ pub fn setup(config_func: impl FnOnce(Pinnacle)) -> anyhow::Result<()> {
let pinnacle = Pinnacle { let pinnacle = Pinnacle {
process: Process, process: Process,
input: Input, input: Input { libinput: Libinput },
window: Window { rules: WindowRules }, window: Window { rules: WindowRules },
output: Output, output: Output,
tag: Tag, tag: Tag,

View file

@ -1,6 +1,7 @@
use std::num::NonZeroU32; use std::num::NonZeroU32;
use crate::{ use crate::{
input::libinput::LibinputSetting,
output::OutputName, output::OutputName,
tag::{Layout, TagId}, tag::{Layout, TagId},
window::{FloatingOrTiled, FullscreenOrMaximized, WindowId}, window::{FloatingOrTiled, FullscreenOrMaximized, WindowId},
@ -52,51 +53,6 @@ pub struct WindowRule {
pub location: Option<(i32, i32)>, 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)] #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct RequestId(pub u32); pub struct RequestId(pub u32);
@ -166,6 +122,7 @@ pub(crate) enum Msg {
output_name: OutputName, output_name: OutputName,
tag_names: Vec<String>, tag_names: Vec<String>,
}, },
// TODO:
RemoveTags { RemoveTags {
/// The name of the output you want these tags removed from. /// The name of the output you want these tags removed from.
tag_ids: Vec<TagId>, tag_ids: Vec<TagId>,