Skip to content

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

refactor(domain): change `IsWindowManageable` to be called with a window handle

Lars Berger7541eeb7fa6d
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs
index d11ffc09..a47c3dfb 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs
@@ -32,11 +32,11 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
var targetParent = command.TargetParent;
var shouldRedraw = command.ShouldRedraw;
- var window = new TilingWindow(command.WindowHandle);
-
- if (!window.IsManageable)
+ if (!_windowService.IsHandleManageable(windowHandle))
return CommandResponse.Ok;
+ var window = new TilingWindow(command.WindowHandle);
+
var matchingWindowRules = GetMatchingWindowRules(window);
var commandStrings = matchingWindowRules
diff --git a/GlazeWM.Domain/Windows/Window.cs b/GlazeWM.Domain/Windows/Window.cs
index 96a43567..06b6705b 100644
--- a/GlazeWM.Domain/Windows/Window.cs
+++ b/GlazeWM.Domain/Windows/Window.cs
@@ -52,7 +52,7 @@ namespace GlazeWM.Domain.Windows
public string Title => _windowService.GetTitleOfHandle(Hwnd);
- public bool IsManageable => _windowService.IsWindowManageable(this);
+ public bool IsManageable => _windowService.IsHandleManageable(Hwnd);
public WS WindowStyles => _windowService.GetWindowStyles(Hwnd);
diff --git a/GlazeWM.Domain/Windows/WindowService.cs b/GlazeWM.Domain/Windows/WindowService.cs
index 697e1ae5..9c8afa79 100644
--- a/GlazeWM.Domain/Windows/WindowService.cs
+++ b/GlazeWM.Domain/Windows/WindowService.cs
@@ -141,25 +141,25 @@ namespace GlazeWM.Domain.Windows
return isCloaked;
}
- public bool IsWindowManageable(Window window)
+ public bool IsHandleManageable(IntPtr handle)
{
// Get whether window is actually visible.
- var isVisible = IsWindowVisible(window.Hwnd) && !IsHandleCloaked(window.Hwnd);
+ var isVisible = IsWindowVisible(handle) && !IsHandleCloaked(handle);
if (!isVisible)
return false;
// Ensure window is top-level (ie. not a child window). Ignore windows that are probably
// popups or if they're unavailable in task switcher (alt+tab menu).
- var isApplicationWindow = !window.HasWindowStyle(WS.WS_CHILD)
- && !window.HasWindowExStyle(WS_EX.WS_EX_NOACTIVATE | WS_EX.WS_EX_TOOLWINDOW)
- && GetWindow(window.Hwnd, GW.GW_OWNER) == IntPtr.Zero;
+ var isApplicationWindow = !HandleHasWindowStyle(handle, WS.WS_CHILD)
+ && !HandleHasWindowExStyle(handle, WS_EX.WS_EX_NOACTIVATE | WS_EX.WS_EX_TOOLWINDOW)
+ && GetWindow(handle, GW.GW_OWNER) == IntPtr.Zero;
if (!isApplicationWindow)
return false;
// Get whether the window belongs to the current process.
- var isCurrentProcess = window.Process.Id == Process.GetCurrentProcess().Id;
+ var isCurrentProcess = GetProcessOfHandle(handle).Id == Process.GetCurrentProcess().Id;
if (isCurrentProcess)
return false;