Skip to content

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

feat: update all bar components to new label parser (#399)

lars-berger6ec79d27fb9a
diff --git a/GlazeWM.Bar/Components/BindingModeComponent.xaml b/GlazeWM.Bar/Components/BindingModeComponent.xaml
index abcc4f21..f61656bf 100644
--- a/GlazeWM.Bar/Components/BindingModeComponent.xaml
+++ b/GlazeWM.Bar/Components/BindingModeComponent.xaml
@@ -4,13 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:GlazeWM.Bar.Components"
+ xmlns:components="clr-namespace:GlazeWM.Bar.Components"
mc:Ignorable="d">
- <TextBlock
- VerticalAlignment="Center"
- Foreground="{Binding Foreground}"
- FontFamily="{Binding FontFamily}"
- FontWeight="{Binding FontWeight}"
- FontSize="{Binding FontSize}"
- Text="{Binding ActiveBindingMode}" />
+ <components:LabelComponent DataContext="{Binding Label}" />
</UserControl>
diff --git a/GlazeWM.Bar/Components/BindingModeComponentViewModel.cs b/GlazeWM.Bar/Components/BindingModeComponentViewModel.cs
index 96eef576..800ff603 100644
--- a/GlazeWM.Bar/Components/BindingModeComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/BindingModeComponentViewModel.cs
@@ -1,6 +1,6 @@
using System;
+using System.Collections.Generic;
using System.Reactive.Linq;
-using System.Windows.Threading;
using GlazeWM.Domain.Common.Events;
using GlazeWM.Domain.Containers;
using GlazeWM.Domain.UserConfigs;
@@ -11,7 +11,7 @@ namespace GlazeWM.Bar.Components
{
public class BindingModeComponentViewModel : ComponentViewModel
{
- private Dispatcher _dispatcher => _parentViewModel.Dispatcher;
+ private readonly BindingModeComponentConfig _config;
private readonly Bus _bus = ServiceLocator.GetRequiredService<Bus>();
private readonly ContainerService _containerService =
ServiceLocator.GetRequiredService<ContainerService>();
@@ -27,17 +27,36 @@ namespace GlazeWM.Bar.Components
public override string Visibility =>
ActiveBindingMode is null ? "Collapsed" : "Visible";
+ private LabelViewModel _label;
+ public LabelViewModel Label
+ {
+ get => _label;
+ protected set => SetField(ref _label, value);
+ }
+
public BindingModeComponentViewModel(
BarViewModel parentViewModel,
BindingModeComponentConfig config) : base(parentViewModel, config)
{
- _bus.Events.OfType<BindingModeChangedEvent>().Subscribe(_ =>
- _dispatcher.Invoke(() =>
+ _config = config;
+
+ _bus.Events.OfType<BindingModeChangedEvent>()
+ .TakeUntil(_parentViewModel.WindowClosing)
+ .Subscribe((@event) =>
{
OnPropertyChanged(nameof(Visibility));
- OnPropertyChanged(nameof(ActiveBindingMode));
- })
- );
+ Label = CreateLabel(@event.NewBindingMode);
+ });
+ }
+
+ private LabelViewModel CreateLabel(string bindingMode)
+ {
+ var variableDictionary = new Dictionary<string, Func<string>>()
+ {
+ { "binding_mode", () => bindingMode }
+ };
+
+ return XamlHelper.ParseLabel(_config.Label, variableDictionary, this);
}
}
}
diff --git a/GlazeWM.Bar/Components/ClockComponent.xaml b/GlazeWM.Bar/Components/ClockComponent.xaml
index 3f7a7f63..23a523fd 100644
--- a/GlazeWM.Bar/Components/ClockComponent.xaml
+++ b/GlazeWM.Bar/Components/ClockComponent.xaml
@@ -4,13 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:GlazeWM.Bar.Components"
+ xmlns:components="clr-namespace:GlazeWM.Bar.Components"
mc:Ignorable="d">
- <TextBlock
- VerticalAlignment="Center"
- Foreground="{Binding Foreground}"
- FontFamily="{Binding FontFamily}"
- FontWeight="{Binding FontWeight}"
- FontSize="{Binding FontSize}"
- Text="{Binding FormattedTime}" />
+ <components:LabelComponent DataContext="{Binding Label}" />
</UserControl>
diff --git a/GlazeWM.Bar/Components/ClockComponentViewModel.cs b/GlazeWM.Bar/Components/ClockComponentViewModel.cs
index 5b0c4f05..0fe8e117 100644
--- a/GlazeWM.Bar/Components/ClockComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/ClockComponentViewModel.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Globalization;
using System.Reactive.Linq;
using System.Text;
@@ -8,13 +9,43 @@ namespace GlazeWM.Bar.Components
{
public class ClockComponentViewModel : ComponentViewModel
{
- private ClockComponentConfig _config => _componentConfig as ClockComponentConfig;
- private string _timeFormatting => FormatCalendarWeek(_config.TimeFormatting);
+ private readonly ClockComponentConfig _config;
+ private LabelViewModel _label;
+ public LabelViewModel Label
+ {
+ get => _label;
+ protected set => SetField(ref _label, value);
+ }
+
+ public ClockComponentViewModel(
+ BarViewModel parentViewModel,
+ ClockComponentConfig config) : base(parentViewModel, config)
+ {
+ _config = config;
+
+ // Update the displayed time every second.
+ var updateInterval = TimeSpan.FromSeconds(1);
+
+ Observable
+ .Interval(updateInterval)
+ .TakeUntil(_parentViewModel.WindowClosing)
+ .Subscribe(_ => Label = CreateLabel());
+ }
+
+ private LabelViewModel CreateLabel()
+ {
+ var timeFormatting = FormatCalendarWeek(_config.TimeFormatting);
- /// <summary>
- /// Format the current time with the user's formatting config.
- /// </summary>
- public string FormattedTime => DateTime.Now.ToString(_timeFormatting, CultureInfo.InvariantCulture);
+ // Format the current time with the user's formatting config.
+ var formattedTime = DateTime.Now.ToString(timeFormatting, CultureInfo.InvariantCulture);
+
+ var variableDictionary = new Dictionary<string, Func<string>>()
+ {
+ { "formatted_time", () => formattedTime }
+ };
+
+ return XamlHelper.ParseLabel(_config.Label, variableDictionary, this);
+ }
private static string FormatCalendarWeek(string timeFormat)
{
@@ -59,18 +90,5 @@ namespace GlazeWM.Bar.Components
}
return result.ToString();
}
-
- public ClockComponentViewModel(
- BarViewModel parentViewModel,
- ClockComponentConfig config) : base(parentViewModel, config)
- {
- // Update the displayed time every second.
- var updateInterval = TimeSpan.FromSeconds(1);
-
- Observable
- .Interval(updateInterval)
- .TakeUntil(_parentViewModel.WindowClosing)
- .Subscribe(_ => OnPropertyChanged(nameof(FormattedTime)));
- }
}
}
diff --git a/GlazeWM.Bar/Components/LabelComponent.xaml b/GlazeWM.Bar/Components/LabelComponent.xaml
index 38633eeb..94040d2d 100644
--- a/GlazeWM.Bar/Components/LabelComponent.xaml
+++ b/GlazeWM.Bar/Components/LabelComponent.xaml
@@ -16,7 +16,6 @@
<TextBlock
Text="{Binding Text}"
VerticalAlignment="Center"
- Background="{Binding Background}"
Foreground="{Binding Foreground}"
FontFamily="{Binding FontFamily}"
FontWeight="{Binding FontWeight}"
diff --git a/GlazeWM.Bar/Components/LabelSpan.cs b/GlazeWM.Bar/Components/LabelSpan.cs
index cb76e02a..72d7ef54 100644
--- a/GlazeWM.Bar/Components/LabelSpan.cs
+++ b/GlazeWM.Bar/Components/LabelSpan.cs
@@ -3,7 +3,6 @@ namespace GlazeWM.Bar.Components
public class LabelSpan
{
public string Text { get; }
- public string Background { get; }
public string Foreground { get; }
public string FontFamily { get; }
public string FontWeight { get; }
@@ -11,14 +10,12 @@ namespace GlazeWM.Bar.Components
public LabelSpan(
string text,
- string background,
string foreground,
string fontFamily,
string fontWeight,
string fontSize)
{
Text = text;
- Background = background;
Foreground = foreground;
FontFamily = fontFamily;
FontWeight = fontWeight;
@@ -26,71 +23,3 @@ namespace GlazeWM.Bar.Components
}
}
}
-
-/// Usage:
-/**
-public class BatteryComponentViewModel : ComponentViewModel
-{
- private readonly BatteryComponentConfig _config;
-
- private LabelViewModel _label;
- public string Label
- {
- get => _label;
- protected set => SetField(ref _label, value);
- }
-
- public BatteryComponentViewModel(...) : base(parentViewModel, config)
- {
- _batteryComponentConfig = config;
-
- Label = XamlHelper.ParseLabel(config.Label, CreateVariableDict());
-
- Observable
- .Interval(TimeSpan.FromSeconds(3))
- .TakeUntil(_parentViewModel.WindowClosing)
- .Subscribe(_ => {
- Label.UpdateVariables(CreateVariableDict());
- OnPropertyChanged(nameof(Label));
- });
- }
-}
-*/
-
-/// Alternatively:
-/**
-public class BatteryComponentViewModel : ComponentViewModel
-{
- private readonly BatteryComponentConfig _config;
-
- private LabelViewModel _label;
- public string Label
- {
- get => _label;
- protected set => SetField(ref _label, value);
- }
-
- public BatteryComponentViewModel(...) : base(parentViewModel, config)
- {
- _batteryComponentConfig = config;
-
- Label = XamlHelper.ParseLabel(config.Label, GetVariableDict());
-
- Observable
- .Interval(TimeSpan.FromSeconds(3))
- .TakeUntil(_parentViewModel.WindowClosing)
- .Subscribe(_ => {
- Label.UpdateVariables();
- OnPropertyChanged(nameof(Label));
- });
- }
-
- public Dictionary<string, Action<string>> GetVariableDict()
- {
- return new()
- {
- { "battery_level", () => GetBatteryLevel() }
- }
- }
-}
-*/
diff --git a/GlazeWM.Bar/Components/SystemTrayComponent.xaml b/GlazeWM.Bar/Components/SystemTrayComponent.xaml
index 810dd293..3bc83bf5 100644
--- a/GlazeWM.Bar/Components/SystemTrayComponent.xaml
+++ b/GlazeWM.Bar/Components/SystemTrayComponent.xaml
@@ -1,25 +1,30 @@
<UserControl
x:Class="GlazeWM.Bar.Components.SystemTrayComponent"
+ x:Name="_workspacesComponent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:GlazeWM.Bar.Components"
+ xmlns:components="clr-namespace:GlazeWM.Bar.Components"
+ xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</UserControl.Resources>
<StackPanel Orientation="Horizontal">
- <Button
- Background="{Binding Background}"
- Foreground="{Binding Foreground}"
- FontFamily="{Binding FontFamily}"
- Content="{Binding ExpandCollapseText}"
- FontWeight="{Binding FontWeight}"
- FontSize="{Binding FontSize}"
- Command="{Binding ToggleShowAllIconsCommand}"
- BorderThickness="0"
- Cursor="Hand" />
+ <components:LabelComponent
+ DataContext="{Binding Label}"
+ MouseEnter="OnLabelHoverEnter"
+ MouseLeave="OnLabelHoverLeave">
+ <i:Interaction.Triggers>
+ <i:EventTrigger EventName="MouseLeftButtonDown">
+ <i:CallMethodAction
+ MethodName="ToggleShowAllIcons"
+ TargetObject="{Binding Path=DataContext, ElementName=_workspacesComponent, Mode=OneWay}" />
+ </i:EventTrigger>
+ </i:Interaction.Triggers>
+ </components:LabelComponent>
<Border
x:Name="NotifyIconBorder"
ToolTip="{Binding Path=TrayIcon.Title}"
diff --git a/GlazeWM.Bar/Components/SystemTrayComponent.xaml.cs b/GlazeWM.Bar/Components/SystemTrayComponent.xaml.cs
index 08c707ca..d8b3ee54 100644
--- a/GlazeWM.Bar/Components/SystemTrayComponent.xaml.cs
+++ b/GlazeWM.Bar/Components/SystemTrayComponent.xaml.cs
@@ -1,4 +1,5 @@
using System.Windows.Controls;
+using System.Windows.Input;
namespace GlazeWM.Bar.Components
{
@@ -11,5 +12,15 @@ namespace GlazeWM.Bar.Components
{
InitializeComponent();
}
+
+ public void OnLabelHoverEnter(object sender, MouseEventArgs e)
+ {
+ Cursor = Cursors.Hand;
+ }
+
+ public void OnLabelHoverLeave(object sender, MouseEventArgs e)
+ {
+ Cursor = Cursors.Arrow;
+ }
}
}
diff --git a/GlazeWM.Bar/Components/SystemTrayComponentViewModel.cs b/GlazeWM.Bar/Components/SystemTrayComponentViewModel.cs
index 76dac039..1d6766c9 100644
--- a/GlazeWM.Bar/Components/SystemTrayComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/SystemTrayComponentViewModel.cs
@@ -1,5 +1,7 @@
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics;
using System.Linq;
using System.Windows.Input;
using GlazeWM.Bar.Common;
@@ -16,8 +18,6 @@ namespace GlazeWM.Bar.Components
private readonly ShellManager _shellManager =
ServiceLocator.GetRequiredService<ShellManager>();
- public ICommand ToggleShowAllIconsCommand => new RelayCommand(ToggleShowAllIcons);
-
private bool _isExpanded = true;
public bool IsExpanded
{
@@ -29,9 +29,9 @@ namespace GlazeWM.Bar.Components
}
}
- public string ExpandCollapseText => IsExpanded
- ? _config.LabelCollapseText
- : _config.LabelExpandText;
+ public LabelViewModel Label => IsExpanded
+ ? XamlHelper.ParseLabel(_config.LabelCollapseText, new Dictionary<string, Func<string>>(), this)
+ : XamlHelper.ParseLabel(_config.LabelExpandText, new Dictionary<string, Func<string>>(), this);
public ObservableCollection<NotifyIconViewModel> PinnedTrayIcons =>
new(_pinnedTrayIcons);
@@ -64,7 +64,7 @@ namespace GlazeWM.Bar.Components
public void ToggleShowAllIcons()
{
IsExpanded = !IsExpanded;
- OnPropertyChanged(nameof(ExpandCollapseText));
+ OnPropertyChanged(nameof(Label));
}
}
}
diff --git a/GlazeWM.Bar/Components/TilingDirectionComponent.xaml b/GlazeWM.Bar/Components/TilingDirectionComponent.xaml
index 1d244c7a..9031eadc 100644
--- a/GlazeWM.Bar/Components/TilingDirectionComponent.xaml
+++ b/GlazeWM.Bar/Components/TilingDirectionComponent.xaml
@@ -4,13 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:GlazeWM.Bar.Components"
+ xmlns:components="clr-namespace:GlazeWM.Bar.Components"
mc:Ignorable="d">
- <TextBlock
- VerticalAlignment="Center"
- Foreground="{Binding Foreground}"
- FontFamily="{Binding FontFamily}"
- FontWeight="{Binding FontWeight}"
- FontSize="{Binding FontSize}"
- Text="{Binding TilingDirectionString}" />
+ <components:LabelComponent DataContext="{Binding Label}" />
</UserControl>
diff --git a/GlazeWM.Bar/Components/TilingDirectionComponentViewModel.cs b/GlazeWM.Bar/Components/TilingDirectionComponentViewModel.cs
index fc275a5b..85c5f47d 100644
--- a/GlazeWM.Bar/Components/TilingDirectionComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/TilingDirectionComponentViewModel.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Reactive.Linq;
using System.Windows.Threading;
using GlazeWM.Domain.Common.Enums;
@@ -17,31 +18,41 @@ namespace GlazeWM.Bar.Components
private readonly ContainerService _containerService =
ServiceLocator.GetRequiredService<ContainerService>();
- private TilingDirectionComponentConfig _config => _componentConfig as TilingDirectionComponentConfig;
+ private readonly TilingDirectionComponentConfig _config;
- private string LabelVertical => _config.LabelVertical;
- private string LabelHorizontal => _config.LabelHorizontal;
-
- /// <summary>
- /// The tiling direction of the currently focused container. Can be null on app
- /// startup when workspaces haven't been created yet.
- /// </summary>
- private TilingDirection? _tilingDirection =>
- (_containerService.FocusedContainer as SplitContainer)?.TilingDirection ??
- (_containerService.FocusedContainer.Parent as SplitContainer)?.TilingDirection;
-
- public string TilingDirectionString =>
- _tilingDirection == TilingDirection.Vertical ? LabelVertical : LabelHorizontal;
+ private LabelViewModel _label;
+ public LabelViewModel Label
+ {
+ get => _label;
+ protected set => SetField(ref _label, value);
+ }
public TilingDirectionComponentViewModel(
BarViewModel parentViewModel,
TilingDirectionComponentConfig config) : base(parentViewModel, config)
{
+ _config = config;
+
_bus.Events.Where(
(@event) => @event is TilingDirectionChangedEvent or FocusChangedEvent
- ).Subscribe((_) =>
- _dispatcher.Invoke(() => OnPropertyChanged(nameof(TilingDirectionString)))
- );
+ )
+ .TakeUntil(_parentViewModel.WindowClosing)
+ .Subscribe((_) => _dispatcher.Invoke(() => Label = CreateLabel()));
+ }
+
+ private LabelViewModel CreateLabel()
+ {
+ // The tiling direction of the currently focused container. Can be null on app
+ // startup when workspaces haven't been created yet.
+ var tilingDirection =
+ (_containerService.FocusedContainer as SplitContainer)?.TilingDirection ??
+ (_containerService.FocusedContainer.Parent as SplitContainer)?.TilingDirection;
+
+ var label = tilingDirection == TilingDirection.Vertical
+ ? _config.LabelVertical
+ : _config.LabelHorizontal;
+
+ return XamlHelper.ParseLabel(label, new Dictionary<string, Func<string>>(), this);
}
}
}
diff --git a/GlazeWM.Bar/Components/WindowTitleComponent.xaml b/GlazeWM.Bar/Components/WindowTitleComponent.xaml
index a199a6b6..733c945a 100644
--- a/GlazeWM.Bar/Components/WindowTitleComponent.xaml
+++ b/GlazeWM.Bar/Components/WindowTitleComponent.xaml
@@ -4,13 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:GlazeWM.Bar.Components"
+ xmlns:components="clr-namespace:GlazeWM.Bar.Components"
mc:Ignorable="d">
- <TextBlock
- VerticalAlignment="Center"
- Foreground="{Binding Foreground}"
- FontFamily="{Binding FontFamily}"
- FontWeight="{Binding FontWeight}"
- FontSize="{Binding FontSize}"
- Text="{Binding FocusedWindowTitle}" />
+ <components:LabelComponent DataContext="{Binding Label}" />
</UserControl>
diff --git a/GlazeWM.Bar/Components/WindowTitleComponentViewModel.cs b/GlazeWM.Bar/Components/WindowTitleComponentViewModel.cs
index 4f7f96ae..e098c595 100644
--- a/GlazeWM.Bar/Components/WindowTitleComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/WindowTitleComponentViewModel.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Reactive.Linq;
using GlazeWM.Domain.Containers;
using GlazeWM.Domain.UserConfigs;
@@ -11,42 +12,55 @@ namespace GlazeWM.Bar.Components
{
public class WindowTitleComponentViewModel : ComponentViewModel
{
+ private readonly WindowTitleComponentConfig _config;
private readonly Bus _bus = ServiceLocator.GetRequiredService<Bus>();
private readonly ContainerService _containerService =
ServiceLocator.GetRequiredService<ContainerService>();
- public string _focusedWindowTitle = string.Empty;
- public string FocusedWindowTitle
+ private LabelViewModel _label;
+ public LabelViewModel Label
{
- get => _focusedWindowTitle;
- set
- {
- _focusedWindowTitle = value;
- OnPropertyChanged(nameof(FocusedWindowTitle));
- }
+ get => _label;
+ protected set => SetField(ref _label, value);
}
public WindowTitleComponentViewModel(
BarViewModel parentViewModel,
WindowTitleComponentConfig config) : base(parentViewModel, config)
{
- _bus.Events.OfType<WindowFocusedEvent>()
- .Subscribe((@event) => UpdateTitle(@event.WindowHandle));
+ _config = config;
- _bus.Events.OfType<WindowTitleChangedEvent>()
- .Subscribe((@event) => UpdateTitle(@event.WindowHandle));
- }
+ var windowFocused = _bus.Events
+ .OfType<WindowFocusedEvent>()
+ .Select(@event => @event.WindowHandle);
- private void UpdateTitle(IntPtr windowHandle)
- {
- var focusedWindow = _containerService.FocusedContainer as Window;
+ var windowTitleChanged = _bus.Events
+ .OfType<WindowTitleChangedEvent>()
+ .Select(@event => @event.WindowHandle);
- if (focusedWindow != null && windowHandle != focusedWindow.Handle)
- return;
+ windowFocused.Merge(windowTitleChanged)
+ .TakeUntil(_parentViewModel.WindowClosing)
+ .Subscribe((windowHandle) =>
+ {
+ var focusedWindow = _containerService.FocusedContainer as Window;
+ if (focusedWindow != null && windowHandle != focusedWindow.Handle)
+ return;
+
+ var windowTitle = focusedWindow?.Title ?? string.Empty;
+ Label = CreateLabel(windowTitle);
+ });
+ }
+
+ private LabelViewModel CreateLabel(string windowTitle)
+ {
+ var variableDictionary = new Dictionary<string, Func<string>>()
+ {
// TODO: Make truncate max length configurable from config.
- var windowTitle = focusedWindow?.Title ?? string.Empty;
- FocusedWindowTitle = Truncate(windowTitle, 60);
+ { "window_title", () => Truncate(windowTitle, 60) }
+ };
+
+ return XamlHelper.ParseLabel(_config.Label, variableDictionary, this);
}
public static string Truncate(string value, int maxLength, string truncationSuffix = "…")
diff --git a/GlazeWM.Bar/Components/WorkspacesComponentViewModel.cs b/GlazeWM.Bar/Components/WorkspacesComponentViewModel.cs
index 629288de..dc77c891 100644
--- a/GlazeWM.Bar/Components/WorkspacesComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/WorkspacesComponentViewModel.cs
@@ -83,9 +83,11 @@ namespace GlazeWM.Bar.Components
);
// Refresh contents of workspaces collection.
- workspacesChangedEvent.Subscribe(_ =>
- _dispatcher.Invoke(() => OnPropertyChanged(nameof(Workspaces)))
- );
+ workspacesChangedEvent
+ .TakeUntil(_parentViewModel.WindowClosing)
+ .Subscribe(_ =>
+ _dispatcher.Invoke(() => OnPropertyChanged(nameof(Workspaces)))
+ );
}
public void FocusWorkspace(string workspaceName)
diff --git a/GlazeWM.Bar/XamlHelper.cs b/GlazeWM.Bar/XamlHelper.cs
index c0fd405a..dced5174 100644
--- a/GlazeWM.Bar/XamlHelper.cs
+++ b/GlazeWM.Bar/XamlHelper.cs
@@ -86,7 +86,6 @@ namespace GlazeWM.Bar
_ => throw new ArgumentException("Invalid XML.", nameof(labelString))
};
- string background = null;
string foreground = null;
string fontFamily = null;
string fontWeight = null;
@@ -96,7 +95,6 @@ namespace GlazeWM.Bar
while (ancestor is not null)
{
- background ??= (ancestor as XElement)?.Attribute("bg")?.Value;
foreground ??= (ancestor as XElement)?.Attribute("fg")?.Value;
fontFamily ??= (ancestor as XElement)?.Attribute("ff")?.Value;
fontWeight ??= (ancestor as XElement)?.Attribute("fw")?.Value;
@@ -108,7 +106,6 @@ namespace GlazeWM.Bar
return new LabelSpan(
value,
- background ?? viewModel.Background,
foreground ?? viewModel.Foreground,
fontFamily ?? viewModel.FontFamily,
fontWeight ?? viewModel.FontWeight,
diff --git a/GlazeWM.Domain/UserConfigs/BindingModeComponentConfig.cs b/GlazeWM.Domain/UserConfigs/BindingModeComponentConfig.cs
index 4fd50f10..4d465d71 100644
--- a/GlazeWM.Domain/UserConfigs/BindingModeComponentConfig.cs
+++ b/GlazeWM.Domain/UserConfigs/BindingModeComponentConfig.cs
@@ -2,5 +2,9 @@ namespace GlazeWM.Domain.UserConfigs
{
public class BindingModeComponentConfig : BarComponentConfig
{
+ /// <summary>
+ /// Label assigned to the binding mode component.
+ /// </summary>
+ public string Label { get; set; } = "{binding_mode}";
}
}
diff --git a/GlazeWM.Domain/UserConfigs/ClockComponentConfig.cs b/GlazeWM.Domain/UserConfigs/ClockComponentConfig.cs
index 5b4f5dc6..823a8e87 100644
--- a/GlazeWM.Domain/UserConfigs/ClockComponentConfig.cs
+++ b/GlazeWM.Domain/UserConfigs/ClockComponentConfig.cs
@@ -2,6 +2,11 @@ namespace GlazeWM.Domain.UserConfigs
{
public class ClockComponentConfig : BarComponentConfig
{
+ /// <summary>
+ /// Label assigned to the clock component.
+ /// </summary>
+ public string Label { get; set; } = "{formatted_time}";
+
/// <summary>
/// How to format the current time/date via `DateTime.ToString`.
/// </summary>
diff --git a/GlazeWM.Domain/UserConfigs/WindowTitleComponentConfig.cs b/GlazeWM.Domain/UserConfigs/WindowTitleComponentConfig.cs
index f9044cbe..66132ed1 100644
--- a/GlazeWM.Domain/UserConfigs/WindowTitleComponentConfig.cs
+++ b/GlazeWM.Domain/UserConfigs/WindowTitleComponentConfig.cs
@@ -2,5 +2,9 @@ namespace GlazeWM.Domain.UserConfigs
{
public class WindowTitleComponentConfig : BarComponentConfig
{
+ /// <summary>
+ /// Label assigned to the window title component.
+ /// </summary>
+ public string Label { get; set; } = "{window_title}";
}
}