input: Add fullscreen shortcut

This commit is contained in:
Victoria Brekenfeld 2025-06-25 19:10:55 +02:00 committed by Victoria Brekenfeld
parent adedb705e7
commit 33044d9efb
4 changed files with 50 additions and 1 deletions

2
Cargo.lock generated
View file

@ -943,7 +943,7 @@ dependencies = [
[[package]]
name = "cosmic-settings-config"
version = "0.1.0"
source = "git+https://github.com/pop-os/cosmic-settings-daemon#243c36e9e66dcbec83fa63cb3adaceb3bea166a4"
source = "git+https://github.com/pop-os/cosmic-settings-daemon#54b4418e1e7757d965166ae9dc00c522aebf4451"
dependencies = [
"cosmic-config",
"ron",

View file

@ -86,6 +86,7 @@
(modifiers: [Super], key: "x"): SwapWindow,
(modifiers: [Super], key: "m"): Maximize,
(modifiers: [Super], key: "F11"): Fullscreen,
(modifiers: [Super], key: "r"): Resizing(Outwards),
(modifiers: [Super, Shift], key: "r"): Resizing(Inwards),

View file

@ -868,6 +868,33 @@ impl State {
}
}
Action::Fullscreen => {
let Some(focused_output) = seat.focused_output() else {
return;
};
let mut shell = self.common.shell.write();
let workspace = shell.active_space(&focused_output).unwrap();
let focus_stack = workspace.focus_stack.get(seat);
let focused_window = focus_stack.last().cloned();
match focused_window {
Some(FocusTarget::Window(window)) => {
let output = workspace.output.clone();
if let Some(target) = shell.fullscreen_request(
&window.active_window(),
output,
&self.common.event_loop_handle,
) {
std::mem::drop(shell);
Shell::set_focus(self, Some(&target), seat, Some(serial), true);
}
}
Some(FocusTarget::Fullscreen(surface)) => {
shell.unfullscreen_request(&surface, &self.common.event_loop_handle);
}
_ => {}
}
}
Action::Resizing(direction) => self.common.shell.write().set_resize_mode(
Some((pattern, direction)),
&self.common.config,

View file

@ -233,6 +233,7 @@ pub fn window_items(
) -> impl Iterator<Item = Item> {
let minimize_clone = window.clone();
let maximize_clone = window.clone();
let fullscreen_clone = window.clone();
let tile_clone = window.clone();
let move_prev_clone = window.clone();
let move_next_clone = window.clone();
@ -290,6 +291,26 @@ pub fn window_items(
.shortcut(config.shortcut_for_action(&Action::Maximize))
.toggled(window.is_maximized(false)),
),
Some(
Item::new(fl!("window-menu-fullscreen"), move |handle| {
let mapped = fullscreen_clone.clone();
let _ = handle.insert_idle(move |state| {
let mut shell = state.common.shell.write();
let seat = shell.seats.last_active().clone();
let output = seat.active_output();
if let Some(target) = shell.fullscreen_request(
&mapped.active_window(),
output,
&state.common.event_loop_handle,
) {
std::mem::drop(shell);
Shell::set_focus(state, Some(&target), &seat, None, false);
}
});
})
.shortcut(config.shortcut_for_action(&Action::Fullscreen))
.toggled(false),
),
(tiling_enabled && !is_sticky).then_some(
Item::new(fl!("window-menu-tiled"), move |handle| {
let tile_clone = tile_clone.clone();