input: Add keybindings for toggling tiling

This commit is contained in:
Victoria Brekenfeld 2022-07-07 22:45:04 +02:00
parent 06da5cc9b6
commit 022267c6f6
3 changed files with 17 additions and 3 deletions

View file

@ -2,7 +2,7 @@
key_bindings: { key_bindings: {
(modifiers: [Logo, Shift], key: "Escape"): Terminate, (modifiers: [Logo, Shift], key: "Escape"): Terminate,
(modifiers: [Logo], key: "Escape"): Debug, (modifiers: [Logo], key: "Escape"): Debug,
(modifiers: [Logo], key: "Q"): Close, (modifiers: [Logo], key: "q"): Close,
(modifiers: [Logo], key: "1"): Workspace(1), (modifiers: [Logo], key: "1"): Workspace(1),
(modifiers: [Logo], key: "2"): Workspace(2), (modifiers: [Logo], key: "2"): Workspace(2),
(modifiers: [Logo], key: "3"): Workspace(3), (modifiers: [Logo], key: "3"): Workspace(3),
@ -31,9 +31,11 @@
(modifiers: [Logo], key: "j"): Focus(Down), (modifiers: [Logo], key: "j"): Focus(Down),
(modifiers: [Logo], key: "k"): Focus(Up), (modifiers: [Logo], key: "k"): Focus(Up),
(modifiers: [Logo], key: "l"): Focus(Right), (modifiers: [Logo], key: "l"): Focus(Right),
//TODO: automatic orientation with Logo+o toggling //TODO: automatic orientation with Logo+o toggling
(modifiers: [Logo], key: "v"): Orientation(Vertical), (modifiers: [Logo], key: "v"): Orientation(Vertical),
(modifiers: [Logo], key: "o"): Orientation(Horizontal), (modifiers: [Logo], key: "o"): Orientation(Horizontal),
(modifiers: [Logo], key: "y"): ToggleTiling,
(modifiers: [Logo], key: "g"): ToggleWindowFloating,
(modifiers: [Logo, Shift], key: "f"): Fullscreen, (modifiers: [Logo, Shift], key: "f"): Fullscreen,
//TODO: ability to select default web browser //TODO: ability to select default web browser
(modifiers: [Logo], key: "b"): Spawn("firefox"), (modifiers: [Logo], key: "b"): Spawn("firefox"),
@ -42,7 +44,7 @@
//TODO: ability to select default terminal //TODO: ability to select default terminal
(modifiers: [Logo], key: "t"): Spawn("gnome-terminal"), (modifiers: [Logo], key: "t"): Spawn("gnome-terminal"),
(modifiers: [Logo], key: "a"): Spawn("xdg-shell-wrapper cosmic-app-library"), (modifiers: [Logo], key: "a"): Spawn("xdg-shell-wrapper cosmic-app-library"),
(modifiers: [Logo], key: "Slash"): Spawn("xdg-shell-wrapper cosmic-launcher"), (modifiers: [Logo], key: "slash"): Spawn("xdg-shell-wrapper cosmic-launcher"),
}, },
workspace_mode: OutputBound, workspace_mode: OutputBound,
) )

View file

@ -749,6 +749,8 @@ pub enum Action {
MoveToWorkspace(u8), MoveToWorkspace(u8),
Focus(FocusDirection), Focus(FocusDirection),
Orientation(crate::shell::layout::Orientation), Orientation(crate::shell::layout::Orientation),
ToggleTiling,
ToggleWindowFloating,
Fullscreen, Fullscreen,
Spawn(String), Spawn(String),
} }

View file

@ -344,6 +344,16 @@ impl State {
focus_stack.iter(), focus_stack.iter(),
); );
} }
Action::ToggleTiling => {
let output = active_output(seat, &self.common);
let workspace = self.common.shell.active_space_mut(&output);
workspace.toggle_tiling(seat);
}
Action::ToggleWindowFloating => {
let output = active_output(seat, &self.common);
let workspace = self.common.shell.active_space_mut(&output);
workspace.toggle_floating_window(seat);
}
Action::Spawn(command) => { Action::Spawn(command) => {
if let Err(err) = std::process::Command::new("/bin/sh") if let Err(err) = std::process::Command::new("/bin/sh")
.arg("-c") .arg("-c")