mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
Extract to_xkb_config() to a method
This commit is contained in:
+13
-1
@@ -6,7 +6,7 @@ use directories::ProjectDirs;
|
|||||||
use miette::{miette, Context, IntoDiagnostic};
|
use miette::{miette, Context, IntoDiagnostic};
|
||||||
use smithay::input::keyboard::keysyms::KEY_NoSymbol;
|
use smithay::input::keyboard::keysyms::KEY_NoSymbol;
|
||||||
use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE};
|
use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE};
|
||||||
use smithay::input::keyboard::Keysym;
|
use smithay::input::keyboard::{Keysym, XkbConfig};
|
||||||
|
|
||||||
#[derive(knuffel::Decode, Debug, PartialEq)]
|
#[derive(knuffel::Decode, Debug, PartialEq)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
@@ -80,6 +80,18 @@ pub struct Xkb {
|
|||||||
pub options: Option<String>,
|
pub options: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Xkb {
|
||||||
|
pub fn to_xkb_config(&self) -> XkbConfig {
|
||||||
|
XkbConfig {
|
||||||
|
rules: &self.rules,
|
||||||
|
model: &self.model,
|
||||||
|
layout: self.layout.as_deref().unwrap_or("us"),
|
||||||
|
variant: &self.variant,
|
||||||
|
options: self.options.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(knuffel::DecodeScalar, Debug, Default, PartialEq, Eq)]
|
#[derive(knuffel::DecodeScalar, Debug, Default, PartialEq, Eq)]
|
||||||
pub enum TrackLayout {
|
pub enum TrackLayout {
|
||||||
/// The layout change is global.
|
/// The layout change is global.
|
||||||
|
|||||||
+4
-11
@@ -32,7 +32,7 @@ use smithay::desktop::utils::{
|
|||||||
use smithay::desktop::{
|
use smithay::desktop::{
|
||||||
layer_map_for_output, LayerSurface, PopupManager, Space, Window, WindowSurfaceType,
|
layer_map_for_output, LayerSurface, PopupManager, Space, Window, WindowSurfaceType,
|
||||||
};
|
};
|
||||||
use smithay::input::keyboard::{Layout as KeyboardLayout, XkbConfig, XkbContextHandler};
|
use smithay::input::keyboard::{Layout as KeyboardLayout, XkbContextHandler};
|
||||||
use smithay::input::pointer::{CursorIcon, CursorImageAttributes, CursorImageStatus, MotionEvent};
|
use smithay::input::pointer::{CursorIcon, CursorImageAttributes, CursorImageStatus, MotionEvent};
|
||||||
use smithay::input::{Seat, SeatState};
|
use smithay::input::{Seat, SeatState};
|
||||||
use smithay::output::Output;
|
use smithay::output::Output;
|
||||||
@@ -633,17 +633,10 @@ impl Niri {
|
|||||||
VirtualKeyboardManagerState::new::<State, _>(&display_handle, |_| true);
|
VirtualKeyboardManagerState::new::<State, _>(&display_handle, |_| true);
|
||||||
|
|
||||||
let mut seat: Seat<State> = seat_state.new_wl_seat(&display_handle, backend.seat_name());
|
let mut seat: Seat<State> = seat_state.new_wl_seat(&display_handle, backend.seat_name());
|
||||||
let xkb = XkbConfig {
|
|
||||||
rules: &config_.input.keyboard.xkb.rules,
|
|
||||||
model: &config_.input.keyboard.xkb.model,
|
|
||||||
layout: config_.input.keyboard.xkb.layout.as_deref().unwrap_or("us"),
|
|
||||||
variant: &config_.input.keyboard.xkb.variant,
|
|
||||||
options: config_.input.keyboard.xkb.options.clone(),
|
|
||||||
};
|
|
||||||
seat.add_keyboard(
|
seat.add_keyboard(
|
||||||
xkb,
|
config_.input.keyboard.xkb.to_xkb_config(),
|
||||||
config_.input.keyboard.repeat_delay as i32,
|
config_.input.keyboard.repeat_delay.into(),
|
||||||
config_.input.keyboard.repeat_rate as i32,
|
config_.input.keyboard.repeat_rate.into(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
seat.add_pointer();
|
seat.add_pointer();
|
||||||
|
|||||||
Reference in New Issue
Block a user