Extract to_xkb_config() to a method
Browse files at this commit11ae17b220dfb454c524fff800f97bc11c3a56ddParent: 40b633b2 changed files +17 -12
- src/config.rs +13 -1
- src/niri.rs +4 -11
src/config.rsmodified+13 -1
| @@ -6,7 +6,7 @@ use directories::ProjectDirs; | |||
| 6 | use miette::{miette, Context, IntoDiagnostic}; | 6 | use miette::{miette, Context, IntoDiagnostic}; |
| 7 | use smithay::input::keyboard::keysyms::KEY_NoSymbol; | 7 | use smithay::input::keyboard::keysyms::KEY_NoSymbol; |
| 8 | use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE}; | 8 | use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE}; |
| 9 | -use smithay::input::keyboard::Keysym; | 9 | +use smithay::input::keyboard::{Keysym, XkbConfig}; |
| 10 | 10 | ||
| 11 | #[derive(knuffel::Decode, Debug, PartialEq)] | 11 | #[derive(knuffel::Decode, Debug, PartialEq)] |
| 12 | pub struct Config { | 12 | pub struct Config { |
| @@ -80,6 +80,18 @@ pub struct Xkb { | |||
| 80 | pub options: Option<String>, | 80 | pub options: Option<String>, |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | +impl Xkb { | ||
| 84 | + pub fn to_xkb_config(&self) -> XkbConfig { | ||
| 85 | + XkbConfig { | ||
| 86 | + rules: &self.rules, | ||
| 87 | + model: &self.model, | ||
| 88 | + layout: self.layout.as_deref().unwrap_or("us"), | ||
| 89 | + variant: &self.variant, | ||
| 90 | + options: self.options.clone(), | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | +} | ||
| 94 | + | ||
| 83 | #[derive(knuffel::DecodeScalar, Debug, Default, PartialEq, Eq)] | 95 | #[derive(knuffel::DecodeScalar, Debug, Default, PartialEq, Eq)] |
| 84 | pub enum TrackLayout { | 96 | pub enum TrackLayout { |
| 85 | /// The layout change is global. | 97 | /// The layout change is global. |
src/niri.rsmodified+4 -11
| @@ -32,7 +32,7 @@ use smithay::desktop::utils::{ | |||
| 32 | use smithay::desktop::{ | 32 | use smithay::desktop::{ |
| 33 | layer_map_for_output, LayerSurface, PopupManager, Space, Window, WindowSurfaceType, | 33 | layer_map_for_output, LayerSurface, PopupManager, Space, Window, WindowSurfaceType, |
| 34 | }; | 34 | }; |
| 35 | -use smithay::input::keyboard::{Layout as KeyboardLayout, XkbConfig, XkbContextHandler}; | 35 | +use smithay::input::keyboard::{Layout as KeyboardLayout, XkbContextHandler}; |
| 36 | use smithay::input::pointer::{CursorIcon, CursorImageAttributes, CursorImageStatus, MotionEvent}; | 36 | use smithay::input::pointer::{CursorIcon, CursorImageAttributes, CursorImageStatus, MotionEvent}; |
| 37 | use smithay::input::{Seat, SeatState}; | 37 | use smithay::input::{Seat, SeatState}; |
| 38 | use smithay::output::Output; | 38 | use smithay::output::Output; |
| @@ -633,17 +633,10 @@ impl Niri { | |||
| 633 | VirtualKeyboardManagerState::new::<State, _>(&display_handle, |_| true); | 633 | VirtualKeyboardManagerState::new::<State, _>(&display_handle, |_| true); |
| 634 | 634 | ||
| 635 | let mut seat: Seat<State> = seat_state.new_wl_seat(&display_handle, backend.seat_name()); | 635 | let mut seat: Seat<State> = seat_state.new_wl_seat(&display_handle, backend.seat_name()); |
| 636 | - let xkb = XkbConfig { | ||
| 637 | - rules: &config_.input.keyboard.xkb.rules, | ||
| 638 | - model: &config_.input.keyboard.xkb.model, | ||
| 639 | - layout: config_.input.keyboard.xkb.layout.as_deref().unwrap_or("us"), | ||
| 640 | - variant: &config_.input.keyboard.xkb.variant, | ||
| 641 | - options: config_.input.keyboard.xkb.options.clone(), | ||
| 642 | - }; | ||
| 643 | seat.add_keyboard( | 636 | seat.add_keyboard( |
| 644 | - xkb, | 637 | + config_.input.keyboard.xkb.to_xkb_config(), |
| 645 | - config_.input.keyboard.repeat_delay as i32, | 638 | + config_.input.keyboard.repeat_delay.into(), |
| 646 | - config_.input.keyboard.repeat_rate as i32, | 639 | + config_.input.keyboard.repeat_rate.into(), |
| 647 | ) | 640 | ) |
| 648 | .unwrap(); | 641 | .unwrap(); |
| 649 | seat.add_pointer(); | 642 | seat.add_pointer(); |