diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-10 17:50:53 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-10 17:50:53 +0400 |
| commit | db3c030fdd137fdf27239e673ad215e96a280fb3 (patch) | |
| tree | 1947337a8b8c9ae866468179215fea04f64557c2 | |
| parent | b6a4570a432335289ed66cf865ca3a4b3e4a1d10 (diff) | |
| download | niri-db3c030fdd137fdf27239e673ad215e96a280fb3.tar.gz niri-db3c030fdd137fdf27239e673ad215e96a280fb3.tar.bz2 niri-db3c030fdd137fdf27239e673ad215e96a280fb3.zip | |
Add Super+q to quit the current toplevel
| -rw-r--r-- | src/input.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/input.rs b/src/input.rs index 4fcfa98c..6d8a6f2b 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,3 +1,4 @@ +use std::cell::Cell; use std::process::Command; use smithay::backend::input::{ @@ -15,6 +16,7 @@ enum InputAction { Quit, ChangeVt(i32), SpawnTerminal, + CloseWindow, } impl Niri { @@ -51,6 +53,9 @@ impl Niri { keysyms::KEY_t if mods.logo => { FilterResult::Intercept(InputAction::SpawnTerminal) } + keysyms::KEY_q if mods.logo => { + FilterResult::Intercept(InputAction::CloseWindow) + } _ => FilterResult::Forward, } } else { @@ -73,6 +78,23 @@ impl Niri { warn!("error spawning alacritty: {err}"); } } + InputAction::CloseWindow => { + if let Some(focus) = self.seat.get_keyboard().unwrap().current_focus() { + // FIXME: is there a better way of doing this? + for window in self.space.elements() { + let found = Cell::new(false); + window.with_surfaces(|surface, _| { + if surface == &focus { + found.set(true); + } + }); + if found.get() { + window.toplevel().send_close(); + break; + } + } + } + } } } } |
