diff options
| author | Kirill Chibisov <contact@kchibisov.com> | 2023-11-02 00:09:31 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-11-08 19:09:11 +0400 |
| commit | eb7d20c638e8912747ee21a4b8de95dd27bb7aba (patch) | |
| tree | 521ed085c5340a4297f3c3ee98b7b191a95800ef /src | |
| parent | 195ca80c3959c35819ef33d84efd5970321b7614 (diff) | |
| download | niri-eb7d20c638e8912747ee21a4b8de95dd27bb7aba.tar.gz niri-eb7d20c638e8912747ee21a4b8de95dd27bb7aba.tar.bz2 niri-eb7d20c638e8912747ee21a4b8de95dd27bb7aba.zip | |
Add action to switch layouts
Allow users to trigger layout change with custom bindings.
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.rs | 7 | ||||
| -rw-r--r-- | src/input.rs | 13 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs index 1ad27ed7..ac1917bc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -288,6 +288,7 @@ pub enum Action { SwitchPresetColumnWidth, MaximizeColumn, SetColumnWidth(#[knuffel(argument, str)] SizeChange), + SwitchLayout(#[knuffel(argument)] LayoutAction), } #[derive(Debug, Clone, Copy, PartialEq)] @@ -298,6 +299,12 @@ pub enum SizeChange { AdjustProportion(f64), } +#[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq)] +pub enum LayoutAction { + Next, + Prev, +} + #[derive(knuffel::Decode, Debug, PartialEq)] pub struct DebugConfig { #[knuffel(child, unwrap(argument), default = 1.)] diff --git a/src/input.rs b/src/input.rs index b57c4c20..83f186fd 100644 --- a/src/input.rs +++ b/src/input.rs @@ -17,7 +17,7 @@ use smithay::input::pointer::{ use smithay::utils::SERIAL_COUNTER; use smithay::wayland::tablet_manager::{TabletDescriptor, TabletSeatTrait}; -use crate::config::{Action, Binds, Modifiers}; +use crate::config::{Action, Binds, LayoutAction, Modifiers}; use crate::niri::State; use crate::screenshot_ui::ScreenshotUi; use crate::utils::{center, get_monotonic_time, spawn}; @@ -90,6 +90,7 @@ impl State { | Action::ChangeVt(_) | Action::Suspend | Action::PowerOffMonitors + | Action::SwitchLayout(_) ) { return; @@ -186,6 +187,16 @@ impl State { self.niri.layout.toggle_fullscreen(&window); } } + Action::SwitchLayout(action) => { + self.niri + .seat + .get_keyboard() + .unwrap() + .with_kkb_state(self, |mut state| match action { + LayoutAction::Next => state.cycle_next_layout(), + LayoutAction::Prev => state.cycle_prev_layout(), + }); + } Action::MoveColumnLeft => { self.niri.layout.move_left(); // FIXME: granular |
