diff --git a/src/input/mod.rs b/src/input/mod.rs index 7529002f..43bed81c 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -1988,10 +1988,7 @@ impl State { } } Action::Move(direction) => { - let current_output = seat.active_output(); - let workspace = self.common.shell.active_space_mut(¤t_output); - - match workspace.move_current_element(direction, seat) { + match self.common.shell.move_current_element(direction, seat) { MoveResult::MoveFurther(_move_further) => self.handle_action( Action::MoveToOutput(direction), seat, @@ -2005,6 +2002,8 @@ impl State { Common::set_focus(self, Some(&shift), seat, None); } _ => { + let current_output = seat.active_output(); + let workspace = self.common.shell.active_space(¤t_output); if let Some(focused_window) = workspace.focus_stack.get(seat).last() { if workspace.is_tiled(focused_window) { self.common.shell.set_overview_mode( diff --git a/src/shell/mod.rs b/src/shell/mod.rs index d0aa4b6d..da21f7a5 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -2360,6 +2360,39 @@ impl Shell { } } + pub fn move_current_element<'a>( + &mut self, + direction: Direction, + seat: &Seat, + ) -> MoveResult { + let output = seat.active_output(); + let workspace = self.active_space(&output); + let focus_stack = workspace.focus_stack.get(seat); + let Some(last) = focus_stack.last().cloned() else { + return MoveResult::None + }; + let fullscreen = workspace.fullscreen.as_ref().map(|f| f.surface.clone()); + + if let Some(surface) = fullscreen { + MoveResult::MoveFurther(KeyboardFocusTarget::Fullscreen(surface)) + } else if let Some(set) = self + .workspaces + .sets + .values_mut() + .find(|set| set.sticky_layer.mapped().any(|m| m == &last)) + { + set.sticky_layer + .move_current_element(direction, seat, self.theme.clone()) + } else { + let theme = self.theme.clone(); + let workspace = self.active_space_mut(&output); + workspace + .floating_layer + .move_current_element(direction, seat, theme) + .or_else(|| workspace.tiling_layer.move_current_node(direction, seat)) + } + } + pub fn menu_resize_request( state: &mut State, mapped: &CosmicMapped, diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index 8917e917..c70e1f8a 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -753,20 +753,6 @@ impl Workspace { }) } - pub fn move_current_element<'a>( - &mut self, - direction: Direction, - seat: &Seat, - ) -> MoveResult { - if let Some(f) = self.fullscreen.as_ref() { - MoveResult::MoveFurther(KeyboardFocusTarget::Fullscreen(f.surface.clone())) - } else { - self.floating_layer - .move_current_element(direction, seat, self.tiling_layer.theme.clone()) - .or_else(|| self.tiling_layer.move_current_node(direction, seat)) - } - } - pub fn render<'a, R>( &self, renderer: &mut R,