From db3c030fdd137fdf27239e673ad215e96a280fb3 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 10 Aug 2023 17:50:53 +0400 Subject: Add Super+q to quit the current toplevel --- src/input.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') 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; + } + } + } + } } } } -- cgit