Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat: draw fullscreen windows as the size of the current monitor

Lars Bergere354ee984491
diff --git a/packages/wm/src/common/platform/native_window.rs b/packages/wm/src/common/platform/native_window.rs
index 9516d88a..1bca8b4c 100644
--- a/packages/wm/src/common/platform/native_window.rs
+++ b/packages/wm/src/common/platform/native_window.rs
@@ -404,10 +404,11 @@ impl NativeWindow {
match state {
WindowState::Minimized => self.minimize(),
- // TODO: Handle non-maximized fullscreen.
// TODO: Handle maximized fullscreen on different monitor than
// window's current position.
- WindowState::Fullscreen(_) => self.maximize(),
+ WindowState::Fullscreen(config) if config.maximized => {
+ self.maximize()
+ }
_ => {
unsafe {
SetWindowPos(
diff --git a/packages/wm/src/windows/non_tiling_window.rs b/packages/wm/src/windows/non_tiling_window.rs
index 564af02d..ed408515 100644
--- a/packages/wm/src/windows/non_tiling_window.rs
+++ b/packages/wm/src/windows/non_tiling_window.rs
@@ -4,6 +4,7 @@ use std::{
rc::Rc,
};
+use anyhow::Context;
use uuid::Uuid;
use crate::{
@@ -109,18 +110,56 @@ impl_window_getters!(NonTilingWindow);
impl PositionGetters for NonTilingWindow {
fn width(&self) -> anyhow::Result<i32> {
- Ok(self.0.borrow().floating_placement.width())
+ // TODO: Simplify with a `borrow_monitor_rect` fn.
+ let width = match self.state() {
+ WindowState::Fullscreen(_) => self
+ .monitor()
+ .context("No monitor.")?
+ .native()
+ .rect()?
+ .width(),
+ _ => self.floating_placement().width(),
+ };
+
+ Ok(width)
}
fn height(&self) -> anyhow::Result<i32> {
- Ok(self.0.borrow().floating_placement.height())
+ // TODO: Simplify with a `borrow_monitor_rect` fn.
+ let height = match self.state() {
+ WindowState::Fullscreen(_) => self
+ .monitor()
+ .context("No monitor.")?
+ .native()
+ .rect()?
+ .height(),
+ _ => self.floating_placement().height(),
+ };
+
+ Ok(height)
}
fn x(&self) -> anyhow::Result<i32> {
- Ok(self.0.borrow().floating_placement.x())
+ // TODO: Simplify with a `borrow_monitor_rect` fn.
+ let x = match self.state() {
+ WindowState::Fullscreen(_) => {
+ self.monitor().context("No monitor.")?.native().rect()?.x()
+ }
+ _ => self.floating_placement().x(),
+ };
+
+ Ok(x)
}
fn y(&self) -> anyhow::Result<i32> {
- Ok(self.0.borrow().floating_placement.y())
+ // TODO: Simplify with a `borrow_monitor_rect` fn.
+ let y = match self.state() {
+ WindowState::Fullscreen(_) => {
+ self.monitor().context("No monitor.")?.native().rect()?.y()
+ }
+ _ => self.floating_placement().y(),
+ };
+
+ Ok(y)
}
}