GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat(bar): create `BarManagerService` for launching bar app on a single thread; spawn windows on `MonitorAddedEvent`
Lars Bergere98edb99934e
diff --git a/LarsWM.Bar/BarManagerService.cs b/LarsWM.Bar/BarManagerService.csnew file mode 100644index 00000000..b06ec223--- /dev/null+++ b/LarsWM.Bar/BarManagerService.cs@@ -0,0 +1,46 @@+using LarsWM.Domain.Monitors.Events;+using LarsWM.Domain.Workspaces;+using LarsWM.Infrastructure.Bussing;+using System.Reactive.Linq;+using System;+using System.Threading;++namespace LarsWM.Bar+{+ public class BarManagerService+ {+ private Bus _bus;+ private WorkspaceService _workspaceService;++ public BarManagerService(Bus bus, WorkspaceService workspaceService)+ {+ _bus = bus;+ _workspaceService = workspaceService;+ }++ public void Init()+ {+ var thread = new Thread(() =>+ {+ var application = new App();++ // Launch the bar window on the added monitor.+ _bus.Events.Where(@event => @event is MonitorAddedEvent)+ .Subscribe((@event) =>+ {+ application.Dispatcher.Invoke(() =>+ {+ var bar = new MainWindow((@event as MonitorAddedEvent).AddedMonitor, _workspaceService, _bus);+ bar.Show();+ });+ });++ application.Run();+ });++ thread.Name = "LarsWMBar";+ thread.SetApartmentState(ApartmentState.STA);+ thread.Start();+ }+ }+}