Skip to content

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

feat: add option to disable bar windows (#260)

Zinvokec9be86fc2c76
diff --git a/.gitignore b/.gitignore
index d65bb0df..fecc066b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -232,3 +232,6 @@ _Pvt_Extensions
# FAKE - F# Make
.fake/
+
+# IDEA files
+.idea/
diff --git a/GlazeWM.Bar/BarService.cs b/GlazeWM.Bar/BarService.cs
index d7b98e8a..75db0706 100644
--- a/GlazeWM.Bar/BarService.cs
+++ b/GlazeWM.Bar/BarService.cs
@@ -84,11 +84,16 @@ namespace GlazeWM.Bar
public void ShowWindow(Domain.Monitors.Monitor targetMonitor)
{
+ var barConfig = _userConfigService.GetBarConfigForMonitor(targetMonitor);
+
+ if (!barConfig.Enabled)
+ {
+ return;
+ }
+
_application.Dispatcher.Invoke(() =>
{
var originalFocusedHandle = GetForegroundWindow();
-
- var barConfig = _userConfigService.GetBarConfigForMonitor(targetMonitor);
var barViewModel = new BarViewModel(
targetMonitor,
_application.Dispatcher,
@@ -112,7 +117,7 @@ namespace GlazeWM.Bar
{
// Kill the corresponding bar window.
var barWindow = _activeWindowsByDeviceName.GetValueOrDefault(deviceName);
- barWindow.Close();
+ barWindow?.Close();
});
}
}
diff --git a/GlazeWM.Bootstrapper/Startup.cs b/GlazeWM.Bootstrapper/Startup.cs
index 1ec0aaa6..21d2787d 100644
--- a/GlazeWM.Bootstrapper/Startup.cs
+++ b/GlazeWM.Bootstrapper/Startup.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Reactive.Linq;
using System.Windows.Forms;
using GlazeWM.Bar;
diff --git a/GlazeWM.Domain/Containers/JsonContainerConverter.cs b/GlazeWM.Domain/Containers/JsonContainerConverter.cs
index 911888b9..e1eb0992 100644
--- a/GlazeWM.Domain/Containers/JsonContainerConverter.cs
+++ b/GlazeWM.Domain/Containers/JsonContainerConverter.cs
@@ -1,5 +1,4 @@
using System;
-using System.Globalization;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -145,9 +144,9 @@ namespace GlazeWM.Domain.Containers
return;
case MinimizedWindow:
var minimizedWindow = value as MinimizedWindow;
- writer.WriteString(
+ writer.WriteNumber(
"Handle",
- minimizedWindow.Handle.ToString("x", CultureInfo.InvariantCulture)
+ minimizedWindow.Handle.ToInt64()
);
writer.WritePropertyName("FloatingPlacement");
JsonSerializer.Serialize(writer, minimizedWindow.FloatingPlacement);
@@ -157,9 +156,9 @@ namespace GlazeWM.Domain.Containers
return;
case FloatingWindow:
var floatingWindow = value as FloatingWindow;
- writer.WriteString(
+ writer.WriteNumber(
"Handle",
- floatingWindow.Handle.ToString("x", CultureInfo.InvariantCulture)
+ floatingWindow.Handle.ToInt64()
);
writer.WritePropertyName("FloatingPlacement");
JsonSerializer.Serialize(writer, floatingWindow.FloatingPlacement);
@@ -168,9 +167,9 @@ namespace GlazeWM.Domain.Containers
return;
case TilingWindow:
var tilingWindow = value as TilingWindow;
- writer.WriteString(
+ writer.WriteNumber(
"Handle",
- tilingWindow.Handle.ToString("x", CultureInfo.InvariantCulture)
+ tilingWindow.Handle.ToInt64()
);
writer.WritePropertyName("FloatingPlacement");
JsonSerializer.Serialize(writer, tilingWindow.FloatingPlacement);
diff --git a/GlazeWM.Domain/UserConfigs/BarConfig.cs b/GlazeWM.Domain/UserConfigs/BarConfig.cs
index ffc0f4a1..5833c97f 100644
--- a/GlazeWM.Domain/UserConfigs/BarConfig.cs
+++ b/GlazeWM.Domain/UserConfigs/BarConfig.cs
@@ -4,6 +4,8 @@ namespace GlazeWM.Domain.UserConfigs
{
public class BarConfig
{
+ public bool Enabled { get; set; } = true;
+
public string OffsetX { get; set; } = "0px";
public string OffsetY { get; set; } = "0px";
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs
index b830df03..b43fb38c 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs
@@ -9,7 +9,6 @@ using GlazeWM.Domain.UserConfigs;
using GlazeWM.Domain.Windows.Commands;
using GlazeWM.Domain.Workspaces;
using GlazeWM.Infrastructure.Bussing;
-using GlazeWM.Infrastructure.Common.Events;
using GlazeWM.Infrastructure.Utils;
using GlazeWM.Infrastructure.WindowsApi;
@@ -246,8 +245,8 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
amount = units switch
{
- "%" => (int)(amount * currentMonitor.Width / 100),
- "ppt" => (int)(amount * currentMonitor.Width / 100),
+ "%" => amount * currentMonitor.Width / 100,
+ "ppt" => amount * currentMonitor.Width / 100,
"px" => amount,
// in case user only provided a number in the config;
// TODO: somehow validate floating_window_move_amount in config on startup
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs
index 5248bfde..5eb3259a 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs
@@ -10,7 +10,6 @@ using GlazeWM.Domain.Monitors;
using GlazeWM.Domain.Windows.Commands;
using GlazeWM.Domain.Workspaces;
using GlazeWM.Infrastructure.Bussing;
-using GlazeWM.Infrastructure.Common.Events;
using GlazeWM.Infrastructure.Exceptions;
using GlazeWM.Infrastructure.WindowsApi;
@@ -139,7 +138,7 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
var resizePercentage = ConvertToResizePercentage(windowToResize, dimensionToResize, resizeAmount);
var currentMonitor = MonitorService.GetMonitorFromChildContainer(windowToResize);
- int amount = (int)(currentMonitor.Width * resizePercentage);
+ var amount = (int)(currentMonitor.Width * resizePercentage);
var width = windowToResize.FloatingPlacement.Width;
var height = windowToResize.FloatingPlacement.Height;
diff --git a/GlazeWM.Domain/Workspaces/Workspace.cs b/GlazeWM.Domain/Workspaces/Workspace.cs
index 8b1f202b..3babbab4 100644
--- a/GlazeWM.Domain/Workspaces/Workspace.cs
+++ b/GlazeWM.Domain/Workspaces/Workspace.cs
@@ -51,10 +51,33 @@ namespace GlazeWM.Domain.Workspaces
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 Height
+ {
+ get
+ {
+ if (!_userConfigService.GetBarConfigForMonitor(Parent as Monitor).Enabled)
+ {
+ return Parent.Height - (_outerGap * 2);
+ }
+
+ return 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 + floatBarOffsetY;
+ public override int Y
+ {
+ get
+ {
+ if (!_userConfigService.GetBarConfigForMonitor(Parent as Monitor).Enabled)
+ {
+ return Parent.Y + _outerGap;
+ }
+
+ return Parent.Y + _outerGap + _yOffset + floatBarOffsetY;
+ }
+ }
/// <summary>
/// Whether the workspace itself or a descendant container has focus.
diff --git a/README.md b/README.md
index c47fe5b8..28863520 100644
--- a/README.md
+++ b/README.md
@@ -141,6 +141,9 @@ The appearance of the bar can be changed via the `bar` property in the config fi
```yaml
bar:
+ # The option to enable/disable the bar.
+ enabled: true
+
# Height of the bar in pixels.
height: "30px"