cosmic-comp-config crate, and default input config
This adds a `input-default` setting, which is used for input settings if a device isn't set in `input-devices`. More awkwardly, it also adds an `input-touchpad` setting, which is used instead of `input-default` for touchpad devices, so we can separate mouse and touchpad settings even though they use the same capability and settings. This no longer sets the input config, and only reads it. If we add a UI for per-device config, we'll need some IPC mechanism to list connected devices. (Assuming cosmic-settings can't use libinput directly for that.) This moves `InputConfig` and `XkbConfig` to a new `cosmic-comp-config` crate, so they can be used in `cosmic-settings`.
This commit is contained in:
parent
0f5d654535
commit
56467755a8
9 changed files with 536 additions and 468 deletions
|
|
@ -13,147 +13,6 @@ pub use smithay::{
|
|||
use tracing::warn;
|
||||
use xkbcommon::xkb;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct XkbConfig {
|
||||
pub rules: String,
|
||||
pub model: String,
|
||||
pub layout: String,
|
||||
pub variant: String,
|
||||
pub options: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for XkbConfig {
|
||||
fn default() -> XkbConfig {
|
||||
XkbConfig {
|
||||
rules: String::new(),
|
||||
model: String::new(),
|
||||
layout: String::new(),
|
||||
variant: String::new(),
|
||||
options: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Into<WlXkbConfig<'a>> for &'a XkbConfig {
|
||||
fn into(self) -> WlXkbConfig<'a> {
|
||||
WlXkbConfig {
|
||||
rules: &self.rules,
|
||||
model: &self.model,
|
||||
layout: &self.layout,
|
||||
variant: &self.variant,
|
||||
options: self.options.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod ClickMethodDef {
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use smithay::reexports::input::ClickMethod as ClickMethodOrig;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum ClickMethod {
|
||||
ButtonAreas,
|
||||
Clickfinger,
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<ClickMethodOrig>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let o = Option::deserialize(deserializer)?;
|
||||
Ok(o.map(|x| match x {
|
||||
ClickMethod::ButtonAreas => ClickMethodOrig::ButtonAreas,
|
||||
ClickMethod::Clickfinger => ClickMethodOrig::Clickfinger,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn serialize<S>(arg: &Option<ClickMethodOrig>, ser: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let arg = match arg {
|
||||
Some(ClickMethodOrig::ButtonAreas) => Some(ClickMethod::ButtonAreas),
|
||||
Some(ClickMethodOrig::Clickfinger) => Some(ClickMethod::Clickfinger),
|
||||
Some(_) | None => None,
|
||||
};
|
||||
Option::serialize(&arg, ser)
|
||||
}
|
||||
}
|
||||
|
||||
pub mod AccelProfileDef {
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use smithay::reexports::input::AccelProfile as AccelProfileOrig;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
enum AccelProfile {
|
||||
Flat,
|
||||
Adaptive,
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<AccelProfileOrig>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let o = Option::deserialize(deserializer)?;
|
||||
Ok(o.map(|x| match x {
|
||||
AccelProfile::Flat => AccelProfileOrig::Flat,
|
||||
AccelProfile::Adaptive => AccelProfileOrig::Adaptive,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn serialize<S>(arg: &Option<AccelProfileOrig>, ser: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let arg = match arg {
|
||||
Some(AccelProfileOrig::Flat) => Some(AccelProfile::Flat),
|
||||
Some(AccelProfileOrig::Adaptive) => Some(AccelProfile::Adaptive),
|
||||
Some(_) | None => None,
|
||||
};
|
||||
Option::serialize(&arg, ser)
|
||||
}
|
||||
}
|
||||
|
||||
pub mod ScrollMethodDef {
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use smithay::reexports::input::ScrollMethod as ScrollMethodOrig;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum ScrollMethod {
|
||||
NoScroll,
|
||||
TwoFinger,
|
||||
Edge,
|
||||
OnButtonDown,
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<ScrollMethodOrig>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let o = Option::deserialize(deserializer)?;
|
||||
Ok(o.map(|x| match x {
|
||||
ScrollMethod::NoScroll => ScrollMethodOrig::NoScroll,
|
||||
ScrollMethod::TwoFinger => ScrollMethodOrig::TwoFinger,
|
||||
ScrollMethod::Edge => ScrollMethodOrig::Edge,
|
||||
ScrollMethod::OnButtonDown => ScrollMethodOrig::OnButtonDown,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn serialize<S>(arg: &Option<ScrollMethodOrig>, ser: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let arg = match arg {
|
||||
Some(ScrollMethodOrig::NoScroll) => Some(ScrollMethod::NoScroll),
|
||||
Some(ScrollMethodOrig::TwoFinger) => Some(ScrollMethod::TwoFinger),
|
||||
Some(ScrollMethodOrig::Edge) => Some(ScrollMethod::Edge),
|
||||
Some(ScrollMethodOrig::OnButtonDown) => Some(ScrollMethod::OnButtonDown),
|
||||
Some(_) | None => None,
|
||||
};
|
||||
Option::serialize(&arg, ser)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(remote = "Transform")]
|
||||
pub enum TransformDef {
|
||||
|
|
@ -167,40 +26,6 @@ pub enum TransformDef {
|
|||
Flipped270,
|
||||
}
|
||||
|
||||
pub mod TapButtonMapDef {
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use smithay::reexports::input::TapButtonMap as TapButtonMapOrig;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum TapButtonMap {
|
||||
LeftRightMiddle,
|
||||
LeftMiddleRight,
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<TapButtonMapOrig>, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let o = Option::deserialize(deserializer)?;
|
||||
Ok(o.map(|x| match x {
|
||||
TapButtonMap::LeftRightMiddle => TapButtonMapOrig::LeftRightMiddle,
|
||||
TapButtonMap::LeftMiddleRight => TapButtonMapOrig::LeftMiddleRight,
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn serialize<S>(arg: &Option<TapButtonMapOrig>, ser: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let arg = match arg {
|
||||
Some(TapButtonMapOrig::LeftRightMiddle) => Some(TapButtonMap::LeftRightMiddle),
|
||||
Some(TapButtonMapOrig::LeftMiddleRight) => Some(TapButtonMap::LeftMiddleRight),
|
||||
Some(_) | None => None,
|
||||
};
|
||||
Option::serialize(&arg, ser)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(transparent)]
|
||||
pub struct KeyModifiersDef(Vec<KeyModifier>);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue