Skip to content

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

feat(domain): avoid storing original width/height of window; instead store full coordinates in new `FloatingPlacement` property

Lars Berger343fab2772d8
diff --git a/GlazeWM.Domain/Windows/FloatingWindow.cs b/GlazeWM.Domain/Windows/FloatingWindow.cs
index ceff8de0..508c13ec 100644
--- a/GlazeWM.Domain/Windows/FloatingWindow.cs
+++ b/GlazeWM.Domain/Windows/FloatingWindow.cs
@@ -1,15 +1,12 @@
using System;
+using GlazeWM.Infrastructure.WindowsApi;
namespace GlazeWM.Domain.Windows
{
public sealed class FloatingWindow : Window
{
- public FloatingWindow(IntPtr hwnd, int originalWidth, int originalHeight, int x, int y) : base(hwnd, originalWidth, originalHeight)
+ public FloatingWindow(IntPtr hwnd, WindowRect floatingPlacement) : base(hwnd, floatingPlacement)
{
- Width = originalWidth;
- Height = originalHeight;
- X = x;
- Y = y;
}
}
}
diff --git a/GlazeWM.Domain/Windows/FullscreenWindow.cs b/GlazeWM.Domain/Windows/FullscreenWindow.cs
index 315a086c..487f676c 100644
--- a/GlazeWM.Domain/Windows/FullscreenWindow.cs
+++ b/GlazeWM.Domain/Windows/FullscreenWindow.cs
@@ -1,10 +1,14 @@
using System;
+using GlazeWM.Infrastructure.WindowsApi;
namespace GlazeWM.Domain.Windows
{
public sealed class FullscreenWindow : Window
{
- public FullscreenWindow(IntPtr hwnd, int originalWidth, int originalHeight) : base(hwnd, originalWidth, originalHeight)
+ public FullscreenWindow(
+ IntPtr hwnd,
+ WindowRect floatingPlacement
+ ) : base(hwnd, floatingPlacement)
{
}
}
diff --git a/GlazeWM.Domain/Windows/MaximizedWindow.cs b/GlazeWM.Domain/Windows/MaximizedWindow.cs
index 3bc1c7a3..a5cbac6b 100644
--- a/GlazeWM.Domain/Windows/MaximizedWindow.cs
+++ b/GlazeWM.Domain/Windows/MaximizedWindow.cs
@@ -1,10 +1,14 @@
using System;
+using GlazeWM.Infrastructure.WindowsApi;
namespace GlazeWM.Domain.Windows
{
public sealed class MaximizedWindow : Window
{
- public MaximizedWindow(IntPtr hwnd, int originalWidth, int originalHeight) : base(hwnd, originalWidth, originalHeight)
+ public MaximizedWindow(
+ IntPtr hwnd,
+ WindowRect floatingPlacement
+ ) : base(hwnd, floatingPlacement)
{
}
}
diff --git a/GlazeWM.Domain/Windows/MinimizedWindow.cs b/GlazeWM.Domain/Windows/MinimizedWindow.cs
index 750bef3d..6c73a9ae 100644
--- a/GlazeWM.Domain/Windows/MinimizedWindow.cs
+++ b/GlazeWM.Domain/Windows/MinimizedWindow.cs
@@ -1,10 +1,14 @@
using System;
+using GlazeWM.Infrastructure.WindowsApi;
namespace GlazeWM.Domain.Windows
{
public sealed class MinimizedWindow : Window
{
- public MinimizedWindow(IntPtr hwnd, int originalWidth, int originalHeight) : base(hwnd, originalWidth, originalHeight)
+ public MinimizedWindow(
+ IntPtr hwnd,
+ WindowRect floatingPlacement
+ ) : base(hwnd, floatingPlacement)
{
}
}
diff --git a/GlazeWM.Domain/Windows/TilingWindow.cs b/GlazeWM.Domain/Windows/TilingWindow.cs
index fa1f6c0d..7739fc75 100644
--- a/GlazeWM.Domain/Windows/TilingWindow.cs
+++ b/GlazeWM.Domain/Windows/TilingWindow.cs
@@ -1,6 +1,7 @@
using System;
using GlazeWM.Domain.Containers;
using GlazeWM.Infrastructure;
+using GlazeWM.Infrastructure.WindowsApi;
using Microsoft.Extensions.DependencyInjection;
namespace GlazeWM.Domain.Windows
@@ -9,11 +10,8 @@ namespace GlazeWM.Domain.Windows
{
public double SizePercentage { get; set; } = 1;
- private ContainerService _containerService = ServiceLocator.Provider.GetRequiredService<ContainerService>();
-
- public TilingWindow(IntPtr hwnd, int originalWidth, int originalHeight) : base(hwnd, originalWidth, originalHeight)
- {
- }
+ private ContainerService _containerService =
+ ServiceLocator.Provider.GetRequiredService<ContainerService>();
public override int Width => _containerService.CalculateWidthOfResizableContainer(this);
@@ -22,5 +20,9 @@ namespace GlazeWM.Domain.Windows
public override int X => _containerService.CalculateXOfResizableContainer(this);
public override int Y => _containerService.CalculateYOfResizableContainer(this);
+
+ public TilingWindow(IntPtr hwnd, WindowRect floatingPlacement) : base(hwnd, floatingPlacement)
+ {
+ }
}
}
diff --git a/GlazeWM.Domain/Windows/Window.cs b/GlazeWM.Domain/Windows/Window.cs
index 8035414f..dd4119c6 100644
--- a/GlazeWM.Domain/Windows/Window.cs
+++ b/GlazeWM.Domain/Windows/Window.cs
@@ -13,28 +13,23 @@ namespace GlazeWM.Domain.Windows
public IntPtr Hwnd { get; }
/// <summary>
- /// Whether adjustments need to be made because of DPI (eg. when moving between monitors).
+ /// The placement of the window when floating. Initialized with window's placement on launch
+ /// and updated on resize/move whilst floating.
/// </summary>
- public bool HasPendingDpiAdjustment { get; set; } = false;
+ public WindowRect FloatingPlacement { get; set; }
/// <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.
+ /// Whether adjustments need to be made because of DPI (eg. when moving between monitors).
/// </summary>
- public int OriginalHeight { get; set; }
+ public bool HasPendingDpiAdjustment { get; set; } = false;
private WindowService _windowService = ServiceLocator.Provider.GetRequiredService<WindowService>();
private WorkspaceService _workspaceService = ServiceLocator.Provider.GetRequiredService<WorkspaceService>();
- public Window(IntPtr hwnd, int originalWidth, int originalHeight)
+ public Window(IntPtr hwnd, WindowRect floatingPlacement)
{
Hwnd = hwnd;
- OriginalWidth = originalWidth;
- OriginalHeight = originalHeight;
+ FloatingPlacement = floatingPlacement;
}
/// <summary>