GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: MonitorAddedEvent triggers a workspace to be created if one doesn't exist
Larsc38c0066cac4
diff --git a/LarsWM.Core/LarsWM.Core.csproj b/LarsWM.Core/LarsWM.Core.csprojindex 6dc1211a..ffcee848 100644--- a/LarsWM.Core/LarsWM.Core.csproj+++ b/LarsWM.Core/LarsWM.Core.csproj@@ -13,4 +13,9 @@<PackageReference Include="System.Reactive" Version="4.3.2" /></ItemGroup>+ <ItemGroup>+ <Folder Include="Workspaces\Events\" />+ <Folder Include="Workspaces\EventHandlers\" />+ </ItemGroup>+</Project>diff --git a/LarsWM.Core/Monitors/EventHandlers/MonitorAddedHandler.cs b/LarsWM.Core/Monitors/EventHandlers/MonitorAddedHandler.csindex 037b0f89..580ad006 100644--- a/LarsWM.Core/Monitors/EventHandlers/MonitorAddedHandler.cs+++ b/LarsWM.Core/Monitors/EventHandlers/MonitorAddedHandler.cs@@ -1,8 +1,10 @@using LarsWM.Core.Common.Models;using LarsWM.Core.Common.Services;using LarsWM.Core.Monitors.Events;+using LarsWM.Core.Workspaces.Commands;using System;using System.Collections.Generic;+using System.Linq;using System.Text;namespace LarsWM.Core.Monitors.EventHandler@@ -10,17 +12,26 @@ namespace LarsWM.Core.Monitors.EventHandlerclass MonitorAddedHandler : IEventHandler<MonitorAddedEvent>{private IBus _bus;+ private AppState _appState;- public MonitorAddedHandler(IBus bus)+ public MonitorAddedHandler(IBus bus, AppState appState){_bus = bus;+ _appState = appState;}public void Handle(MonitorAddedEvent @event){- throw new NotImplementedException();+ foreach (var monitor in _appState.Monitors)+ {+ // Create an initial workspace for the monitor if one doesn't exist.+ if (monitor.WorkspacesInMonitor.Count() == 0)+ _bus.Invoke(new CreateWorkspaceCommand(monitor.Name, 1));+ // TODO: invoke SetDisplayedWorkspaceCommand+ }- // Create an initial Workspace for each Monitor+ // Old code:+ // Create an initial Workspace for each Monitor// int index = 0;// foreach (var monitor in msg.monitors)// {