aboutsummaryrefslogtreecommitdiff
path: root/src/layout/workspace.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-12-29 10:39:21 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-12-30 20:12:37 +0300
commit3c2e1554c6f1fe0d7d96094aa93f72f4ced613e5 (patch)
tree9b3c883f1f3256e49250bb5c26716ebcf1a38bba /src/layout/workspace.rs
parent744955ba69176a0e2937f18958908274583223d4 (diff)
downloadniri-3c2e1554c6f1fe0d7d96094aa93f72f4ced613e5.tar.gz
niri-3c2e1554c6f1fe0d7d96094aa93f72f4ced613e5.tar.bz2
niri-3c2e1554c6f1fe0d7d96094aa93f72f4ced613e5.zip
Add default-floating-position window rule
Diffstat (limited to 'src/layout/workspace.rs')
-rw-r--r--src/layout/workspace.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index e67b4e76..aef7203b 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -1123,7 +1123,9 @@ impl<W: LayoutElement> Workspace<W> {
removed.tile.stop_move_animations();
// Come up with a default floating position close to the tile position.
- if removed.tile.floating_pos.is_none() {
+ if removed.tile.floating_pos.is_none()
+ && removed.tile.default_floating_logical_pos().is_none()
+ {
let offset = if self.options.center_focused_column == CenterFocusedColumn::Always {
Point::from((0., 0.))
} else {
@@ -1214,17 +1216,26 @@ impl<W: LayoutElement> Workspace<W> {
};
let working_area_loc = self.floating.working_area().loc;
+ let pos = tile
+ .floating_pos
+ .map(|pos| self.floating.scale_by_working_area(pos));
+ let pos = pos.or_else(|| {
+ tile.default_floating_logical_pos()
+ .map(|pos| pos + working_area_loc)
+ });
+
// If there's no stored floating position, we can only set both components at once, not
// adjust.
- let Some(pos) = tile.floating_pos.or_else(|| {
+ let pos = pos.or_else(|| {
(matches!(x, PositionChange::SetFixed(_))
&& matches!(y, PositionChange::SetFixed(_)))
.then_some(Point::default())
- }) else {
+ });
+
+ let Some(mut pos) = pos else {
return;
};
- let mut pos = self.floating.scale_by_working_area(pos);
match x {
PositionChange::SetFixed(x) => pos.x = x + working_area_loc.x,
PositionChange::AdjustFixed(x) => pos.x += x,