From baa051891237054f2d4db86d7bcfe0f17440c35f Mon Sep 17 00:00:00 2001 From: Evgeny Zemtsov Date: Sun, 26 Jan 2025 20:09:01 +0100 Subject: Extend switch-layout action to accept layout index (#1045) * Extend switch-layout action to accept layout index * Update src/input/mod.rs --------- Co-authored-by: Ivan Molodetskikh --- src/input/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/input') diff --git a/src/input/mod.rs b/src/input/mod.rs index c2691739..2604fd72 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -17,7 +17,7 @@ use smithay::backend::input::{ TabletToolTipState, TouchEvent, }; use smithay::backend::libinput::LibinputInputBackend; -use smithay::input::keyboard::{keysyms, FilterResult, Keysym, ModifiersState}; +use smithay::input::keyboard::{keysyms, FilterResult, Keysym, Layout, ModifiersState}; use smithay::input::pointer::{ AxisFrame, ButtonEvent, CursorIcon, CursorImageStatus, Focus, GestureHoldBeginEvent, GestureHoldEndEvent, GesturePinchBeginEvent, GesturePinchEndEvent, GesturePinchUpdateEvent, @@ -691,6 +691,14 @@ impl State { keyboard.with_xkb_state(self, |mut state| match action { LayoutSwitchTarget::Next => state.cycle_next_layout(), LayoutSwitchTarget::Prev => state.cycle_prev_layout(), + LayoutSwitchTarget::Index(layout) => { + let num_layouts = state.xkb().lock().unwrap().layouts().count(); + if usize::from(layout) >= num_layouts { + warn!("requested layout doesn't exist") + } else { + state.set_layout(Layout(layout.into())) + } + } }); } Action::MoveColumnLeft => { -- cgit