Skip to content

Commit

Permalink
fix(window-state): restore window positions that matches monitor posi…
Browse files Browse the repository at this point in the history
…tions

closes #892
  • Loading branch information
amrbashir committed Jan 16, 2024
1 parent 83f9899 commit 157f748
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changes/window-state-zero-positions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"window-state": "patch"
---

Fix restoring window positions where `x` or `y` are equal to the monitors `x` or `y` respectively.
17 changes: 7 additions & 10 deletions plugins/window-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,9 @@ impl<R: Runtime> WindowExtInternal for Window<R> {

if flags.contains(StateFlags::POSITION) {
let position = self.outer_position()?;
if let Ok(Some(monitor)) = self.current_monitor() {
// save only window positions that are inside the current monitor
if monitor.contains(position) && !is_maximized {
state.x = position.x;
state.y = position.y;
}
if !is_maximized {
state.x = position.x;
state.y = position.y;
}
}

Expand Down Expand Up @@ -372,9 +369,9 @@ impl MonitorExt for Monitor {
let PhysicalPosition { x, y } = *self.position();
let PhysicalSize { width, height } = *self.size();

x < position.x as _
&& position.x < (x + width as i32)
&& y < position.y as _
&& position.y < (y + height as i32)
x <= position.x as _
&& position.x <= (x + width as i32)
&& y <= position.y as _
&& position.y <= (y + height as i32)
}
}

0 comments on commit 157f748

Please sign in to comment.