diff --git a/src/layout/floating.rs b/src/layout/floating.rs index 8cdfb02ed..8a69e55d8 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -22,6 +22,9 @@ use crate::utils::{ }; use crate::window::ResolvedWindowRules; +/// By how many logical pixels the directional move commands move floating windows. +const DIRECTIONAL_MOVE_PX: f64 = 50.; + /// Space for floating windows. #[derive(Debug)] pub struct FloatingSpace { @@ -689,6 +692,32 @@ impl FloatingSpace { } } + fn move_by(&mut self, amount: Point) { + let Some(active_id) = &self.active_window_id else { + return; + }; + let active_idx = self.idx_of(active_id).unwrap(); + + let new_pos = self.data[active_idx].logical_pos + amount; + self.move_and_animate(active_idx, new_pos); + } + + pub fn move_left(&mut self) { + self.move_by(Point::from((-DIRECTIONAL_MOVE_PX, 0.))); + } + + pub fn move_right(&mut self) { + self.move_by(Point::from((DIRECTIONAL_MOVE_PX, 0.))); + } + + pub fn move_up(&mut self) { + self.move_by(Point::from((0., -DIRECTIONAL_MOVE_PX))); + } + + pub fn move_down(&mut self) { + self.move_by(Point::from((0., DIRECTIONAL_MOVE_PX))); + } + pub fn center_window(&mut self) { let Some(active_id) = &self.active_window_id else { return; diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 46ed669e2..b5d0f894d 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -840,16 +840,20 @@ impl Workspace { pub fn move_left(&mut self) -> bool { if self.floating_is_active { - return true; + self.floating.move_left(); + true + } else { + self.scrolling.move_left() } - self.scrolling.move_left() } pub fn move_right(&mut self) -> bool { if self.floating_is_active { - return true; + self.floating.move_right(); + true + } else { + self.scrolling.move_right() } - self.scrolling.move_right() } pub fn move_column_to_first(&mut self) { @@ -868,16 +872,20 @@ impl Workspace { pub fn move_down(&mut self) -> bool { if self.floating_is_active { - return true; + self.floating.move_down(); + true + } else { + self.scrolling.move_down() } - self.scrolling.move_down() } pub fn move_up(&mut self) -> bool { if self.floating_is_active { - return true; + self.floating.move_up(); + true + } else { + self.scrolling.move_up() } - self.scrolling.move_up() } pub fn consume_or_expel_window_left(&mut self, window: Option<&W::Id>) {