Skip to content

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

feat(boot): handle resetting window positions and other cleanup on application exit

Lars Berger0eca3562ba8a
diff --git a/GlazeWM.Bootstrapper/Startup.cs b/GlazeWM.Bootstrapper/Startup.cs
index 02b5df04..0d3b9874 100644
--- a/GlazeWM.Bootstrapper/Startup.cs
+++ b/GlazeWM.Bootstrapper/Startup.cs
@@ -11,7 +11,10 @@ using GlazeWM.Domain.Workspaces;
using GlazeWM.Domain.Workspaces.Commands;
using GlazeWM.Infrastructure.Bussing;
using GlazeWM.Infrastructure.WindowsApi;
+using GlazeWM.Infrastructure.WindowsApi.Events;
+using System;
using System.Linq;
+using System.Reactive.Linq;
using System.Windows.Forms;
using static GlazeWM.Infrastructure.WindowsApi.WindowsApiService;
@@ -65,6 +68,9 @@ namespace GlazeWM.Bootstrapper
_windowEventService.Start();
_systemTrayService.AddToSystemTray("icon.ico");
+
+ _bus.Events.Where(@event => @event is ApplicationExitingEvent)
+ .Subscribe((@event) => OnApplicationExit());
}
/// <summary>
@@ -116,5 +122,12 @@ namespace GlazeWM.Bootstrapper
else if (containerToFocus is Workspace)
_bus.Invoke(new FocusWorkspaceCommand((containerToFocus as Workspace).Name));
}
+
+ private void OnApplicationExit()
+ {
+ _bus.Invoke(new ShowAllWindowsCommand());
+ _barService.ExitApp();
+ Application.Exit();
+ }
}
}