Skip to content

Commit

Permalink
Rename IWindowLocation to IWindowState (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalyIsaac authored Jul 3, 2022
1 parent d092d52 commit bd8e707
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Whim.Bar/BarWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public BarWindow(IConfigContext configContext, BarConfig barConfig, IMonitor mon
x: _monitor.X + leftMargin,
y: _monitor.Y + rightMargin,
width: _monitor.Width - (leftMargin + rightMargin),
height: _barConfig.Height), WindowState.Normal);
height: _barConfig.Height), WindowSize.Normal);

// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/3689
Title = "Whim Bar";
Expand Down
2 changes: 1 addition & 1 deletion src/Whim.CommandPalette/CommandPaletteWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void Activate(IEnumerable<(ICommand, IKeybind?)>? items = null, IMonitor?
base.Activate();
TextEntry.Focus(FocusState.Programmatic);
Win32Helper.SetWindowPos(
new WindowLocation(_window, windowLocation, WindowState.Normal),
new WindowLocation(_window, windowLocation, WindowSize.Normal),
_window.Handle
);
_window.FocusForceForeground();
Expand Down
2 changes: 1 addition & 1 deletion src/Whim.FloatingLayout/FloatingLayoutEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override IEnumerable<IWindowLocation> DoLayout(ILocation<int> location)
// Iterate over all windows in _windowToLocation.
foreach ((IWindow window, ILocation<double> loc) in _windowToLocation)
{
yield return new WindowLocation(window, location.ToMonitor(loc), WindowState.Normal);
yield return new WindowLocation(window, location.ToMonitor(loc), WindowSize.Normal);
}

// Iterate over all windows in the inner layout engine.
Expand Down
2 changes: 1 addition & 1 deletion src/Whim.FocusIndicator/FocusIndicatorWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void Activate(IWindowLocation windowLocation)
);

Win32Helper.SetWindowPos(
new WindowLocation(_window, borderLocation, WindowState.Normal),
new WindowLocation(_window, borderLocation, WindowSize.Normal),
windowLocation.Window.Handle
);
}
Expand Down
18 changes: 9 additions & 9 deletions src/Whim.TreeLayout.Tests/TestTreeWindowLocations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public static IWindowLocation[] GetAllWindowLocations(ILocation<int> screen, IWi
{
return new IWindowLocation[]
{
new WindowLocation(leftWindow, Left.Scale(screen), WindowState.Normal),
new WindowLocation(rightTopLeftTopWindow, RightTopLeftTop.Scale(screen), WindowState.Normal),
new WindowLocation(rightTopLeftBottomLeftWindow, RightTopLeftBottomLeft.Scale(screen), WindowState.Normal),
new WindowLocation(rightTopLeftBottomRightTopWindow, RightTopLeftBottomRightTop.Scale(screen), WindowState.Normal),
new WindowLocation(rightTopLeftBottomRightBottomWindow, RightTopLeftBottomRightBottom.Scale(screen), WindowState.Normal),
new WindowLocation(rightTopRight1Window, RightTopRight1.Scale(screen), WindowState.Normal),
new WindowLocation(rightTopRight2Window, RightTopRight2.Scale(screen), WindowState.Normal),
new WindowLocation(rightTopRight3Window, RightTopRight3.Scale(screen), WindowState.Normal),
new WindowLocation(rightBottomWindow, RightBottom.Scale(screen), WindowState.Normal)
new WindowLocation(leftWindow, Left.Scale(screen), WindowSize.Normal),
new WindowLocation(rightTopLeftTopWindow, RightTopLeftTop.Scale(screen), WindowSize.Normal),
new WindowLocation(rightTopLeftBottomLeftWindow, RightTopLeftBottomLeft.Scale(screen), WindowSize.Normal),
new WindowLocation(rightTopLeftBottomRightTopWindow, RightTopLeftBottomRightTop.Scale(screen), WindowSize.Normal),
new WindowLocation(rightTopLeftBottomRightBottomWindow, RightTopLeftBottomRightBottom.Scale(screen), WindowSize.Normal),
new WindowLocation(rightTopRight1Window, RightTopRight1.Scale(screen), WindowSize.Normal),
new WindowLocation(rightTopRight2Window, RightTopRight2.Scale(screen), WindowSize.Normal),
new WindowLocation(rightTopRight3Window, RightTopRight3.Scale(screen), WindowSize.Normal),
new WindowLocation(rightBottomWindow, RightBottom.Scale(screen), WindowSize.Normal)
};
}
}
6 changes: 3 additions & 3 deletions src/Whim.TreeLayout/TreeLayoutEngineGetWindowLocations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public class TreeLayoutWindowLocation

