ei: add support for libei
This commit is contained in:
parent
084fe50259
commit
40e87f8f91
69 changed files with 4340 additions and 72 deletions
|
|
@ -299,6 +299,11 @@ pub struct Tearing {
|
|||
pub mode: Option<TearingMode>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Libei {
|
||||
pub enable_socket: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Shortcut {
|
||||
pub mask: Modifiers,
|
||||
|
|
@ -334,6 +339,7 @@ pub struct Config {
|
|||
pub window_management_key: Option<ModifiedKeySym>,
|
||||
pub vrr: Option<Vrr>,
|
||||
pub tearing: Option<Tearing>,
|
||||
pub libei: Libei,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ mod idle;
|
|||
mod input;
|
||||
mod input_match;
|
||||
pub mod keymap;
|
||||
mod libei;
|
||||
mod log_level;
|
||||
mod mode;
|
||||
pub mod modified_keysym;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use {
|
|||
idle::IdleParser,
|
||||
input::InputsParser,
|
||||
keymap::KeymapParser,
|
||||
libei::LibeiParser,
|
||||
log_level::LogLevelParser,
|
||||
output::OutputsParser,
|
||||
repeat_rate::RepeatRateParser,
|
||||
|
|
@ -27,7 +28,7 @@ use {
|
|||
vrr::VrrParser,
|
||||
},
|
||||
spanned::SpannedErrorExt,
|
||||
Action, Config, Theme,
|
||||
Action, Config, Libei, Theme,
|
||||
},
|
||||
toml::{
|
||||
toml_span::{DespanExt, Span, Spanned},
|
||||
|
|
@ -110,6 +111,7 @@ impl Parser for ConfigParser<'_> {
|
|||
window_management_key_val,
|
||||
vrr_val,
|
||||
tearing_val,
|
||||
libei_val,
|
||||
),
|
||||
) = ext.extract((
|
||||
(
|
||||
|
|
@ -144,6 +146,7 @@ impl Parser for ConfigParser<'_> {
|
|||
recover(opt(str("window-management-key"))),
|
||||
opt(val("vrr")),
|
||||
opt(val("tearing")),
|
||||
opt(val("libei")),
|
||||
),
|
||||
))?;
|
||||
let mut keymap = None;
|
||||
|
|
@ -326,6 +329,15 @@ impl Parser for ConfigParser<'_> {
|
|||
}
|
||||
}
|
||||
}
|
||||
let mut libei = Libei::default();
|
||||
if let Some(value) = libei_val {
|
||||
match value.parse(&mut LibeiParser(self.0)) {
|
||||
Ok(v) => libei = v,
|
||||
Err(e) => {
|
||||
log::warn!("Could not parse libei setting: {}", self.0.error(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Config {
|
||||
keymap,
|
||||
repeat_rate,
|
||||
|
|
@ -352,6 +364,7 @@ impl Parser for ConfigParser<'_> {
|
|||
window_management_key,
|
||||
vrr,
|
||||
tearing,
|
||||
libei,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
44
toml-config/src/config/parsers/libei.rs
Normal file
44
toml-config/src/config/parsers/libei.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
use {
|
||||
crate::{
|
||||
config::{
|
||||
context::Context,
|
||||
extractor::{bol, opt, recover, Extractor, ExtractorError},
|
||||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
Libei,
|
||||
},
|
||||
toml::{
|
||||
toml_span::{DespanExt, Span, Spanned},
|
||||
toml_value::Value,
|
||||
},
|
||||
},
|
||||
indexmap::IndexMap,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum LibeiParserError {
|
||||
#[error(transparent)]
|
||||
Expected(#[from] UnexpectedDataType),
|
||||
#[error(transparent)]
|
||||
Extract(#[from] ExtractorError),
|
||||
}
|
||||
|
||||
pub struct LibeiParser<'a>(pub &'a Context<'a>);
|
||||
|
||||
impl Parser for LibeiParser<'_> {
|
||||
type Value = Libei;
|
||||
type Error = LibeiParserError;
|
||||
const EXPECTED: &'static [DataType] = &[DataType::Table];
|
||||
|
||||
fn parse_table(
|
||||
&mut self,
|
||||
span: Span,
|
||||
table: &IndexMap<Spanned<String>, Spanned<Value>>,
|
||||
) -> ParseResult<Self> {
|
||||
let mut ext = Extractor::new(self.0, span, table);
|
||||
let enable_socket = ext.extract(recover(opt(bol("enable-socket"))))?;
|
||||
Ok(Libei {
|
||||
enable_socket: enable_socket.despan(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,8 @@ use {
|
|||
get_workspace,
|
||||
input::{
|
||||
capability::CAP_SWITCH, get_seat, input_devices, on_input_device_removed,
|
||||
on_new_input_device, FocusFollowsMouseMode, InputDevice, Seat, SwitchEvent,
|
||||
on_new_input_device, set_libei_socket_enabled, FocusFollowsMouseMode, InputDevice,
|
||||
Seat, SwitchEvent,
|
||||
},
|
||||
is_reload,
|
||||
keyboard::{Keymap, ModifiedKeySym},
|
||||
|
|
@ -1047,6 +1048,7 @@ fn load_config(initial_load: bool, persistent: &Rc<PersistentState>) {
|
|||
set_tearing_mode(mode);
|
||||
}
|
||||
}
|
||||
set_libei_socket_enabled(config.libei.enable_socket.unwrap_or(false));
|
||||
}
|
||||
|
||||
fn create_command(exec: &Exec) -> Command {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue