diff --git a/cosmic-comp-config/src/lib.rs b/cosmic-comp-config/src/lib.rs index 32dbd3f4..5ff1f90a 100644 --- a/cosmic-comp-config/src/lib.rs +++ b/cosmic-comp-config/src/lib.rs @@ -54,6 +54,10 @@ pub struct XkbConfig { pub layout: String, pub variant: String, pub options: Option, + #[serde(default = "default_repeat_delay")] + pub repeat_delay: u32, + #[serde(default = "default_repeat_rate")] + pub repeat_rate: u32, } impl Default for XkbConfig { @@ -64,6 +68,16 @@ impl Default for XkbConfig { layout: String::new(), variant: String::new(), options: None, + repeat_delay: default_repeat_delay(), + repeat_rate: default_repeat_rate(), } } } + +fn default_repeat_rate() -> u32 { + 25 +} + +fn default_repeat_delay() -> u32 { + 600 +} diff --git a/src/config/mod.rs b/src/config/mod.rs index 35d743e2..9f3ea3c5 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -584,6 +584,10 @@ fn config_changed(config: cosmic_config::Config, keys: Vec, state: &mut .collect::>(); for seat in seats.into_iter() { if let Some(keyboard) = seat.get_keyboard() { + keyboard.change_repeat_info( + (value.repeat_rate as i32).abs(), // Negative values are illegal + (value.repeat_delay as i32).abs(), + ); if let Err(err) = keyboard.set_xkb_config(state, xkb_config_to_wl(&value)) { error!(?err, "Failed to load provided xkb config"); // TODO Revert to default? diff --git a/src/shell/seats.rs b/src/shell/seats.rs index f05cf457..1638b751 100644 --- a/src/shell/seats.rs +++ b/src/shell/seats.rs @@ -186,13 +186,21 @@ pub fn create_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 conf = config.xkb_config(); - if let Err(err) = seat.add_keyboard(xkb_config_to_wl(&conf), 600, 25) { + if let Err(err) = seat.add_keyboard( + xkb_config_to_wl(&conf), + (conf.repeat_delay as i32).abs(), + (conf.repeat_rate as i32).abs(), + ) { warn!( ?err, "Failed to load provided xkb config. Trying default...", ); - seat.add_keyboard(XkbConfig::default(), 600, 25) - .expect("Failed to load xkb configuration files"); + seat.add_keyboard( + XkbConfig::default(), + (conf.repeat_delay as i32).abs(), + (conf.repeat_rate as i32).abs(), + ) + .expect("Failed to load xkb configuration files"); } seat.add_pointer(); seat.add_touch();