forge
Explore
Log in

Don't you dare go Hollow

Add Super+q to quit the current toplevel

Browse files at this commit

db3c030fdd137fdf27239e673ad215e96a280fb3Ivan MolodetskikhParent: b6a4570
src/input.rsmodified+22 -0
@@ -1,3 +1,4 @@
1+use std::cell::Cell;
1 use std::process::Command;2 use std::process::Command;
2 3
3 use smithay::backend::input::{4 use smithay::backend::input::{
@@ -15,6 +16,7 @@ enum InputAction {
15 Quit,16 Quit,
16 ChangeVt(i32),17 ChangeVt(i32),
17 SpawnTerminal,18 SpawnTerminal,
19+ CloseWindow,
18 }20 }
19 21
20 impl Niri {22 impl Niri {
@@ -51,6 +53,9 @@ impl Niri {
51 keysyms::KEY_t if mods.logo => {53 keysyms::KEY_t if mods.logo => {
52 FilterResult::Intercept(InputAction::SpawnTerminal)54 FilterResult::Intercept(InputAction::SpawnTerminal)
53 }55 }
56+ keysyms::KEY_q if mods.logo => {
57+ FilterResult::Intercept(InputAction::CloseWindow)
58+ }
54 _ => FilterResult::Forward,59 _ => FilterResult::Forward,
55 }60 }
56 } else {61 } else {
@@ -73,6 +78,23 @@ impl Niri {
73 warn!("error spawning alacritty: {err}");78 warn!("error spawning alacritty: {err}");
74 }79 }
75 }80 }
81+ InputAction::CloseWindow => {
82+ if let Some(focus) = self.seat.get_keyboard().unwrap().current_focus() {
83+ // FIXME: is there a better way of doing this?
84+ for window in self.space.elements() {
85+ let found = Cell::new(false);
86+ window.with_surfaces(|surface, _| {
87+ if surface == &focus {
88+ found.set(true);
89+ }
90+ });
91+ if found.get() {
92+ window.toplevel().send_close();
93+ break;
94+ }
95+ }
96+ }
97+ }
76 }98 }
77 }99 }
78 }100 }