input: Add fullscreen shortcut
This commit is contained in:
parent
adedb705e7
commit
33044d9efb
4 changed files with 50 additions and 1 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -943,7 +943,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-settings-config"
|
name = "cosmic-settings-config"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
"ron",
|
"ron",
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@
|
||||||
(modifiers: [Super], key: "x"): SwapWindow,
|
(modifiers: [Super], key: "x"): SwapWindow,
|
||||||
|
|
||||||
(modifiers: [Super], key: "m"): Maximize,
|
(modifiers: [Super], key: "m"): Maximize,
|
||||||
|
(modifiers: [Super], key: "F11"): Fullscreen,
|
||||||
(modifiers: [Super], key: "r"): Resizing(Outwards),
|
(modifiers: [Super], key: "r"): Resizing(Outwards),
|
||||||
(modifiers: [Super, Shift], key: "r"): Resizing(Inwards),
|
(modifiers: [Super, Shift], key: "r"): Resizing(Inwards),
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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(
|
Action::Resizing(direction) => self.common.shell.write().set_resize_mode(
|
||||||
Some((pattern, direction)),
|
Some((pattern, direction)),
|
||||||
&self.common.config,
|
&self.common.config,
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,7 @@ pub fn window_items(
|
||||||
) -> impl Iterator<Item = Item> {
|
) -> impl Iterator<Item = Item> {
|
||||||
let minimize_clone = window.clone();
|
let minimize_clone = window.clone();
|
||||||
let maximize_clone = window.clone();
|
let maximize_clone = window.clone();
|
||||||
|
let fullscreen_clone = window.clone();
|
||||||
let tile_clone = window.clone();
|
let tile_clone = window.clone();
|
||||||
let move_prev_clone = window.clone();
|
let move_prev_clone = window.clone();
|
||||||
let move_next_clone = window.clone();
|
let move_next_clone = window.clone();
|
||||||
|
|
@ -290,6 +291,26 @@ pub fn window_items(
|
||||||
.shortcut(config.shortcut_for_action(&Action::Maximize))
|
.shortcut(config.shortcut_for_action(&Action::Maximize))
|
||||||
.toggled(window.is_maximized(false)),
|
.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(
|
(tiling_enabled && !is_sticky).then_some(
|
||||||
Item::new(fl!("window-menu-tiled"), move |handle| {
|
Item::new(fl!("window-menu-tiled"), move |handle| {
|
||||||
let tile_clone = tile_clone.clone();
|
let tile_clone = tile_clone.clone();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue