GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat(domain): store the original width & height of a window before managing it
Lars Berger7ef4d495aef4
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.csindex 9b5705c0..d11ffc09 100644--- a/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs+++ b/GlazeWM.Domain/Windows/CommandHandlers/AddWindowHandler.cs@@ -15,13 +15,15 @@ namespace GlazeWM.Domain.Windows.CommandHandlersprivate ContainerService _containerService;private UserConfigService _userConfigService;private CommandParsingService _commandParsingService;+ private WindowService _windowService;- public AddWindowHandler(Bus bus, ContainerService containerService, UserConfigService userConfigService, CommandParsingService commandParsingService)+ public AddWindowHandler(Bus bus, ContainerService containerService, UserConfigService userConfigService, CommandParsingService commandParsingService, WindowService windowService){_bus = bus;_containerService = containerService;_userConfigService = userConfigService;_commandParsingService = commandParsingService;+ _windowService = windowService;}public CommandResponse Handle(AddWindowCommand command)@@ -45,6 +47,11 @@ namespace GlazeWM.Domain.Windows.CommandHandlersif (commandStrings.Contains("ignore"))return CommandResponse.Ok;+ // Store the original width and height of the window.+ var originalPlacement = _windowService.GetPlacementOfHandle(window.Hwnd).NormalPosition;+ window.OriginalWidth = originalPlacement.Right - originalPlacement.Left;+ window.OriginalHeight = originalPlacement.Bottom - originalPlacement.Top;+// Attach the new window as a child to the target parent (if provided), otherwise, add as a// sibling of the focused container.AttachChildWindow(window, targetParent);diff --git a/GlazeWM.Domain/Windows/Window.cs b/GlazeWM.Domain/Windows/Window.csindex ae1e19b8..33fa2b0c 100644--- a/GlazeWM.Domain/Windows/Window.cs+++ b/GlazeWM.Domain/Windows/Window.cs@@ -21,6 +21,16 @@ namespace GlazeWM.Domain.Windows/// </summary>public bool HasPendingDpiAdjustment { get; set; } = false;+ /// <summary>+ /// The original width of the window. Used as the window's width when floating is toggled.+ /// </summary>+ public int OriginalWidth { get; set; }++ /// <summary>+ /// The original height of the window. Used as the window's height when floating is toggled.+ /// </summary>+ public int OriginalHeight { get; set; }+private WindowService _windowService = ServiceLocator.Provider.GetRequiredService<WindowService>();private WorkspaceService _workspaceService = ServiceLocator.Provider.GetRequiredService<WorkspaceService>();