diff --git a/src/config/key_bindings.rs b/src/config/key_bindings.rs index f4fd85bc..bf4c39ec 100644 --- a/src/config/key_bindings.rs +++ b/src/config/key_bindings.rs @@ -182,6 +182,7 @@ pub enum Action { ToggleStacking, ToggleTiling, ToggleWindowFloating, + ToggleSticky, SwapWindow, Resizing(ResizeDirection), diff --git a/src/input/mod.rs b/src/input/mod.rs index 7d050d23..9bb3ecba 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -2134,6 +2134,10 @@ impl State { let workspace = self.common.shell.active_space_mut(&output); workspace.toggle_floating_window_focused(seat); } + Action::ToggleSticky => { + let seats = self.common.seats().cloned().collect::>(); + self.common.shell.toggle_sticky_current(seats.iter(), seat); + } Action::Spawn(command) => { let (token, data) = self .common diff --git a/src/shell/mod.rs b/src/shell/mod.rs index e892b3dd..5b92931b 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -2360,6 +2360,19 @@ impl Shell { } } + pub fn toggle_sticky_current<'a>( + &mut self, + seats: impl Iterator>, + seat: &Seat, + ) { + let set = self.workspaces.sets.get_mut(&seat.active_output()).unwrap(); + let workspace = &mut set.workspaces[set.active]; + let maybe_window = workspace.focus_stack.get(seat).iter().next().cloned(); + if let Some(mapped) = maybe_window { + self.toggle_sticky(seats, seat, &mapped); + } + } + pub(crate) fn set_theme(&mut self, theme: cosmic::Theme) { self.theme = theme.clone(); self.refresh();