public ILocation<int> Location { get; }

public WindowState WindowState { get; }
public WindowSize WindowState { get; }

public TreeLayoutWindowLocation(Node node, ILocation<int> location, WindowState windowState)
public TreeLayoutWindowLocation(Node node, ILocation<int> location, WindowSize windowState)
{
this.Node = node;
Location = location;
Expand All @@ -33,7 +33,7 @@ public static IEnumerable<TreeLayoutWindowLocation> GetWindowLocations(Node node
if (node is LeafNode)
{
yield return new TreeLayoutWindowLocation(
node, location, WindowState.Normal
node, location, WindowSize.Normal
);

yield break;
Expand Down
2 changes: 1 addition & 1 deletion src/Whim/Layout/ColumnLayoutEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override IEnumerable<IWindowLocation> DoLayout(ILocation<int> location)
{
yield return new WindowLocation(window,
new Location(x, y, width, height),
WindowState.Normal);
WindowSize.Normal);

if (LeftToRight)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Whim/Native/Win32Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,15 @@ public static void SetWindowPos(IWindowLocation windowLocation, HWND? hwndInsert
ILocation<int> offset = GetWindowOffset(window.Handle);
ILocation<int> location = Location.Add(windowLocation.Location, offset);

WindowState windowState = windowLocation.WindowState;
WindowSize windowState = windowLocation.WindowState;

SET_WINDOW_POS_FLAGS flags = SET_WINDOW_POS_FLAGS.SWP_FRAMECHANGED
| SET_WINDOW_POS_FLAGS.SWP_NOACTIVATE
| SET_WINDOW_POS_FLAGS.SWP_NOCOPYBITS
| SET_WINDOW_POS_FLAGS.SWP_NOZORDER
| SET_WINDOW_POS_FLAGS.SWP_NOOWNERZORDER;

if (windowState == WindowState.Maximized || windowState == WindowState.Minimized)
if (windowState == WindowSize.Maximized || windowState == WindowSize.Minimized)
{
flags = flags | SET_WINDOW_POS_FLAGS.SWP_NOMOVE | SET_WINDOW_POS_FLAGS.SWP_NOSIZE;
}
Expand All @@ -316,14 +316,14 @@ public static void SetWindowPos(IWindowLocation windowLocation, HWND? hwndInsert
location.Height,
flags);

if (windowState == WindowState.Maximized)
if (windowState == WindowSize.Maximized)
{
if (!window.IsMinimized)
{
MinimizeWindow(window.Handle);
}
}
else if (windowState == WindowState.Minimized)
else if (windowState == WindowSize.Minimized)
{
if (!window.IsMaximized)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Whim/Window/IWindowLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IWindowLocation
/// <summary>
/// The state of the window.
/// </summary>
public WindowState WindowState { get; set; }
public WindowSize WindowState { get; set; }

/// <summary>
/// The window in question.
Expand Down
4 changes: 2 additions & 2 deletions src/Whim/Window/WindowLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ public class WindowLocation : IWindowLocation
{
public ILocation<int> Location { get; set; }

public WindowState WindowState { get; set; }
public WindowSize WindowState { get; set; }

public IWindow Window { get; }

public WindowLocation(IWindow window, ILocation<int> location, WindowState windowState)
public WindowLocation(IWindow window, ILocation<int> location, WindowSize windowState)
{
Window = window;
Location = location;
Expand Down
22 changes: 22 additions & 0 deletions src/Whim/Window/WindowSize.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Whim;

/// <summary>
/// The size of a window.
/// </summary>
public enum WindowSize
{
/// <summary>
/// The window is in its normal state.
/// </summary>
Normal,

/// <summary>
/// The window is minimized.
/// </summary>
Minimized,

/// <summary>
/// The window is maximized.
/// </summary>
Maximized,
}
8 changes: 0 additions & 8 deletions src/Whim/Window/WindowState.cs

This file was deleted.

0 comments on commit bd8e707

Please sign in to comment.