Skip to content

Commit

Permalink
feat: outer gaps supports multiple values (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxle5 authored Jul 23, 2023
1 parent 6fb4d2b commit b9e792b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion GlazeWM.Domain/UserConfigs/CommandParsingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public static List<string> ExtractProcessArgs(string processNameAndArgs)
return args.Where(arg => !string.IsNullOrWhiteSpace(arg)).ToList();
}

private static RectDelta ShorthandToRectDelta(string shorthand)
public static RectDelta ShorthandToRectDelta(string shorthand)
{
var shorthandParts = shorthand.Split(" ")
.Select(shorthandPart => UnitsHelper.TrimUnits(shorthandPart))
Expand Down
2 changes: 1 addition & 1 deletion GlazeWM.Domain/UserConfigs/GapsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ namespace GlazeWM.Domain.UserConfigs
public class GapsConfig
{
public int InnerGap { get; set; } = 20;
public int OuterGap { get; set; } = 20;
public string OuterGap { get; set; } = "20px";
}
}
15 changes: 8 additions & 7 deletions GlazeWM.Domain/Workspaces/Workspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using GlazeWM.Domain.UserConfigs;
using GlazeWM.Infrastructure;
using GlazeWM.Infrastructure.Utils;
using GlazeWM.Infrastructure.WindowsApi;

namespace GlazeWM.Domain.Workspaces
{
Expand Down Expand Up @@ -46,7 +47,7 @@ private int _yOffset
}
}

private int _outerGap => _userConfigService.GapsConfig.OuterGap;
private RectDelta _outerGaps => CommandParsingService.ShorthandToRectDelta(_userConfigService.GapsConfig.OuterGap);

private BarConfig barForMonitor => _userConfigService.GetBarConfigForMonitor(Parent as Monitor);
private int floatBarOffsetY => UnitsHelper.TrimUnits(barForMonitor.OffsetY);
Expand All @@ -57,25 +58,25 @@ public override int Height
{
if (!_userConfigService.GetBarConfigForMonitor(Parent as Monitor).Enabled)
{
return Parent.Height - (_outerGap * 2);
return Parent.Height - _outerGaps.Top - _outerGaps.Bottom;
}

return Parent.Height - (_outerGap * 2) - floatBarOffsetY - _logicalBarHeight;
return Parent.Height - _outerGaps.Top - _outerGaps.Bottom - floatBarOffsetY - _logicalBarHeight;
}
}

public override int Width => Parent.Width - (_outerGap * 2);
public override int X => Parent.X + _outerGap;
public override int Width => Parent.Width - _outerGaps.Left - _outerGaps.Right;
public override int X => Parent.X + _outerGaps.Left;
public override int Y
{
get
{
if (!_userConfigService.GetBarConfigForMonitor(Parent as Monitor).Enabled)
{
return Parent.Y + _outerGap;
return Parent.Y + _outerGaps.Top;
}

return Parent.Y + _outerGap + _yOffset + floatBarOffsetY;
return Parent.Y + _outerGaps.Top + _yOffset + floatBarOffsetY;
}
}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ gaps:
# Gap between adjacent windows.
inner_gap: 20
# Gap between windows and the screen edge.
outer_gap: 20
# Gap between windows and the screen edge. See "Shorthand properties" for more info.
outer_gap: "20px 0 20px 0"
```

## Workspaces configuration
Expand Down

0 comments on commit b9e792b

Please sign in to comment.