aboutsummaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-08-11 10:47:03 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-08-11 10:47:03 +0400
commitf734cb0129a804c4e9c0f20a6c5318554969730d (patch)
treee5fd1297848d97ab2f68a828463e2df0be1ee28b /src/input.rs
parent91a809b755977f57c1c1fc0da09dfc1cd2483d87 (diff)
downloadniri-f734cb0129a804c4e9c0f20a6c5318554969730d.tar.gz
niri-f734cb0129a804c4e9c0f20a6c5318554969730d.tar.bz2
niri-f734cb0129a804c4e9c0f20a6c5318554969730d.zip
input: Add Super+F to fullscreen
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/input.rs b/src/input.rs
index f3627618..aa03a593 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -7,8 +7,10 @@ use smithay::backend::input::{
};
use smithay::input::keyboard::{keysyms, FilterResult};
use smithay::input::pointer::{AxisFrame, ButtonEvent, MotionEvent, RelativeMotionEvent};
+use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
use smithay::utils::SERIAL_COUNTER;
+use smithay::wayland::shell::xdg::XdgShellHandler;
use crate::niri::Niri;
@@ -17,6 +19,7 @@ enum InputAction {
ChangeVt(i32),
SpawnTerminal,
CloseWindow,
+ ToggleFullscreen,
}
impl Niri {
@@ -58,6 +61,9 @@ impl Niri {
keysyms::KEY_q if mods.logo => {
FilterResult::Intercept(InputAction::CloseWindow)
}
+ keysyms::KEY_f if mods.logo => {
+ FilterResult::Intercept(InputAction::ToggleFullscreen)
+ }
_ => FilterResult::Forward,
}
} else {
@@ -97,6 +103,32 @@ impl Niri {
}
}
}
+ InputAction::ToggleFullscreen => {
+ if let Some(focus) = self.seat.get_keyboard().unwrap().current_focus() {
+ // FIXME: is there a better way of doing this?
+ let window = self.space.elements().find(|window| {
+ let found = Cell::new(false);
+ window.with_surfaces(|surface, _| {
+ if surface == &focus {
+ found.set(true);
+ }
+ });
+ found.get()
+ });
+ if let Some(window) = window {
+ let toplevel = window.toplevel().clone();
+ if toplevel
+ .current_state()
+ .states
+ .contains(xdg_toplevel::State::Fullscreen)
+ {
+ self.unfullscreen_request(toplevel);
+ } else {
+ self.fullscreen_request(toplevel, None);
+ }
+ }
+ }
+ }
}
}
}