Skip to content

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

refactor: use `IsZoomed` for detecting maximized windows

Lars Berger85e51efcfa46
diff --git a/packages/wm/src/common/platform/native_window.rs b/packages/wm/src/common/platform/native_window.rs
index b7f648ae..9516d88a 100644
--- a/packages/wm/src/common/platform/native_window.rs
+++ b/packages/wm/src/common/platform/native_window.rs
@@ -21,7 +21,7 @@ use windows::{
WindowsAndMessaging::{
EnumWindows, GetClassNameW, GetWindow, GetWindowLongPtrW,
GetWindowPlacement, GetWindowRect, GetWindowTextW,
- GetWindowThreadProcessId, IsIconic, IsWindowVisible,
+ GetWindowThreadProcessId, IsIconic, IsWindowVisible, IsZoomed,
SendNotifyMessageW, SetForegroundWindow, SetWindowPos,
ShowWindowAsync, GWL_EXSTYLE, GWL_STYLE, GW_OWNER, HWND_NOTOPMOST,
HWND_TOPMOST, SWP_ASYNCWINDOWPOS, SWP_FRAMECHANGED,
@@ -200,11 +200,7 @@ impl NativeWindow {
}
pub fn is_maximized(&self) -> bool {
- let mut placement = WINDOWPLACEMENT::default();
- let _ =
- unsafe { GetWindowPlacement(HWND(self.handle), &mut placement) };
-
- placement.showCmd == SW_MAXIMIZE.0 as u32
+ unsafe { IsZoomed(HWND(self.handle)) }.as_bool()
}
pub fn is_resizable(&self) -> bool {
diff --git a/resources/sample-config.yaml b/resources/sample-config.yaml
index bcc4e013..dcd65770 100644
--- a/resources/sample-config.yaml
+++ b/resources/sample-config.yaml
@@ -61,7 +61,8 @@ window_behavior:
show_on_top: false
fullscreen:
- # Whether to prefer fullscreen windows to be maximized.
+ # Maximize the window if possible. If the window doesn't have a
+ # maximize button, then it'll be fullscreen'ed normally instead.
maximized: true
workspaces: