aboutsummaryrefslogtreecommitdiff
path: root/src/input
diff options
context:
space:
mode:
authorEvgeny Zemtsov <eugene.zemtsov@gmail.com>2025-01-26 20:09:01 +0100
committerGitHub <noreply@github.com>2025-01-26 19:09:01 +0000
commitbaa051891237054f2d4db86d7bcfe0f17440c35f (patch)
tree60931bc4385d6802482a8a9d5b502d1ea3585bee /src/input
parentd665079b84a7af503efc82cca63a351e762d6b11 (diff)
downloadniri-baa051891237054f2d4db86d7bcfe0f17440c35f.tar.gz
niri-baa051891237054f2d4db86d7bcfe0f17440c35f.tar.bz2
niri-baa051891237054f2d4db86d7bcfe0f17440c35f.zip
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 <yalterz@gmail.com>
Diffstat (limited to 'src/input')
-rw-r--r--src/input/mod.rs10
1 files changed, 9 insertions, 1 deletions
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 => {