Skip to content

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

feat(bar): format border width to be compatible with WPF `BorderThickness`

Lars Berger6fb9359ca93d
diff --git a/GlazeWM.Bar/BarViewModel.cs b/GlazeWM.Bar/BarViewModel.cs
index 0b2c198d..83fcce58 100644
--- a/GlazeWM.Bar/BarViewModel.cs
+++ b/GlazeWM.Bar/BarViewModel.cs
@@ -35,11 +35,28 @@ namespace GlazeWM.Bar
FontFamily = _barConfig.FontFamily;
FontSize = _barConfig.FontSize;
BorderColor = _barConfig.BorderColor;
- BorderWidth = _barConfig.BorderWidth;
+ BorderWidth = FormatBorderWidth(_barConfig.BorderWidth);
UpdateWorkspaces();
}
+ /// <summary>
+ /// Format border width from user config to be compatible with `BorderThickness`.
+ /// </summary>
+ private string FormatBorderWidth(string borderWidth)
+ {
+ var borderWidthParts = borderWidth.Split(" ");
+
+ return borderWidthParts.Count() switch
+ {
+ 1 => borderWidth,
+ 2 => $"{borderWidthParts[1]},{borderWidthParts[0]},{borderWidthParts[1]},{borderWidthParts[0]}",
+ 3 => $"{borderWidthParts[1]},{borderWidthParts[0]},{borderWidthParts[1]},{borderWidthParts[2]}",
+ 4 => $"{borderWidthParts[3]},{borderWidthParts[0]},{borderWidthParts[1]},{borderWidthParts[2]}",
+ _ => throw new ArgumentException(),
+ };
+ }
+
public void UpdateWorkspaces()
{
_dispatcher.Invoke(() =>