Skip to content

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

feat: improved detection of unmanageable windows

Larsd8dddfb95e34
diff --git a/LarsWM/Window.cs b/LarsWM/Window.cs
index 16b4aa9b..cc69df86 100644
--- a/LarsWM/Window.cs
+++ b/LarsWM/Window.cs
@@ -22,7 +22,7 @@ namespace LarsWM
public WindowRect Location => GetLocationOfWindow(this);
- public bool CanLayout => !IsWindowCloaked(this);
+ public bool CanLayout => !IsWindowCloaked(this) && IsWindowManageable(this);
/// <summary>
/// This window's style flags.
diff --git a/LarsWM/WindowsApi/WindowsApiFacade.cs b/LarsWM/WindowsApi/WindowsApiFacade.cs
index 478ff407..3223ab15 100644
--- a/LarsWM/WindowsApi/WindowsApiFacade.cs
+++ b/LarsWM/WindowsApi/WindowsApiFacade.cs
@@ -130,5 +130,17 @@ namespace LarsWM.WindowsApi
DwmGetWindowAttribute(window.Hwnd, DwmWindowAttribute.DWMWA_CLOAKED, out isCloaked, Marshal.SizeOf(typeof(bool)));
return isCloaked;
}
+
+ public static bool IsWindowManageable(Window window)
+ {
+
+ if (HasWindowExStyle(window.Hwnd, WS_EX.WS_EX_TOOLWINDOW) ||
+ GetWindow(window.Hwnd, GW.GW_OWNER) != IntPtr.Zero)
+ {
+ return false;
+ }
+
+ return true;
+ }
}
}
diff --git a/LarsWM/WindowsApi/WindowsApiService.cs b/LarsWM/WindowsApi/WindowsApiService.cs
index fd9db069..7bb52108 100644
--- a/LarsWM/WindowsApi/WindowsApiService.cs
+++ b/LarsWM/WindowsApi/WindowsApiService.cs
@@ -113,6 +113,11 @@ namespace LarsWM.WindowsApi
public static int GWL_STYLE = -16;
public static int GWL_EXSTYLE = -20;
+ public enum GW : uint
+ {
+ GW_OWNER = 4,
+ }
+
public delegate bool EnumWindowsDelegate(IntPtr hWnd, int lParam);
[DllImport("user32.dll", EntryPoint = "EnumWindows", ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)]
@@ -166,6 +171,9 @@ namespace LarsWM.WindowsApi
[DllImport("user32.dll")]
public static extern bool GetWindowRect(IntPtr hwnd, ref WindowRect rectangle);
+ [DllImport("user32.dll")]
+ public static extern IntPtr GetWindow(IntPtr hWnd, GW uCmd);
+
[DllImport("dwmapi.dll")]
public static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, out bool pvAttribute, int cbAttribute);