mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
input: Add Super+F to fullscreen
This commit is contained in:
@@ -7,8 +7,10 @@ use smithay::backend::input::{
|
|||||||
};
|
};
|
||||||
use smithay::input::keyboard::{keysyms, FilterResult};
|
use smithay::input::keyboard::{keysyms, FilterResult};
|
||||||
use smithay::input::pointer::{AxisFrame, ButtonEvent, MotionEvent, RelativeMotionEvent};
|
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::reexports::wayland_server::protocol::wl_surface::WlSurface;
|
||||||
use smithay::utils::SERIAL_COUNTER;
|
use smithay::utils::SERIAL_COUNTER;
|
||||||
|
use smithay::wayland::shell::xdg::XdgShellHandler;
|
||||||
|
|
||||||
use crate::niri::Niri;
|
use crate::niri::Niri;
|
||||||
|
|
||||||
@@ -17,6 +19,7 @@ enum InputAction {
|
|||||||
ChangeVt(i32),
|
ChangeVt(i32),
|
||||||
SpawnTerminal,
|
SpawnTerminal,
|
||||||
CloseWindow,
|
CloseWindow,
|
||||||
|
ToggleFullscreen,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Niri {
|
impl Niri {
|
||||||
@@ -58,6 +61,9 @@ impl Niri {
|
|||||||
keysyms::KEY_q if mods.logo => {
|
keysyms::KEY_q if mods.logo => {
|
||||||
FilterResult::Intercept(InputAction::CloseWindow)
|
FilterResult::Intercept(InputAction::CloseWindow)
|
||||||
}
|
}
|
||||||
|
keysyms::KEY_f if mods.logo => {
|
||||||
|
FilterResult::Intercept(InputAction::ToggleFullscreen)
|
||||||
|
}
|
||||||
_ => FilterResult::Forward,
|
_ => FilterResult::Forward,
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user