mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Add action to switch layouts
Allow users to trigger layout change with custom bindings.
This commit is contained in:
committed by
Ivan Molodetskikh
parent
195ca80c39
commit
eb7d20c638
@@ -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.)]
|
||||
|
||||
+12
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user