Skip to content

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

feat(infra): raise `WindowHiddenEvent` via window event hook procedure

Lars Bergere7009ba0bd2b
diff --git a/LarsWM.Infrastructure/WindowsApi/WindowEventService.cs b/LarsWM.Infrastructure/WindowsApi/WindowEventService.cs
index 7cfbb110..f550ffe4 100644
--- a/LarsWM.Infrastructure/WindowsApi/WindowEventService.cs
+++ b/LarsWM.Infrastructure/WindowsApi/WindowEventService.cs
@@ -38,7 +38,10 @@ namespace LarsWM.Infrastructure.WindowsApi
private void WindowEventHookProc(IntPtr hWinEventHook, EventConstant eventType, IntPtr hwnd, ObjectIdentifier idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
{
- var isWindowEvent = idChild == CHILDID_SELF && idObject == ObjectIdentifier.OBJID_WINDOW && hwnd != IntPtr.Zero;
+ // Whether the window event is actually associated with a window object (instead of a UI
+ // control, for example).
+ var isWindowEvent = idChild == CHILDID_SELF && idObject == ObjectIdentifier.OBJID_WINDOW
+ && hwnd != IntPtr.Zero;
if (!isWindowEvent)
return;
@@ -51,6 +54,9 @@ namespace LarsWM.Infrastructure.WindowsApi
case EventConstant.EVENT_OBJECT_DESTROY:
_bus.RaiseEvent(new WindowDestroyedEvent(hwnd));
break;
+ case EventConstant.EVENT_OBJECT_HIDE:
+ _bus.RaiseEvent(new WindowHiddenEvent(hwnd));
+ break;
case EventConstant.EVENT_SYSTEM_MINIMIZESTART:
_bus.RaiseEvent(new WindowMinimizedEvent(hwnd));
break;