aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/layout/floating.rs29
-rw-r--r--src/layout/workspace.rs24
2 files changed, 45 insertions, 8 deletions
diff --git a/src/layout/floating.rs b/src/layout/floating.rs
index c3cf8831..2d7d0457 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<W: LayoutElement> {
@@ -691,6 +694,32 @@ impl<W: LayoutElement> FloatingSpace<W> {
}
}
+ fn move_by(&mut self, amount: Point<f64, Logical>) {
+ 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 46ed669e..b5d0f894 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -840,16 +840,20 @@ impl<W: LayoutElement> Workspace<W> {
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<W: LayoutElement> Workspace<W> {
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>) {