seat: Use user-provided xkb-config

This commit is contained in:
Victoria Brekenfeld 2022-07-29 14:23:23 +02:00
parent 6966305ad4
commit 7708cdc1a2
4 changed files with 23 additions and 7 deletions

View file

@ -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;

View file

@ -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<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;

View file

@ -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<State> {
pub fn add_seat(dh: &DisplayHandle, config: &Config, name: String) -> Seat<State> {
let mut seat = Seat::<State>::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<State> {
// 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| {

View file

@ -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));