Skip to content

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

feat: add custom X & Y offset for bar position (#217)

blameea7c9cb5196
diff --git a/GlazeWM.Bar/BarViewModel.cs b/GlazeWM.Bar/BarViewModel.cs
index b758859f..68034044 100644
--- a/GlazeWM.Bar/BarViewModel.cs
+++ b/GlazeWM.Bar/BarViewModel.cs
@@ -23,6 +23,7 @@ namespace GlazeWM.Bar
public string FontSize => XamlHelper.FormatSize(BarConfig.FontSize);
public string BorderColor => XamlHelper.FormatColor(BarConfig.BorderColor);
public string BorderWidth => XamlHelper.FormatRectShorthand(BarConfig.BorderWidth);
+ public string BorderRadius => XamlHelper.FormatSize(BarConfig.BorderRadius);
public string Padding => XamlHelper.FormatRectShorthand(BarConfig.Padding);
public double Opacity => BarConfig.Opacity;
diff --git a/GlazeWM.Bar/MainWindow.xaml b/GlazeWM.Bar/MainWindow.xaml
index 55966426..a06a9958 100644
--- a/GlazeWM.Bar/MainWindow.xaml
+++ b/GlazeWM.Bar/MainWindow.xaml
@@ -21,6 +21,7 @@
AllowsTransparency="True"
Topmost="False">
<Border
+ CornerRadius="{Binding BorderRadius}"
BorderThickness="{Binding BorderWidth}"
BorderBrush="{Binding BorderColor}">
<Grid Margin="{Binding Padding}">
diff --git a/GlazeWM.Bar/MainWindow.xaml.cs b/GlazeWM.Bar/MainWindow.xaml.cs
index e1b3b8c4..4227d2f3 100644
--- a/GlazeWM.Bar/MainWindow.xaml.cs
+++ b/GlazeWM.Bar/MainWindow.xaml.cs
@@ -70,22 +70,26 @@ namespace GlazeWM.Bar
? _monitor.Height - scaledBarHeight
: 0;
+ var barConfig = _userConfigService.GetBarConfigForMonitor(_monitor);
+ var floatBarOffsetX = UnitsHelper.TrimUnits(barConfig.OffsetX);
+ var floatBarOffsetY = UnitsHelper.TrimUnits(barConfig.OffsetY);
+
// The first move puts it on the correct monitor, which triggers WM_DPICHANGED.
MoveWindow(
windowHandle,
- _monitor.X + 1,
- _monitor.Y + barOffsetY,
- _monitor.Width - 1,
+ _monitor.X + floatBarOffsetX,
+ _monitor.Y + barOffsetY + floatBarOffsetY,
+ _monitor.Width - (floatBarOffsetX * 2),
scaledBarHeight,
- false
+ true
);
// The +1/-1 coerces WPF to update Top/Left/Width/Height in the second move.
MoveWindow(
windowHandle,
- _monitor.X,
- _monitor.Y + barOffsetY,
- _monitor.Width,
+ _monitor.X + floatBarOffsetX,
+ _monitor.Y + barOffsetY + floatBarOffsetY,
+ _monitor.Width - (floatBarOffsetX * 2),
scaledBarHeight,
true
);
diff --git a/GlazeWM.Bootstrapper/sample-config.yaml b/GlazeWM.Bootstrapper/sample-config.yaml
index aff190e6..8489304d 100644
--- a/GlazeWM.Bootstrapper/sample-config.yaml
+++ b/GlazeWM.Bootstrapper/sample-config.yaml
@@ -8,6 +8,9 @@ general:
cursor_follows_focus: true
bar:
+ offset_x: "0px"
+ offset_y: "0px"
+ border_radius: "0px"
height: "30px"
position: "top"
opacity: 1.0
diff --git a/GlazeWM.Domain/UserConfigs/BarConfig.cs b/GlazeWM.Domain/UserConfigs/BarConfig.cs
index de28d45f..ffc0f4a1 100644
--- a/GlazeWM.Domain/UserConfigs/BarConfig.cs
+++ b/GlazeWM.Domain/UserConfigs/BarConfig.cs
@@ -4,6 +4,12 @@ namespace GlazeWM.Domain.UserConfigs
{
public class BarConfig
{
+ public string OffsetX { get; set; } = "0px";
+
+ public string OffsetY { get; set; } = "0px";
+
+ public string BorderRadius { get; set; } = "0px";
+
public string Height { get; set; } = "30px";
public BarPosition Position { get; set; } = BarPosition.Top;
diff --git a/GlazeWM.Domain/Workspaces/Workspace.cs b/GlazeWM.Domain/Workspaces/Workspace.cs
index d8f62f91..8b1f202b 100644
--- a/GlazeWM.Domain/Workspaces/Workspace.cs
+++ b/GlazeWM.Domain/Workspaces/Workspace.cs
@@ -48,10 +48,13 @@ namespace GlazeWM.Domain.Workspaces
private int _outerGap => _userConfigService.GapsConfig.OuterGap;
- public override int Height => Parent.Height - (_outerGap * 2) - _logicalBarHeight;
+ private BarConfig barForMonitor => _userConfigService.GetBarConfigForMonitor(Parent as Monitor);
+ private int floatBarOffsetY => UnitsHelper.TrimUnits(barForMonitor.OffsetY);
+
+ public override int Height => Parent.Height - (_outerGap * 2) - floatBarOffsetY - _logicalBarHeight;
public override int Width => Parent.Width - (_outerGap * 2);
public override int X => Parent.X + _outerGap;
- public override int Y => Parent.Y + _outerGap + _yOffset;
+ public override int Y => Parent.Y + _outerGap + _yOffset + floatBarOffsetY;
/// <summary>
/// Whether the workspace itself or a descendant container has focus.