Skip to content

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

feat(domain): invoke FocusWindowCommand on EVENT_SYSTEM_FOREGROUND

Lars7b064b3a5e0c
diff --git a/LarsWM.Domain/Windows/WindowHooksHandler.cs b/LarsWM.Domain/Windows/WindowHooksHandler.cs
index e22f1835..4ee7f7a9 100644
--- a/LarsWM.Domain/Windows/WindowHooksHandler.cs
+++ b/LarsWM.Domain/Windows/WindowHooksHandler.cs
@@ -1,4 +1,6 @@
-using LarsWM.Infrastructure.WindowsApi;
+using LarsWM.Domain.Windows.Commands;
+using LarsWM.Infrastructure.Bussing;
+using LarsWM.Infrastructure.WindowsApi;
using LarsWM.Infrastructure.WindowsApi.Enums;
using System;
using System.Collections.Generic;
@@ -10,10 +12,14 @@ namespace LarsWM.Domain.Windows
// TODO: Rename to WindowService once respository classes are created.
public class WindowHooksHandler
{
+ private IBus _bus;
+ private WindowService _windowService;
private WindowEventService _windowEventService { get; }
- public WindowHooksHandler(WindowEventService windowEventService)
+ public WindowHooksHandler(IBus bus, WindowService windowService, WindowEventService windowEventService)
{
+ _bus = bus;
+ _windowService = windowService;
_windowEventService = windowEventService;
}
@@ -21,6 +27,8 @@ namespace LarsWM.Domain.Windows
{
_windowEventService.WindowHookSubject.Subscribe(observer =>
{
+ var window = _windowService.GetWindowByHandle(observer.AffectedWindowHandle);
+
switch (observer.EventType)
{
case EventConstant.EVENT_OBJECT_SHOW:
@@ -42,7 +50,7 @@ namespace LarsWM.Domain.Windows
Debug.WriteLine("minimize end");
break;
case EventConstant.EVENT_SYSTEM_FOREGROUND:
- Debug.WriteLine("foreground");
+ _bus.Invoke(new FocusWindowCommand(window));
break;
}
});