diff --git a/src/config/mod.rs b/src/config/mod.rs index d3e18ffe..b9ddd073 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -373,6 +373,10 @@ impl Config { .insert(infos, configs); } + pub fn xkb_config(&self) -> XkbConfig { + self.dynamic_conf.inputs().xkb.clone() + } + pub fn read_device(&mut self, device: &mut InputDevice) { use std::collections::hash_map::Entry; diff --git a/src/config/types.rs b/src/config/types.rs index f6ec3199..79ed4ff3 100644 --- a/src/config/types.rs +++ b/src/config/types.rs @@ -9,12 +9,12 @@ pub use smithay::{ utils::{Logical, Physical, Point, Size, Transform}, wayland::{ output::{Mode, Output}, - seat::{keysyms as KeySyms, Keysym, ModifiersState as KeyModifiers}, + seat::{keysyms as KeySyms, Keysym, ModifiersState as KeyModifiers, XkbConfig as WlXkbConfig}, }, }; use xkbcommon::xkb; -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct XkbConfig { pub rules: String, pub model: String, @@ -35,6 +35,18 @@ impl Default for XkbConfig { } } +impl<'a> Into> 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; diff --git a/src/input/mod.rs b/src/input/mod.rs index 52beaa22..29e4ddb7 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only use crate::{ - config::Action, + config::{Action, Config}, shell::{ Workspace, grabs::SeatMoveGrabState, @@ -19,7 +19,6 @@ use smithay::{ primary_selection::set_primary_focus, seat::{ keysyms, ButtonEvent, CursorImageStatus, FilterResult, KeysymHandle, MotionEvent, Seat, - XkbConfig, }, shell::wlr_layer::Layer as WlrLayer, SERIAL_COUNTER, @@ -99,7 +98,7 @@ impl Devices { } } -pub fn add_seat(dh: &DisplayHandle, name: String) -> Seat { +pub fn add_seat(dh: &DisplayHandle, config: &Config, name: String) -> Seat { let mut seat = Seat::::new(dh, name, None); let userdata = seat.user_data(); userdata.insert_if_missing(SeatId::default); @@ -118,8 +117,9 @@ pub fn add_seat(dh: &DisplayHandle, name: String) -> Seat { // So instead of doing the right thing (and initialize these capabilities as matching // devices appear), we have to surrender to reality and just always expose a keyboard and pointer. let dh_clone = dh.clone(); + let conf = config.xkb_config(); let _ = seat.add_keyboard( - XkbConfig::default(), + (&conf).into(), 200, 25, move |seat, focus| { diff --git a/src/state.rs b/src/state.rs index d6c9853f..a9767129 100644 --- a/src/state.rs +++ b/src/state.rs @@ -277,7 +277,7 @@ impl State { let wl_drm_state = WlDrmState; let shell = Shell::new(&config, dh); - let initial_seat = crate::input::add_seat(dh, "seat-0".into()); + let initial_seat = crate::input::add_seat(dh, &config, "seat-0".into()); #[cfg(not(feature = "debug"))] let dirty_flag = Arc::new(AtomicBool::new(false));