Skip to content

Commit

Permalink
Add handling for FloatingLayoutEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
dalyIsaac committed Nov 3, 2024
1 parent 86eace7 commit 5fe81d7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Whim.Gaps/GapsLayoutEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,27 @@ private GapsLayoutEngine UpdateInner(ILayoutEngine newInnerLayoutEngine) =>
/// <inheritdoc />
public override IEnumerable<IWindowState> DoLayout(IRectangle<int> rectangle, IMonitor monitor)
{
// If the inner layout engine is a floating layout engine, then we don't apply gaps.
if (InnerLayoutEngine.GetLayoutEngine<FloatingLayoutEngine>() is not null)
{

Check warning on line 48 in src/Whim.Gaps/GapsLayoutEngine.cs

View check run for this annotation

Codecov / codecov/patch

src/Whim.Gaps/GapsLayoutEngine.cs#L48

Added line #L48 was not covered by tests
foreach (IWindowState windowState in InnerLayoutEngine.DoLayout(rectangle, monitor))
{
yield return windowState;
}
yield break;

Check warning on line 53 in src/Whim.Gaps/GapsLayoutEngine.cs

View check run for this annotation

Codecov / codecov/patch

src/Whim.Gaps/GapsLayoutEngine.cs#L50-L53

Added lines #L50 - L53 were not covered by tests
}

// If the inner layout engine is a proxy floating layout engine, then we apply gaps for the non-floating windows.
int nonProxiedCount = 0;
if (InnerLayoutEngine is ProxyFloatingLayoutEngine proxy)
if (InnerLayoutEngine.GetLayoutEngine<ProxyFloatingLayoutEngine>() is ProxyFloatingLayoutEngine proxy)
{
nonProxiedCount = proxy.FloatingWindowRects.Count + proxy.MinimizedWindowRects.Count;

// The InnerLayoutEngine will use the default rectangle for nonProxiedCount.
// The InnerLayoutEngine will use the proxied rectangle for the remaining windows.
// This is brittle and relies on the order of the windows in the ProxyFloatingLayoutEngine.

IEnumerable<IWindowState> windows = InnerLayoutEngine.DoLayout(rectangle, monitor);
IEnumerable<IWindowState> windows = proxy.DoLayout(rectangle, monitor);
using IEnumerator<IWindowState> enumerator = windows.GetEnumerator();

for (int i = 0; i < nonProxiedCount; i++)
Expand Down

0 comments on commit 5fe81d7

Please sign in to comment.