GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
refactor(infra,domain): rename `WindowRect` -> `Rect`
Lars Bergerd9d5d8b237f2
diff --git a/GlazeWM.Domain/Containers/Container.cs b/GlazeWM.Domain/Containers/Container.csindex ba4d94ac..295f6dc0 100644--- a/GlazeWM.Domain/Containers/Container.cs+++ b/GlazeWM.Domain/Containers/Container.cs@@ -125,9 +125,9 @@ namespace GlazeWM.Domain.Containersreturn Siblings.Any();}- public WindowRect ToRectangle()+ public Rect ToRect(){- return new WindowRect()+ return new Rect(){Left = X,Right = X + Width,diff --git a/GlazeWM.Domain/JsonContainerConverter.cs b/GlazeWM.Domain/JsonContainerConverter.csindex 4b5498fd..9bf8460a 100644--- a/GlazeWM.Domain/JsonContainerConverter.cs+++ b/GlazeWM.Domain/JsonContainerConverter.cs@@ -57,20 +57,20 @@ namespace GlazeWM.Domain.Containers"MinimizedWindow" => new MinimizedWindow(// TODO: Handle `IntPtr` for 32-bit processes.new IntPtr(Convert.ToInt64(jsonObject.GetProperty("Handle").GetString(), 16)),- jsonObject.GetProperty("FloatingPlacement").Deserialize<WindowRect>(),+ jsonObject.GetProperty("FloatingPlacement").Deserialize<Rect>(),jsonObject.GetProperty("BorderDelta").Deserialize<RectDelta>(),jsonObject.GetEnumProperty<WindowType>("PreviousState", options)),"FloatingWindow" => new FloatingWindow(// TODO: Handle `IntPtr` for 32-bit processes.new IntPtr(Convert.ToInt64(jsonObject.GetProperty("Handle").GetString(), 16)),- jsonObject.GetProperty("FloatingPlacement").Deserialize<WindowRect>(),+ jsonObject.GetProperty("FloatingPlacement").Deserialize<Rect>(),jsonObject.GetProperty("BorderDelta").Deserialize<RectDelta>()),"TilingWindow" => new TilingWindow(// TODO: Handle `IntPtr` for 32-bit processes.new IntPtr(Convert.ToInt64(jsonObject.GetProperty("Handle").GetString(), 16)),- jsonObject.GetProperty("FloatingPlacement").Deserialize<WindowRect>(),+ jsonObject.GetProperty("FloatingPlacement").Deserialize<Rect>(),jsonObject.GetProperty("BorderDelta").Deserialize<RectDelta>(),jsonObject.GetProperty("SizePercentage").GetDouble()),diff --git a/GlazeWM.Domain/Monitors/CommandHandlers/RefreshMonitorStateHandler.cs b/GlazeWM.Domain/Monitors/CommandHandlers/RefreshMonitorStateHandler.csindex 570dd90b..35e4ab6e 100644--- a/GlazeWM.Domain/Monitors/CommandHandlers/RefreshMonitorStateHandler.cs+++ b/GlazeWM.Domain/Monitors/CommandHandlers/RefreshMonitorStateHandler.cs@@ -76,7 +76,7 @@ namespace GlazeWM.Domain.Monitors.CommandHandlers// the primary display is changed. The primary display dictates the position of 0,0.var parentWorkspace = WorkspaceService.GetWorkspaceFromChildContainer(window);window.FloatingPlacement =- window.FloatingPlacement.TranslateToCenter(parentWorkspace.ToRectangle());+ window.FloatingPlacement.TranslateToCenter(parentWorkspace.ToRect());}// Redraw full container tree.diff --git a/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.csindex e737e737..8495bda8 100644--- a/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs+++ b/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs@@ -90,7 +90,7 @@ namespace GlazeWM.Domain.Windows.CommandHandlers// Calculate where window should be placed when floating is enabled. Use the original// width/height of the window, but position it in the center of the workspace.var targetWorkspace = WorkspaceService.GetWorkspaceFromChildContainer(targetParent);- var floatingPlacement = originalPlacement.TranslateToCenter(targetWorkspace.ToRectangle());+ var floatingPlacement = originalPlacement.TranslateToCenter(targetWorkspace.ToRect());var defaultBorderDelta = new RectDelta(7, 0, 7, 7);diff --git a/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.csindex 55f7efed..d3a2adc4 100644--- a/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs+++ b/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs@@ -137,7 +137,7 @@ namespace GlazeWM.Domain.Windows.CommandHandlers// Update floating placement since the window has to cross monitors.windowToMove.FloatingPlacement =- windowToMove.FloatingPlacement.TranslateToCenter(workspaceInDirection.ToRectangle());+ windowToMove.FloatingPlacement.TranslateToCenter(workspaceInDirection.ToRect());// TODO: Descend into container if possible.if (direction is Direction.UP or Direction.LEFT)diff --git a/GlazeWM.Domain/Windows/EventHandlers/WindowMovedOrResizedHandler.cs b/GlazeWM.Domain/Windows/EventHandlers/WindowMovedOrResizedHandler.csindex 4d5afab4..5367e258 100644--- a/GlazeWM.Domain/Windows/EventHandlers/WindowMovedOrResizedHandler.cs+++ b/GlazeWM.Domain/Windows/EventHandlers/WindowMovedOrResizedHandler.cs@@ -72,7 +72,7 @@ namespace GlazeWM.Domain.Windows.EventHandlers// Remove invisible borders from current placement to be able to compare window width/height.var currentPlacement = WindowService.GetPlacementOfHandle(window.Handle).NormalPosition;- var adjustedPlacement = new WindowRect+ var adjustedPlacement = new Rect{Left = currentPlacement.Left + window.BorderDelta.Left,Right = currentPlacement.Right - window.BorderDelta.Right,diff --git a/GlazeWM.Domain/Windows/FloatingWindow.cs b/GlazeWM.Domain/Windows/FloatingWindow.csindex 1c9f2ec4..1c1ec230 100644--- a/GlazeWM.Domain/Windows/FloatingWindow.cs+++ b/GlazeWM.Domain/Windows/FloatingWindow.cs@@ -15,7 +15,7 @@ namespace GlazeWM.Domain.Windowspublic FloatingWindow(IntPtr handle,- WindowRect floatingPlacement,+ Rect floatingPlacement,RectDelta borderDelta) : base(handle, floatingPlacement, borderDelta){diff --git a/GlazeWM.Domain/Windows/FullscreenWindow.cs b/GlazeWM.Domain/Windows/FullscreenWindow.csindex 971de8f3..1e691b1b 100644--- a/GlazeWM.Domain/Windows/FullscreenWindow.cs+++ b/GlazeWM.Domain/Windows/FullscreenWindow.cs@@ -7,7 +7,7 @@ namespace GlazeWM.Domain.Windows{public FullscreenWindow(IntPtr handle,- WindowRect floatingPlacement,+ Rect floatingPlacement,RectDelta borderDelta) : base(handle, floatingPlacement, borderDelta){diff --git a/GlazeWM.Domain/Windows/MaximizedWindow.cs b/GlazeWM.Domain/Windows/MaximizedWindow.csindex beed2ec4..0d927f3c 100644--- a/GlazeWM.Domain/Windows/MaximizedWindow.cs+++ b/GlazeWM.Domain/Windows/MaximizedWindow.cs@@ -7,7 +7,7 @@ namespace GlazeWM.Domain.Windows{public MaximizedWindow(IntPtr handle,- WindowRect floatingPlacement,+ Rect floatingPlacement,RectDelta borderDelta) : base(handle, floatingPlacement, borderDelta){diff --git a/GlazeWM.Domain/Windows/MinimizedWindow.cs b/GlazeWM.Domain/Windows/MinimizedWindow.csindex 8c95443a..78ddd1e6 100644--- a/GlazeWM.Domain/Windows/MinimizedWindow.cs+++ b/GlazeWM.Domain/Windows/MinimizedWindow.cs@@ -9,7 +9,7 @@ namespace GlazeWM.Domain.Windowspublic MinimizedWindow(IntPtr handle,- WindowRect floatingPlacement,+ Rect floatingPlacement,RectDelta borderDelta,WindowType previousState) : base(handle, floatingPlacement, borderDelta)diff --git a/GlazeWM.Domain/Windows/TilingWindow.cs b/GlazeWM.Domain/Windows/TilingWindow.csindex 2ef52568..cbf0ae30 100644--- a/GlazeWM.Domain/Windows/TilingWindow.cs+++ b/GlazeWM.Domain/Windows/TilingWindow.cs@@ -23,7 +23,7 @@ namespace GlazeWM.Domain.Windowspublic TilingWindow(IntPtr handle,- WindowRect floatingPlacement,+ Rect floatingPlacement,RectDelta borderDelta) : base(handle, floatingPlacement, borderDelta){@@ -31,7 +31,7 @@ namespace GlazeWM.Domain.Windowspublic TilingWindow(IntPtr handle,- WindowRect floatingPlacement,+ Rect floatingPlacement,RectDelta borderDelta,double sizePercentage) : base(handle, floatingPlacement, borderDelta)diff --git a/GlazeWM.Domain/Windows/Window.cs b/GlazeWM.Domain/Windows/Window.csindex 7b9d5c32..aaccf393 100644--- a/GlazeWM.Domain/Windows/Window.cs+++ b/GlazeWM.Domain/Windows/Window.cs@@ -14,7 +14,7 @@ namespace GlazeWM.Domain.Windows/// The placement of the window when floating. Initialized with window's placement on launch/// and updated on resize/move whilst floating./// </summary>- public WindowRect FloatingPlacement { get; set; }+ public Rect FloatingPlacement { get; set; }/// <summary>/// The difference in window dimensions to adjust for invisible borders. This is typically 7px@@ -28,7 +28,7 @@ namespace GlazeWM.Domain.Windows/// </summary>public bool HasPendingDpiAdjustment { get; set; }- protected Window(IntPtr handle, WindowRect floatingPlacement, RectDelta borderDelta)+ protected Window(IntPtr handle, Rect floatingPlacement, RectDelta borderDelta){Handle = handle;FloatingPlacement = floatingPlacement;@@ -44,7 +44,7 @@ namespace GlazeWM.Domain.Windowspublic string ClassName => WindowService.GetClassNameOfHandle(Handle);- public WindowRect Location => WindowService.GetLocationOfHandle(Handle);+ public Rect Location => WindowService.GetLocationOfHandle(Handle);public string Title => WindowService.GetTitleOfHandle(Handle);diff --git a/GlazeWM.Domain/Windows/WindowService.cs b/GlazeWM.Domain/Windows/WindowService.csindex 1a5ff5fe..16dd8bcf 100644--- a/GlazeWM.Domain/Windows/WindowService.cs+++ b/GlazeWM.Domain/Windows/WindowService.cs@@ -64,9 +64,9 @@ namespace GlazeWM.Domain.Windows/// <summary>/// Get dimensions of the bounding rectangle of the specified window./// </summary>- public static WindowRect GetLocationOfHandle(IntPtr handle)+ public static Rect GetLocationOfHandle(IntPtr handle){- var rect = new WindowRect();+ var rect = new Rect();GetWindowRect(handle, ref rect);return rect;}diff --git a/GlazeWM.Domain/Workspaces/CommandHandlers/MoveWindowToWorkspaceHandler.cs b/GlazeWM.Domain/Workspaces/CommandHandlers/MoveWindowToWorkspaceHandler.csindex 7586417c..0cf3f575 100644--- a/GlazeWM.Domain/Workspaces/CommandHandlers/MoveWindowToWorkspaceHandler.cs+++ b/GlazeWM.Domain/Workspaces/CommandHandlers/MoveWindowToWorkspaceHandler.cs@@ -49,7 +49,7 @@ namespace GlazeWM.Domain.Workspaces.CommandHandlers// Update floating placement if the window has to cross monitors.if (targetWorkspace.Parent != currentWorkspace.Parent)windowToMove.FloatingPlacement =- windowToMove.FloatingPlacement.TranslateToCenter(targetWorkspace.ToRectangle());+ windowToMove.FloatingPlacement.TranslateToCenter(targetWorkspace.ToRect());if (windowToMove is TilingWindow)MoveTilingWindowToWorkspace(windowToMove as TilingWindow, targetWorkspace);diff --git a/GlazeWM.Infrastructure/WindowsApi/WindowRect.cs b/GlazeWM.Infrastructure/WindowsApi/WindowRect.csindex fee3b155..86880988 100644--- a/GlazeWM.Infrastructure/WindowsApi/WindowRect.cs+++ b/GlazeWM.Infrastructure/WindowsApi/WindowRect.cs@@ -1,6 +1,6 @@namespace GlazeWM.Infrastructure.WindowsApi{- public struct WindowRect+ public struct Rect{/// <summary>/// The x-coordinate of the upper-left corner of the rectangle.@@ -33,9 +33,9 @@/// <summary>/// Creates a new `WindowRect` from coordinates of its upper-left and lower-right corners./// </summary>- public static WindowRect FromLTRB(int left, int top, int right, int bottom)+ public static Rect FromLTRB(int left, int top, int right, int bottom){- return new WindowRect()+ return new Rect(){Left = left,Right = right,@@ -47,9 +47,9 @@/// <summary>/// Creates a new `WindowRect` from its X/Y coordinates and size./// </summary>- public static WindowRect FromXYCoordinates(int x, int y, int width, int height)+ public static Rect FromXYCoordinates(int x, int y, int width, int height){- return new WindowRect()+ return new Rect(){Left = x,Right = x + width,@@ -58,12 +58,12 @@};}- public WindowRect TranslateToCoordinates(int x, int y)+ public Rect TranslateToCoordinates(int x, int y){return FromXYCoordinates(x, y, Width, Height);}- public WindowRect TranslateToCenter(WindowRect outerRect)+ public Rect TranslateToCenter(Rect outerRect){return TranslateToCoordinates(outerRect.X + (outerRect.Width / 2) - (Width / 2),diff --git a/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs b/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.csindex cc59c72e..3f76dbd6 100644--- a/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs+++ b/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs@@ -212,7 +212,7 @@ namespace GlazeWM.Infrastructure.WindowsApipublic static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);[DllImport("user32.dll")]- public static extern bool GetWindowRect(IntPtr hwnd, ref WindowRect rectangle);+ public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);/// <summary>/// Contains information about the placement of a window on the screen.@@ -248,7 +248,7 @@ namespace GlazeWM.Infrastructure.WindowsApi/// <summary>/// The window's coordinates when the window is in the restored position./// </summary>- public WindowRect NormalPosition;+ public Rect NormalPosition;}[DllImport("user32.dll", SetLastError = true)]@@ -364,13 +364,13 @@ namespace GlazeWM.Infrastructure.WindowsApipublic static extern uint GetDpiForWindow(IntPtr hWnd);[DllImport("user32.dll", SetLastError = true)]- public static extern bool AdjustWindowRectEx(ref WindowRect lpRect, WS dwStyle, [MarshalAs(UnmanagedType.Bool)] bool bMenu, WS_EX dwExStyle);+ public static extern bool AdjustWindowRectEx(ref Rect lpRect, WS dwStyle, [MarshalAs(UnmanagedType.Bool)] bool bMenu, WS_EX dwExStyle);[DllImport("user32.dll", SetLastError = true)]- public static extern bool AdjustWindowRect(ref WindowRect lpRect, WS dwStyle, [MarshalAs(UnmanagedType.Bool)] bool bMenu);+ public static extern bool AdjustWindowRect(ref Rect lpRect, WS dwStyle, [MarshalAs(UnmanagedType.Bool)] bool bMenu);[DllImport("user32.dll", SetLastError = true)]- public static extern bool AdjustWindowRectExForDpi(ref WindowRect lpRect, WS dwStyle, [MarshalAs(UnmanagedType.Bool)] bool bMenu, WS_EX dwExStyle, uint dpi);+ public static extern bool AdjustWindowRectExForDpi(ref Rect lpRect, WS dwStyle, [MarshalAs(UnmanagedType.Bool)] bool bMenu, WS_EX dwExStyle, uint dpi);public enum DpiType{