Skip to content

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

feat(bar,domain): add 'position' property to bar config

Lyzef9be857a3084
diff --git a/GlazeWM.Bar/BarViewModel.cs b/GlazeWM.Bar/BarViewModel.cs
index 36489a21..6028f077 100644
--- a/GlazeWM.Bar/BarViewModel.cs
+++ b/GlazeWM.Bar/BarViewModel.cs
@@ -21,6 +21,7 @@ namespace GlazeWM.Bar
private UserConfigService _userConfigService = ServiceLocator.Provider.GetRequiredService<UserConfigService>();
private BarConfig _barConfig => _userConfigService.UserConfig.Bar;
+ public BarPosition Position => _barConfig.Position;
public string Background => _barConfig.Background;
public string Foreground => _barConfig.Foreground;
public string FontFamily => _barConfig.FontFamily;
diff --git a/GlazeWM.Bar/MainWindow.xaml.cs b/GlazeWM.Bar/MainWindow.xaml.cs
index 006cdd2b..74110c6f 100644
--- a/GlazeWM.Bar/MainWindow.xaml.cs
+++ b/GlazeWM.Bar/MainWindow.xaml.cs
@@ -70,11 +70,12 @@ namespace GlazeWM.Bar
// Since window size is set manually, need to scale up height to make window DPI responsive.
var barHeight = _userConfigService.UserConfig.Bar.Height;
var scaledBarHeight = Convert.ToInt32(barHeight * _monitor.ScaleFactor);
+ var barOffsetY = _userConfigService.UserConfig.Bar.Position == BarPosition.Bottom ? _monitor.Height - scaledBarHeight : 0;
// The first move puts it on the correct monitor, which triggers WM_DPICHANGED.
// The +1/-1 coerces WPF to update Top/Left/Width/Height in the second move.
- MoveWindow(windowHandle, _monitor.X + 1, _monitor.Y, _monitor.Width - 1, scaledBarHeight, false);
- MoveWindow(windowHandle, _monitor.X, _monitor.Y, _monitor.Width, scaledBarHeight, true);
+ MoveWindow(windowHandle, _monitor.X + 1, _monitor.Y + barOffsetY, _monitor.Width - 1, scaledBarHeight, false);
+ MoveWindow(windowHandle, _monitor.X, _monitor.Y + barOffsetY, _monitor.Width, scaledBarHeight, true);
}
}
}
diff --git a/GlazeWM.Bootstrapper/sample-config.yaml b/GlazeWM.Bootstrapper/sample-config.yaml
index 986d6ce0..d9b23aac 100644
--- a/GlazeWM.Bootstrapper/sample-config.yaml
+++ b/GlazeWM.Bootstrapper/sample-config.yaml
@@ -4,6 +4,7 @@ gaps:
bar:
height: 30
+ position: "top"
opacity: 1.0
background: "#101010"
foreground: "white"
diff --git a/GlazeWM.Domain/UserConfigs/BarConfig.cs b/GlazeWM.Domain/UserConfigs/BarConfig.cs
index 971f938d..f7c36f26 100644
--- a/GlazeWM.Domain/UserConfigs/BarConfig.cs
+++ b/GlazeWM.Domain/UserConfigs/BarConfig.cs
@@ -6,6 +6,8 @@ namespace GlazeWM.Domain.UserConfigs
public class BarConfig
{
public uint Height { get; set; } = 30;
+
+ public BarPosition Position { get; set; } = BarPosition.Top;
public double Opacity { get; set; } = 1.0;
diff --git a/GlazeWM.Domain/UserConfigs/BarPosition.cs b/GlazeWM.Domain/UserConfigs/BarPosition.cs
new file mode 100644
index 00000000..447470ff
--- /dev/null
+++ b/GlazeWM.Domain/UserConfigs/BarPosition.cs
@@ -0,0 +1,7 @@
+namespace GlazeWM.Domain.UserConfigs
+{
+ public enum BarPosition
+ {
+ Top, Bottom
+ }
+}
diff --git a/GlazeWM.Domain/Workspaces/Workspace.cs b/GlazeWM.Domain/Workspaces/Workspace.cs
index f5810efe..b224a398 100644
--- a/GlazeWM.Domain/Workspaces/Workspace.cs
+++ b/GlazeWM.Domain/Workspaces/Workspace.cs
@@ -34,7 +34,7 @@ namespace GlazeWM.Domain.Workspaces
public override int Height => Parent.Height - (OuterGap * 2) - LogicalBarHeight;
public override int Width => Parent.Width - (OuterGap * 2);
public override int X => Parent.X + OuterGap;
- public override int Y => Parent.Y + OuterGap + LogicalBarHeight;
+ public override int Y => Parent.Y + OuterGap + (_userConfigService.UserConfig.Bar.Position == BarPosition.Top ? LogicalBarHeight : 0);
/// <summary>
/// Whether the workspace itself or a descendant container has focus.