Skip to content

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

style: roslynator and general style fixes (#134)

lars-berger7d57741d0b6e
diff --git a/GlazeWM.Bar/BarViewModel.cs b/GlazeWM.Bar/BarViewModel.cs
index bbdafcd7..86fdd223 100644
--- a/GlazeWM.Bar/BarViewModel.cs
+++ b/GlazeWM.Bar/BarViewModel.cs
@@ -15,7 +15,8 @@ namespace GlazeWM.Bar
public Dispatcher Dispatcher { get; set; }
public Monitor Monitor { get; set; }
- private readonly UserConfigService _userConfigService = ServiceLocator.Provider.GetRequiredService<UserConfigService>();
+ private readonly UserConfigService _userConfigService =
+ ServiceLocator.Provider.GetRequiredService<UserConfigService>();
private BarConfig _barConfig => _userConfigService.UserConfig.Bar;
public BarPosition Position => _barConfig.Position;
@@ -38,7 +39,8 @@ namespace GlazeWM.Bar
public List<ComponentViewModel> ComponentsRight =>
CreateComponentViewModels(_barConfig.ComponentsRight);
- private List<ComponentViewModel> CreateComponentViewModels(List<BarComponentConfig> componentConfigs)
+ private List<ComponentViewModel> CreateComponentViewModels(
+ List<BarComponentConfig> componentConfigs)
{
return componentConfigs.ConvertAll<ComponentViewModel>(config => config switch
{
diff --git a/GlazeWM.Bar/Components/ClockComponentViewModel.cs b/GlazeWM.Bar/Components/ClockComponentViewModel.cs
index 83ac04fb..394761ff 100644
--- a/GlazeWM.Bar/Components/ClockComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/ClockComponentViewModel.cs
@@ -13,9 +13,14 @@ namespace GlazeWM.Bar.Components
/// <summary>
/// Format the current time with the user's formatting config.
/// </summary>
- public string FormattedTime => DateTime.Now.ToString(_timeFormatting, CultureInfo.InvariantCulture);
+ public string FormattedTime => DateTime.Now.ToString(
+ _timeFormatting,
+ CultureInfo.InvariantCulture
+ );
- public ClockComponentViewModel(BarViewModel parentViewModel, ClockComponentConfig config) : base(parentViewModel, config)
+ public ClockComponentViewModel(
+ BarViewModel parentViewModel,
+ ClockComponentConfig config) : base(parentViewModel, config)
{
// Update the displayed time every second.
var updateInterval = TimeSpan.FromSeconds(1);
diff --git a/GlazeWM.Bar/Components/ComponentViewModel.cs b/GlazeWM.Bar/Components/ComponentViewModel.cs
index 490757a4..f1f1ef91 100644
--- a/GlazeWM.Bar/Components/ComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/ComponentViewModel.cs
@@ -1,7 +1,5 @@
using GlazeWM.Bar.Common;
using GlazeWM.Domain.UserConfigs;
-using GlazeWM.Infrastructure;
-using Microsoft.Extensions.DependencyInjection;
namespace GlazeWM.Bar.Components
{
@@ -9,7 +7,6 @@ namespace GlazeWM.Bar.Components
{
protected readonly BarViewModel _parentViewModel;
protected readonly BarComponentConfig _componentConfig;
- protected readonly BarService _barService = ServiceLocator.Provider.GetRequiredService<BarService>();
public string Background => _componentConfig.Background ?? _parentViewModel.Background;
public string Foreground => _componentConfig.Foreground ?? _parentViewModel.Foreground;
diff --git a/GlazeWM.Bar/Components/TextComponentViewModel.cs b/GlazeWM.Bar/Components/TextComponentViewModel.cs
index fec1dd17..cc50faeb 100644
--- a/GlazeWM.Bar/Components/TextComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/TextComponentViewModel.cs
@@ -1,6 +1,3 @@
-using System;
-using System.Globalization;
-using System.Reactive.Linq;
using GlazeWM.Domain.UserConfigs;
namespace GlazeWM.Bar.Components
@@ -8,14 +5,12 @@ namespace GlazeWM.Bar.Components
public class TextComponentViewModel : ComponentViewModel
{
private TextComponentConfig _config => _componentConfig as TextComponentConfig;
- private string _text => _config.Text;
- /// <summary>
- /// Shows text from the user's config.
- /// </summary>
- public string Text => _text;
+ public string Text => _config.Text;
- public TextComponentViewModel(BarViewModel parentViewModel, TextComponentConfig config) : base(parentViewModel, config)
+ public TextComponentViewModel(
+ BarViewModel parentViewModel,
+ TextComponentConfig config) : base(parentViewModel, config)
{
}
}
diff --git a/GlazeWM.Bar/Components/WorkspacesComponentViewModel.cs b/GlazeWM.Bar/Components/WorkspacesComponentViewModel.cs
index 97985745..83919d34 100644
--- a/GlazeWM.Bar/Components/WorkspacesComponentViewModel.cs
+++ b/GlazeWM.Bar/Components/WorkspacesComponentViewModel.cs
@@ -60,15 +60,18 @@ namespace GlazeWM.Bar.Components
public ICommand FocusWorkspaceCommand => new RelayCommand<string>(FocusWorkspace);
- public WorkspacesComponentViewModel(BarViewModel parentViewModel, WorkspacesComponentConfig config)
- : base(parentViewModel, config)
+ public WorkspacesComponentViewModel(
+ BarViewModel parentViewModel,
+ WorkspacesComponentConfig config) : base(parentViewModel, config)
{
var workspacesChangedEvent = _bus.Events.Where((@event) =>
@event is WorkspaceActivatedEvent or WorkspaceDeactivatedEvent or FocusChangedEvent
);
// Refresh contents of workspaces collection.
- workspacesChangedEvent.Subscribe(_ => _dispatcher.Invoke(() => OnPropertyChanged(nameof(Workspaces))));
+ workspacesChangedEvent.Subscribe(_ =>
+ _dispatcher.Invoke(() => OnPropertyChanged(nameof(Workspaces)))
+ );
}
public void FocusWorkspace(string workspaceName)
diff --git a/GlazeWM.Bar/MainWindow.xaml.cs b/GlazeWM.Bar/MainWindow.xaml.cs
index b9a9c769..43e0a850 100644
--- a/GlazeWM.Bar/MainWindow.xaml.cs
+++ b/GlazeWM.Bar/MainWindow.xaml.cs
@@ -67,12 +67,31 @@ 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;
+
+ // Get offset from top of monitor.
+ 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.
+ MoveWindow(
+ windowHandle,
+ _monitor.X + 1,
+ _monitor.Y + barOffsetY,
+ _monitor.Width - 1,
+ scaledBarHeight,
+ false
+ );
+
// The +1/-1 coerces WPF to update Top/Left/Width/Height in the second move.
- MoveWindow(windowHandle, _monitor.X + 1, _monitor.Y + barOffsetY, _monitor.Width - 1, scaledBarHeight, false);
- MoveWindow(windowHandle, _monitor.X, _monitor.Y + barOffsetY, _monitor.Width, scaledBarHeight, true);
+ MoveWindow(
+ windowHandle,
+ _monitor.X,
+ _monitor.Y + barOffsetY,
+ _monitor.Width,
+ scaledBarHeight,
+ true
+ );
}
}
}
diff --git a/GlazeWM.Domain/Common/Enums/Direction.cs b/GlazeWM.Domain/Common/Enums/Direction.cs
index ee1c4b03..50d316bf 100644
--- a/GlazeWM.Domain/Common/Enums/Direction.cs
+++ b/GlazeWM.Domain/Common/Enums/Direction.cs
@@ -35,7 +35,8 @@ namespace GlazeWM.Domain.Common.Enums
public static Layout GetCorrespondingLayout(this Direction direction)
{
return (direction is Direction.LEFT or Direction.RIGHT)
- ? Layout.HORIZONTAL : Layout.VERTICAL;
+ ? Layout.HORIZONTAL
+ : Layout.VERTICAL;
}
}
}
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs
index 2e9041b4..cef975be 100644
--- a/GlazeWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs
+++ b/GlazeWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs
@@ -77,8 +77,8 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
workspace.Layout = newLayout;
- // Flatten any top-level split containers with the same layout as the workspace. Clone
- // the list since the number of workspace children changes when split containers are flattened.
+ // Flatten any top-level split containers with the same layout as the workspace. Clone the
+ // list since the number of workspace children changes when split containers are flattened.
foreach (var child in workspace.Children.ToList())
{
var childSplitContainer = child as SplitContainer;
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/FocusInDirectionHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/FocusInDirectionHandler.cs
index 587b8ce0..0b9e0edc 100644
--- a/GlazeWM.Domain/Containers/CommandHandlers/FocusInDirectionHandler.cs
+++ b/GlazeWM.Domain/Containers/CommandHandlers/FocusInDirectionHandler.cs
@@ -16,7 +16,10 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
private readonly ContainerService _containerService;
private readonly MonitorService _monitorService;
- public FocusInDirectionHandler(Bus bus, ContainerService containerService, MonitorService monitorService)
+ public FocusInDirectionHandler(
+ Bus bus,
+ ContainerService containerService,
+ MonitorService monitorService)
{
_bus = bus;
_containerService = containerService;
@@ -84,7 +87,9 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
/// Attempt to find a focus target within the focused workspace. Traverse upwards from the
/// focused container to find an adjacent container that can be focused.
/// </summary>
- private Container GetFocusTargetWithinWorkspace(Container focusedContainer, Direction direction)
+ private Container GetFocusTargetWithinWorkspace(
+ Container focusedContainer,
+ Direction direction)
{
var layoutForDirection = direction.GetCorrespondingLayout();
var focusReference = focusedContainer;
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/MoveContainerWithinTreeHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/MoveContainerWithinTreeHandler.cs
index feffa4f2..662ad69e 100644
--- a/GlazeWM.Domain/Containers/CommandHandlers/MoveContainerWithinTreeHandler.cs
+++ b/GlazeWM.Domain/Containers/CommandHandlers/MoveContainerWithinTreeHandler.cs
@@ -36,7 +36,13 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
// or moving a container to a direct ancestor).
if (targetParent == lowestCommonAncestor)
{
- MoveToLowestCommonAncestor(containerToMove, lowestCommonAncestor, targetIndex, shouldAdjustSize);
+ MoveToLowestCommonAncestor(
+ containerToMove,
+ lowestCommonAncestor,
+ targetIndex,
+ shouldAdjustSize
+ );
+
return CommandResponse.Ok;
}
@@ -84,7 +90,11 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
return CommandResponse.Ok;
}
- private void MoveToLowestCommonAncestor(Container containerToMove, Container lowestCommonAncestor, int targetIndex, bool shouldAdjustSize)
+ private void MoveToLowestCommonAncestor(
+ Container containerToMove,
+ Container lowestCommonAncestor,
+ int targetIndex,
+ bool shouldAdjustSize)
{
// Keep reference to focus index of container's ancestor in LCA's `ChildFocusOrder`.
var originalFocusIndex = containerToMove.SelfAndAncestors
@@ -109,9 +119,21 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
var adjustedTargetIndex = shouldAdjustTargetIndex ? targetIndex - 1 : targetIndex;
if (shouldAdjustSize)
- _bus.Invoke(new AttachAndResizeContainerCommand(containerToMove, lowestCommonAncestor, adjustedTargetIndex));
+ _bus.Invoke(
+ new AttachAndResizeContainerCommand(
+ containerToMove,
+ lowestCommonAncestor,
+ adjustedTargetIndex
+ )
+ );
else
- _bus.Invoke(new AttachContainerCommand(containerToMove, lowestCommonAncestor, adjustedTargetIndex));
+ _bus.Invoke(
+ new AttachContainerCommand(
+ containerToMove,
+ lowestCommonAncestor,
+ adjustedTargetIndex
+ )
+ );
lowestCommonAncestor.ChildFocusOrder.ShiftToIndex(originalFocusIndex, containerToMove);
}
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/RedrawContainersHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/RedrawContainersHandler.cs
index 1bc9433c..91bcd493 100644
--- a/GlazeWM.Domain/Containers/CommandHandlers/RedrawContainersHandler.cs
+++ b/GlazeWM.Domain/Containers/CommandHandlers/RedrawContainersHandler.cs
@@ -28,7 +28,9 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
// Get windows that are minimized/maximized and shouldn't be.
var windowsToRestore = windowsToRedraw
.Where(
- window => window is not MinimizedWindow && window.HasWindowStyle(WS.WS_MAXIMIZE | WS.WS_MINIMIZE)
+ (window) =>
+ window is not MinimizedWindow &&
+ window.HasWindowStyle(WS.WS_MAXIMIZE | WS.WS_MINIMIZE)
)
.ToList();
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/ToggleFocusModeHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/ToggleFocusModeHandler.cs
index 28610e56..d2753f38 100644
--- a/GlazeWM.Domain/Containers/CommandHandlers/ToggleFocusModeHandler.cs
+++ b/GlazeWM.Domain/Containers/CommandHandlers/ToggleFocusModeHandler.cs
@@ -13,7 +13,10 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
private readonly ContainerService _containerService;
private readonly WorkspaceService _workspaceService;
- public ToggleFocusModeHandler(Bus bus, ContainerService containerService, WorkspaceService workspaceService)
+ public ToggleFocusModeHandler(
+ Bus bus,
+ ContainerService containerService,
+ WorkspaceService workspaceService)
{
_bus = bus;
_containerService = containerService;
@@ -24,7 +27,8 @@ namespace GlazeWM.Domain.Containers.CommandHandlers
{
var currentFocusMode = _containerService.FocusMode;
var targetFocusMode = currentFocusMode == FocusMode.TILING
- ? FocusMode.FLOATING : FocusMode.TILING;
+ ? FocusMode.FLOATING
+ : FocusMode.TILING;
var focusedWorkspace = _workspaceService.GetFocusedWorkspace();
diff --git a/GlazeWM.Domain/Containers/Commands/AttachAndResizeContainerCommand.cs b/GlazeWM.Domain/Containers/Commands/AttachAndResizeContainerCommand.cs
index 155fec1f..51f9f351 100644
--- a/GlazeWM.Domain/Containers/Commands/AttachAndResizeContainerCommand.cs
+++ b/GlazeWM.Domain/Containers/Commands/AttachAndResizeContainerCommand.cs
@@ -18,7 +18,10 @@ namespace GlazeWM.Domain.Containers.Commands
TargetIndex = targetParent.Children.Count;
}
- public AttachAndResizeContainerCommand(Container childToAdd, Container targetParent, int targetIndex)
+ public AttachAndResizeContainerCommand(
+ Container childToAdd,
+ Container targetParent,
+ int targetIndex)
{
ChildToAdd = childToAdd;
TargetParent = targetParent;
diff --git a/GlazeWM.Domain/Containers/Commands/MoveContainerWithinTreeCommand.cs b/GlazeWM.Domain/Containers/Commands/MoveContainerWithinTreeCommand.cs
index c1e15d10..40227737 100644
--- a/GlazeWM.Domain/Containers/Commands/MoveContainerWithinTreeCommand.cs
+++ b/GlazeWM.Domain/Containers/Commands/MoveContainerWithinTreeCommand.cs
@@ -12,7 +12,10 @@ namespace GlazeWM.Domain.Containers.Commands
/// <summary>
/// Insert child as end element if `targetIndex` is not provided.
/// </summary>
- public MoveContainerWithinTreeCommand(Container containerToMove, Container targetParent, bool shouldAdjustSize)
+ public MoveContainerWithinTreeCommand(
+ Container containerToMove,
+ Container targetParent,
+ bool shouldAdjustSize)
{
ContainerToMove = containerToMove;
TargetParent = targetParent;
@@ -20,7 +23,11 @@ namespace GlazeWM.Domain.Containers.Commands
ShouldAdjustSize = shouldAdjustSize;
}
- public MoveContainerWithinTreeCommand(Container containerToMove, Container targetParent, int targetIndex, bool shouldAdjustSize)
+ public MoveContainerWithinTreeCommand(
+ Container containerToMove,
+ Container targetParent,
+ int targetIndex,
+ bool shouldAdjustSize)
{
ContainerToMove = containerToMove;
TargetParent = targetParent;
diff --git a/GlazeWM.Domain/Containers/Commands/ReplaceContainerCommand.cs b/GlazeWM.Domain/Containers/Commands/ReplaceContainerCommand.cs
index 531f87bf..290fe6e2 100644
--- a/GlazeWM.Domain/Containers/Commands/ReplaceContainerCommand.cs
+++ b/GlazeWM.Domain/Containers/Commands/ReplaceContainerCommand.cs
@@ -8,7 +8,10 @@ namespace GlazeWM.Domain.Containers.Commands
public Container TargetParent { get; }
public int TargetIndex { get; }
- public ReplaceContainerCommand(Container replacementContainer, Container targetParent, int targetIndex)
+ public ReplaceContainerCommand(
+ Container replacementContainer,
+ Container targetParent,
+ int targetIndex)
{
ReplacementContainer = replacementContainer;
TargetParent = targetParent;
diff --git a/GlazeWM.Domain/JsonContainerConverter.cs b/GlazeWM.Domain/Containers/JsonContainerConverter.cs
similarity index 100%
rename from GlazeWM.Domain/JsonContainerConverter.cs
rename to GlazeWM.Domain/Containers/JsonContainerConverter.cs
diff --git a/GlazeWM.Domain/Containers/SplitContainer.cs b/GlazeWM.Domain/Containers/SplitContainer.cs
index b028d208..bc75f760 100644
--- a/GlazeWM.Domain/Containers/SplitContainer.cs
+++ b/GlazeWM.Domain/Containers/SplitContainer.cs
@@ -10,14 +10,12 @@ namespace GlazeWM.Domain.Containers
public double SizePercentage { get; set; } = 1;
- private readonly ContainerService _containerService = ServiceLocator.Provider.GetRequiredService<ContainerService>();
+ private readonly ContainerService _containerService =
+ ServiceLocator.Provider.GetRequiredService<ContainerService>();
public override int Width => _containerService.CalculateWidthOfResizableContainer(this);
-
public override int Height => _containerService.CalculateHeightOfResizableContainer(this);
-
public override int X => _containerService.CalculateXOfResizableContainer(this);
-
public override int Y => _containerService.CalculateYOfResizableContainer(this);
}
}
diff --git a/GlazeWM.Domain/DependencyInjection.cs b/GlazeWM.Domain/DependencyInjection.cs
index 6ad6a17a..6086aed8 100644
--- a/GlazeWM.Domain/DependencyInjection.cs
+++ b/GlazeWM.Domain/DependencyInjection.cs
@@ -1,5 +1,4 @@
-using GlazeWM.Domain.Common;
-using GlazeWM.Domain.Common.CommandHandlers;
+using GlazeWM.Domain.Common.CommandHandlers;
using GlazeWM.Domain.Common.Commands;
using GlazeWM.Domain.Containers;
using GlazeWM.Domain.Containers.CommandHandlers;
diff --git a/GlazeWM.Domain/Monitors/CommandHandlers/AddMonitorHandler.cs b/GlazeWM.Domain/Monitors/CommandHandlers/AddMonitorHandler.cs
index 4bbdc550..cec9e888 100644
--- a/GlazeWM.Domain/Monitors/CommandHandlers/AddMonitorHandler.cs
+++ b/GlazeWM.Domain/Monitors/CommandHandlers/AddMonitorHandler.cs
@@ -1,5 +1,4 @@
-using System.Linq;
-using GlazeWM.Domain.Containers;
+using GlazeWM.Domain.Containers;
using GlazeWM.Domain.Containers.Commands;
using GlazeWM.Domain.Monitors.Commands;
using GlazeWM.Domain.Monitors.Events;
@@ -16,7 +15,10 @@ namespace GlazeWM.Domain.Monitors.CommandHandlers
private readonly ContainerService _containerService;
private readonly WorkspaceService _workspaceService;
- public AddMonitorHandler(Bus bus, ContainerService containerService, WorkspaceService workspaceService)
+ public AddMonitorHandler(
+ Bus bus,
+ ContainerService containerService,
+ WorkspaceService workspaceService)
{
_bus = bus;
_containerService = containerService;
diff --git a/GlazeWM.Domain/Monitors/CommandHandlers/RefreshMonitorStateHandler.cs b/GlazeWM.Domain/Monitors/CommandHandlers/RefreshMonitorStateHandler.cs
index 37b39966..9e093e7e 100644
--- a/GlazeWM.Domain/Monitors/CommandHandlers/RefreshMonitorStateHandler.cs
+++ b/GlazeWM.Domain/Monitors/CommandHandlers/RefreshMonitorStateHandler.cs
@@ -21,8 +21,7 @@ namespace GlazeWM.Domain.Monitors.CommandHandlers
Bus bus,
MonitorService monitorService,
ContainerService containerService,
- WindowService windowService
- )
+ WindowService windowService)
{
_bus = bus;
_monitorService = monitorService;
diff --git a/GlazeWM.Domain/Monitors/CommandHandlers/RemoveMonitorHandler.cs b/GlazeWM.Domain/Monitors/CommandHandlers/RemoveMonitorHandler.cs
index fe86a305..da3e79b9 100644
--- a/GlazeWM.Domain/Monitors/CommandHandlers/RemoveMonitorHandler.cs
+++ b/GlazeWM.Domain/Monitors/CommandHandlers/RemoveMonitorHandler.cs
@@ -3,7 +3,6 @@ using GlazeWM.Domain.Containers.Commands;
using GlazeWM.Domain.Monitors.Commands;
using GlazeWM.Domain.Monitors.Events;
using GlazeWM.Domain.Workspaces;
-using GlazeWM.Domain.Workspaces.Commands;
using GlazeWM.Domain.Workspaces.Events;
using GlazeWM.Infrastructure.Bussing;
diff --git a/GlazeWM.Domain/Monitors/Monitor.cs b/GlazeWM.Domain/Monitors/Monitor.cs
index 58b32ccd..65e8bcf2 100644
--- a/GlazeWM.Domain/Monitors/Monitor.cs
+++ b/GlazeWM.Domain/Monitors/Monitor.cs
@@ -20,8 +20,7 @@ namespace GlazeWM.Domain.Monitors
int width,
int height,
int x,
- int y
- )
+ int y)
{
DeviceName = deviceName;
Width = width;
diff --git a/GlazeWM.Domain/Monitors/MonitorService.cs b/GlazeWM.Domain/Monitors/MonitorService.cs
index 30ae6777..636ce6d5 100644
--- a/GlazeWM.Domain/Monitors/MonitorService.cs
+++ b/GlazeWM.Domain/Monitors/MonitorService.cs
@@ -97,8 +97,7 @@ namespace GlazeWM.Domain.Monitors
// Check whether the monitor is to the right/left of the origin monitor.
if (
(direction == Direction.RIGHT && monitor.X > originMonitor.X) ||
- (direction == Direction.LEFT && monitor.X < originMonitor.X)
- )
+ (direction == Direction.LEFT && monitor.X < originMonitor.X))
{
// Check whether the y-coordinate overlaps with the y-coordinate of the origin monitor.
if (
@@ -110,8 +109,7 @@ namespace GlazeWM.Domain.Monitors
// Check whether the monitor is below/above the origin monitor.
else if (
(direction == Direction.DOWN && monitor.Y > originMonitor.Y) ||
- (direction == Direction.UP && monitor.Y < originMonitor.Y)
- )
+ (direction == Direction.UP && monitor.Y < originMonitor.Y))
{
// Check whether the x-coordinate overlaps with the x-coordinate of the origin monitor.
if (
diff --git a/GlazeWM.Domain/UserConfigs/BarComponentConfigConverter.cs b/GlazeWM.Domain/UserConfigs/BarComponentConfigConverter.cs
index 77151762..889f758f 100644
--- a/GlazeWM.Domain/UserConfigs/BarComponentConfigConverter.cs
+++ b/GlazeWM.Domain/UserConfigs/BarComponentConfigConverter.cs
@@ -6,7 +6,10 @@ namespace GlazeWM.Domain.UserConfigs
{
public class BarComponentConfigConverter : JsonConverter<BarComponentConfig>
{
- public override BarComponentConfig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ public override BarComponentConfig Read(
+ ref Utf8JsonReader reader,
+ Type typeToConvert,
+ JsonSerializerOptions options)
{
using var jsonObject = JsonDocument.ParseValue(ref reader);
@@ -38,7 +41,10 @@ namespace GlazeWM.Domain.UserConfigs
/// Serializing is not needed, so it's fine to leave it unimplemented.
/// </summary>
/// <exception cref="NotImplementedException"></exception>
- public override void Write(Utf8JsonWriter writer, BarComponentConfig value, JsonSerializerOptions options)
+ public override void Write(
+ Utf8JsonWriter writer,
+ BarComponentConfig value,
+ JsonSerializerOptions options)
{
throw new NotImplementedException();
}
diff --git a/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs b/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs
index 0fab9f6e..93fc4e90 100644
--- a/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs
+++ b/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs
@@ -24,8 +24,7 @@ namespace GlazeWM.Domain.UserConfigs.CommandHandlers
Bus bus,
UserConfigService userConfigService,
YamlService yamlService,
- CommandParsingService commandParsingService
- )
+ CommandParsingService commandParsingService)
{
_bus = bus;
_userConfigService = userConfigService;
diff --git a/GlazeWM.Domain/UserConfigs/CommandHandlers/RegisterKeybindingsHandler.cs b/GlazeWM.Domain/UserConfigs/CommandHandlers/RegisterKeybindingsHandler.cs
index 9387c22a..96d5d5ed 100644
--- a/GlazeWM.Domain/UserConfigs/CommandHandlers/RegisterKeybindingsHandler.cs
+++ b/GlazeWM.Domain/UserConfigs/CommandHandlers/RegisterKeybindingsHandler.cs
@@ -54,8 +54,12 @@ namespace GlazeWM.Domain.UserConfigs.CommandHandlers
{
var subjectContainer = _containerService.FocusedContainer;
+ var parsedCommand = _commandParsingService.ParseCommand(
+ commandString,
+ subjectContainer
+ );
+
// Use `dynamic` to resolve the command type at runtime and allow multiple dispatch.
- var parsedCommand = _commandParsingService.ParseCommand(commandString, subjectContainer);
_bus.Invoke((dynamic)parsedCommand);
}
});
diff --git a/GlazeWM.Domain/UserConfigs/TextComponentConfig.cs b/GlazeWM.Domain/UserConfigs/TextComponentConfig.cs
index 0370e58a..589d4c1a 100644
--- a/GlazeWM.Domain/UserConfigs/TextComponentConfig.cs
+++ b/GlazeWM.Domain/UserConfigs/TextComponentConfig.cs
@@ -3,7 +3,7 @@ namespace GlazeWM.Domain.UserConfigs
public class TextComponentConfig : BarComponentConfig
{
/// <summary>
- /// Text to print.
+ /// Text to display.
/// </summary>
public string Text { get; set; } = "Hello world!";
}
diff --git a/GlazeWM.Domain/UserConfigs/WorkspaceConfig.cs b/GlazeWM.Domain/UserConfigs/WorkspaceConfig.cs
index 08ab72ae..93c3d476 100644
--- a/GlazeWM.Domain/UserConfigs/WorkspaceConfig.cs
+++ b/GlazeWM.Domain/UserConfigs/WorkspaceConfig.cs
@@ -1,4 +1,3 @@
-using System;
using System.ComponentModel.DataAnnotations;
namespace GlazeWM.Domain.UserConfigs
@@ -11,8 +10,10 @@ namespace GlazeWM.Domain.UserConfigs
private string _bindToMonitor;
public string BindToMonitor
{
- get => int.TryParse(_bindToMonitor, out var monitorIndex) ? $@"\\.\DISPLAY{monitorIndex}" : _bindToMonitor;
- set => _bindToMonitor = value;
+ get => _bindToMonitor;
+ set => _bindToMonitor = int.TryParse(value, out var monitorIndex)
+ ? $@"\\.\DISPLAY{monitorIndex}"
+ : value;
}
public string DisplayName { get; set; }
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs
index 8495bda8..8357168f 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs
@@ -105,7 +105,7 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
floatingPlacement,
defaultBorderDelta,
isResizable ? WindowType.TILING : WindowType.FLOATING
- ),
+ ),
WindowType.FLOATING => new FloatingWindow(
windowHandle,
floatingPlacement,
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs
index d3a2adc4..80b1ec06 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/MoveWindowHandler.cs
@@ -19,8 +19,7 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
public MoveWindowHandler(
Bus bus,
ContainerService containerService,
- MonitorService monitorService
- )
+ MonitorService monitorService)
{
_bus = bus;
_containerService = containerService;
@@ -115,10 +114,16 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
var targetParent = targetDescendant.Parent as SplitContainer;
var layoutForDirection = direction.GetCorrespondingLayout();
- var insertionIndex = targetParent.Layout != layoutForDirection || direction == Direction.UP ||
- direction == Direction.LEFT ? targetDescendant.Index + 1 : targetDescendant.Index;
+ var shouldInsertAfter =
+ targetParent.Layout != layoutForDirection ||
+ direction == Direction.UP ||
+ direction == Direction.LEFT;
+ var insertionIndex = shouldInsertAfter ? targetDescendant.Index + 1 : targetDescendant.Index;
+
+ _bus.Invoke(
+ new MoveContainerWithinTreeCommand(windowToMove, targetParent, insertionIndex, true)
+ );
- _bus.Invoke(new MoveContainerWithinTreeCommand(windowToMove, targetParent, insertionIndex, true));
_bus.Invoke(new RedrawContainersCommand());
}
@@ -168,8 +173,7 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
private void InsertIntoAncestor(
TilingWindow windowToMove,
Direction direction,
- Container ancestorWithLayout
- )
+ Container ancestorWithLayout)
{
// Traverse up from `windowToMove` to find container where the parent is `ancestorWithLayout`.
// Then, depending on the direction, insert before or after that container.
@@ -190,8 +194,14 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
var targetParent = targetDescendant.Parent as SplitContainer;
var layoutForDirection = direction.GetCorrespondingLayout();
- var insertionIndex = targetParent.Layout != layoutForDirection || direction == Direction.UP ||
- direction == Direction.LEFT ? targetDescendant.Index + 1 : targetDescendant.Index;
+ var shouldInsertAfter =
+ targetParent.Layout != layoutForDirection ||
+ direction == Direction.UP ||
+ direction == Direction.LEFT;
+
+ var insertionIndex = shouldInsertAfter
+ ? targetDescendant.Index + 1
+ : targetDescendant.Index;
_bus.Invoke(new MoveContainerWithinTreeCommand(windowToMove, targetParent, insertionIndex, true));
}
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs
index 3ddc5fa1..1b25b37e 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/ResizeWindowHandler.cs
@@ -86,8 +86,7 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
private static void DistributeSizePercentage(
IEnumerable<Container> containers,
double sizePercentage,
- double availableSizePercentage
- )
+ double availableSizePercentage)
{
foreach (var container in containers)
{
@@ -106,8 +105,7 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
private static Container GetContainerToResize(
Window windowToResize,
- ResizeDimension dimensionToResize
- )
+ ResizeDimension dimensionToResize)
{
var parent = windowToResize.Parent;
var grandparent = parent.Parent;
@@ -129,8 +127,7 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
private static double ConvertToResizePercentage(
Container containerToResize,
ResizeDimension dimensionToResize,
- string resizeAmount
- )
+ string resizeAmount)
{
try
{
@@ -155,8 +152,7 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
private static double GetPixelScaleFactor(
Container containerToResize,
- ResizeDimension dimensionToResize
- )
+ ResizeDimension dimensionToResize)
{
// Get available width/height that can be resized (ie. exclude inner gaps).
var resizableLength = containerToResize.SelfAndSiblingsOfType(typeof(IResizable)).Aggregate(
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/ToggleFloatingHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/ToggleFloatingHandler.cs
index 95272e38..09f96ed3 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/ToggleFloatingHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/ToggleFloatingHandler.cs
@@ -41,7 +41,13 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
0
);
- _bus.Invoke(new ReplaceContainerCommand(tilingWindow, floatingWindow.Parent, floatingWindow.Index));
+ _bus.Invoke(
+ new ReplaceContainerCommand(
+ tilingWindow,
+ floatingWindow.Parent,
+ floatingWindow.Index
+ )
+ );
// Insert the created tiling window after the last focused descendant of the workspace.
if (insertionTarget == null)
diff --git a/GlazeWM.Domain/Windows/Commands/ResizeWindowCommand.cs b/GlazeWM.Domain/Windows/Commands/ResizeWindowCommand.cs
index 4ca7057a..46f238d3 100644
--- a/GlazeWM.Domain/Windows/Commands/ResizeWindowCommand.cs
+++ b/GlazeWM.Domain/Windows/Commands/ResizeWindowCommand.cs
@@ -12,8 +12,7 @@ namespace GlazeWM.Domain.Windows.Commands
public ResizeWindowCommand(
Window windowToResize,
ResizeDimension dimensionToResize,
- string resizeAmount
- )
+ string resizeAmount)
{
WindowToResize = windowToResize;
DimensionToResize = dimensionToResize;
diff --git a/GlazeWM.Domain/Windows/EventHandlers/WindowDestroyedHandler.cs b/GlazeWM.Domain/Windows/EventHandlers/WindowDestroyedHandler.cs
index e2f85347..17bd1bdf 100644
--- a/GlazeWM.Domain/Windows/EventHandlers/WindowDestroyedHandler.cs
+++ b/GlazeWM.Domain/Windows/EventHandlers/WindowDestroyedHandler.cs
@@ -18,8 +18,7 @@ namespace GlazeWM.Domain.Windows.EventHandlers
public WindowDestroyedHandler(
Bus bus,
WindowService windowService,
- ILogger<WindowDestroyedHandler> logger
- )
+ ILogger<WindowDestroyedHandler> logger)
{
_bus = bus;
_windowService = windowService;
diff --git a/GlazeWM.Domain/Windows/EventHandlers/WindowFocusedHandler.cs b/GlazeWM.Domain/Windows/EventHandlers/WindowFocusedHandler.cs
index 784b72fa..e7c04d77 100644
--- a/GlazeWM.Domain/Windows/EventHandlers/WindowFocusedHandler.cs
+++ b/GlazeWM.Domain/Windows/EventHandlers/WindowFocusedHandler.cs
@@ -23,8 +23,7 @@ namespace GlazeWM.Domain.Windows.EventHandlers
Bus bus,
WindowService windowService,
ContainerService containerService,
- ILogger<WindowFocusedHandler> logger
- )
+ ILogger<WindowFocusedHandler> logger)
{
_bus = bus;
_windowService = windowService;
diff --git a/GlazeWM.Domain/Windows/EventHandlers/WindowHiddenHandler.cs b/GlazeWM.Domain/Windows/EventHandlers/WindowHiddenHandler.cs
index 9aca5745..0d2e15f5 100644
--- a/GlazeWM.Domain/Windows/EventHandlers/WindowHiddenHandler.cs
+++ b/GlazeWM.Domain/Windows/EventHandlers/WindowHiddenHandler.cs
@@ -18,8 +18,7 @@ namespace GlazeWM.Domain.Windows.EventHandlers
public WindowHiddenHandler(
Bus bus,
WindowService windowService,
- ILogger<WindowHiddenHandler> logger
- )
+ ILogger<WindowHiddenHandler> logger)
{
_bus = bus;
_windowService = windowService;
diff --git a/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizeEndedHandler.cs b/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizeEndedHandler.cs
index 3920f81b..47b0bf33 100644
--- a/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizeEndedHandler.cs
+++ b/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizeEndedHandler.cs
@@ -21,8 +21,7 @@ namespace GlazeWM.Domain.Windows.EventHandlers
Bus bus,
WindowService windowService,
ContainerService containerService,
- ILogger<WindowMinimizeEndedHandler> logger
- )
+ ILogger<WindowMinimizeEndedHandler> logger)
{
_bus = bus;
_windowService = windowService;
diff --git a/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizedHandler.cs b/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizedHandler.cs
index 52d84e6b..3647b789 100644
--- a/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizedHandler.cs
+++ b/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizedHandler.cs
@@ -22,8 +22,7 @@ namespace GlazeWM.Domain.Windows.EventHandlers
Bus bus,
WindowService windowService,
ContainerService containerService,
- ILogger<WindowMinimizedHandler> logger
- )
+ ILogger<WindowMinimizedHandler> logger)
{
_bus = bus;
_windowService = windowService;
diff --git a/GlazeWM.Domain/Windows/EventHandlers/WindowMovedOrResizedHandler.cs b/GlazeWM.Domain/Windows/EventHandlers/WindowMovedOrResizedHandler.cs
index 5367e258..6cd1ea49 100644
--- a/GlazeWM.Domain/Windows/EventHandlers/WindowMovedOrResizedHandler.cs
+++ b/GlazeWM.Domain/Windows/EventHandlers/WindowMovedOrResizedHandler.cs
@@ -27,8 +27,7 @@ namespace GlazeWM.Domain.Windows.EventHandlers
WindowService windowService,
MonitorService monitorService,
ILogger<WindowMovedOrResizedHandler> logger,
- ContainerService containerService
- )
+ ContainerService containerService)
{
_bus = bus;
_windowService = windowService;
diff --git a/GlazeWM.Domain/Windows/Window.cs b/GlazeWM.Domain/Windows/Window.cs
index aaccf393..295ef95b 100644
--- a/GlazeWM.Domain/Windows/Window.cs
+++ b/GlazeWM.Domain/Windows/Window.cs
@@ -40,7 +40,8 @@ namespace GlazeWM.Domain.Windows
/// </summary>
public bool IsDisplayed => WorkspaceService.GetWorkspaceFromChildContainer(this).IsDisplayed;
- public string ProcessName => WindowService.GetProcessOfHandle(Handle)?.ProcessName ?? string.Empty;
+ public string ProcessName =>
+ WindowService.GetProcessOfHandle(Handle)?.ProcessName ?? string.Empty;
public string ClassName => WindowService.GetClassNameOfHandle(Handle);
diff --git a/GlazeWM.Domain/Windows/WindowService.cs b/GlazeWM.Domain/Windows/WindowService.cs
index 16dd8bcf..34c77f94 100644
--- a/GlazeWM.Domain/Windows/WindowService.cs
+++ b/GlazeWM.Domain/Windows/WindowService.cs
@@ -136,7 +136,13 @@ namespace GlazeWM.Domain.Windows
/// </summary>
public static bool IsHandleCloaked(IntPtr handle)
{
- _ = DwmGetWindowAttribute(handle, DwmWindowAttribute.DWMWA_CLOAKED, out var isCloaked, Marshal.SizeOf(typeof(bool)));
+ _ = DwmGetWindowAttribute(
+ handle,
+ DwmWindowAttribute.DWMWA_CLOAKED,
+ out var isCloaked,
+ Marshal.SizeOf(typeof(bool))
+ );
+
return isCloaked;
}
diff --git a/GlazeWM.Domain/Workspaces/CommandHandlers/UpdateWorkspacesFromConfigHandler.cs b/GlazeWM.Domain/Workspaces/CommandHandlers/UpdateWorkspacesFromConfigHandler.cs
index 76406237..01c94e0d 100644
--- a/GlazeWM.Domain/Workspaces/CommandHandlers/UpdateWorkspacesFromConfigHandler.cs
+++ b/GlazeWM.Domain/Workspaces/CommandHandlers/UpdateWorkspacesFromConfigHandler.cs
@@ -18,9 +18,8 @@ namespace GlazeWM.Domain.Workspaces.CommandHandlers
public CommandResponse Handle(UpdateWorkspacesFromConfigCommand command)
{
var workspaceConfigs = command.WorkspaceConfigs;
- var workspaces = _workspaceService.GetActiveWorkspaces();
- foreach (var workspace in workspaces)
+ foreach (var workspace in _workspaceService.GetActiveWorkspaces())
{
var workspaceConfig = workspaceConfigs.Find(config => config.Name == workspace.Name);
diff --git a/GlazeWM.Infrastructure/Exceptions/FatalUserException.cs b/GlazeWM.Infrastructure/Exceptions/FatalUserException.cs
index cccc22fb..3dbcf21f 100644
--- a/GlazeWM.Infrastructure/Exceptions/FatalUserException.cs
+++ b/GlazeWM.Infrastructure/Exceptions/FatalUserException.cs
@@ -12,7 +12,9 @@ namespace GlazeWM.Infrastructure.Exceptions
{
}
- public FatalUserException(string message, Exception innerException) : base(message, innerException)
+ public FatalUserException(
+ string message,
+ Exception innerException) : base(message, innerException)
{
}
}
diff --git a/GlazeWM.Infrastructure/Logging/LogFormatter.cs b/GlazeWM.Infrastructure/Logging/LogFormatter.cs
index d697a4e9..eb31dd85 100644
--- a/GlazeWM.Infrastructure/Logging/LogFormatter.cs
+++ b/GlazeWM.Infrastructure/Logging/LogFormatter.cs
@@ -26,8 +26,7 @@ namespace GlazeWM.Infrastructure.Logging
public override void Write<T>(
in LogEntry<T> logEntry,
IExternalScopeProvider scopeProvider,
- TextWriter textWriter
- )
+ TextWriter textWriter)
{
var message = logEntry.Formatter?.Invoke(logEntry.State, logEntry.Exception);
diff --git a/GlazeWM.Infrastructure/Serialization/JsonElementExtensions.cs b/GlazeWM.Infrastructure/Serialization/JsonElementExtensions.cs
index a5008495..0642828e 100644
--- a/GlazeWM.Infrastructure/Serialization/JsonElementExtensions.cs
+++ b/GlazeWM.Infrastructure/Serialization/JsonElementExtensions.cs
@@ -47,16 +47,14 @@ namespace GlazeWM.Infrastructure.Serialization
public static T GetEnumProperty<T>(
this JsonElement element,
string propertyName,
- JsonSerializerOptions options) where T : struct, Enum
+ JsonSerializerOptions _) where T : struct, Enum
{
- T value;
- Enum.TryParse<T>(element.GetProperty(propertyName).GetString(), out value);
- return value;
- }
+ var isEnum = Enum.TryParse(element.GetProperty(propertyName).GetString(), out T value);
- private static string ConvertName(string propertyName, JsonSerializerOptions options)
- {
- return options.PropertyNamingPolicy?.ConvertName(propertyName) ?? propertyName;
+ if (!isEnum)
+ throw new Exception();
+
+ return value;
}
}
}
diff --git a/GlazeWM.Infrastructure/Serialization/JsonStringBoolConverter.cs b/GlazeWM.Infrastructure/Serialization/JsonStringBoolConverter.cs
index 4ad58264..46781051 100644
--- a/GlazeWM.Infrastructure/Serialization/JsonStringBoolConverter.cs
+++ b/GlazeWM.Infrastructure/Serialization/JsonStringBoolConverter.cs
@@ -9,6 +9,7 @@ namespace GlazeWM.Infrastructure.Serialization
/// <summary>
/// Allow boolean strings when deserializing to a bool (eg. "true" -> true).
/// </summary>
+ /// <exception cref="JsonException"></exception>
public override bool Read(
ref Utf8JsonReader reader,
Type typeToConvert,
diff --git a/GlazeWM.Infrastructure/WindowsApi/KeybindingService.cs b/GlazeWM.Infrastructure/WindowsApi/KeybindingService.cs
index 962d4c2e..c671131f 100644
--- a/GlazeWM.Infrastructure/WindowsApi/KeybindingService.cs
+++ b/GlazeWM.Infrastructure/WindowsApi/KeybindingService.cs
@@ -52,7 +52,12 @@ namespace GlazeWM.Infrastructure.WindowsApi
public void Start()
{
// Create low-level keyboard hook.
- _ = SetWindowsHookEx(HookType.WH_KEYBOARD_LL, _hookProc, Process.GetCurrentProcess().MainModule.BaseAddress, 0);
+ _ = SetWindowsHookEx(
+ HookType.WH_KEYBOARD_LL,
+ _hookProc,
+ Process.GetCurrentProcess().MainModule.BaseAddress,
+ 0
+ );
}
public void AddGlobalKeybinding(string keybindingString, Action callback)
@@ -90,7 +95,8 @@ namespace GlazeWM.Infrastructure.WindowsApi
private IntPtr KeybindingHookProc(int nCode, IntPtr wParam, IntPtr lParam)
{
- var shouldPassThrough = nCode != 0 || !((uint)wParam == WM_KEYDOWN || (uint)wParam == WM_SYSKEYDOWN);
+ var shouldPassThrough =
+ nCode != 0 || !((uint)wParam == WM_KEYDOWN || (uint)wParam == WM_SYSKEYDOWN);
// If nCode is less than zero, the hook procedure must pass the hook notification to other
// applications via `CallNextHookEx`.
@@ -98,8 +104,10 @@ namespace GlazeWM.Infrastructure.WindowsApi
return CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam);
// Get struct with details about keyboard input event.
- var inputEvent =
- (LowLevelKeyboardInputEvent)Marshal.PtrToStructure(lParam, typeof(LowLevelKeyboardInputEvent));
+ var inputEvent = (LowLevelKeyboardInputEvent)Marshal.PtrToStructure(
+ lParam,
+ typeof(LowLevelKeyboardInputEvent)
+ );
var pressedKey = inputEvent.Key;
var registeredKeybindings = _keybindingsByTriggerKey.GetValueOrDefault(pressedKey);
diff --git a/GlazeWM.Infrastructure/WindowsApi/SystemTrayIcon.cs b/GlazeWM.Infrastructure/WindowsApi/SystemTrayIcon.cs
index a7cd50c7..d107d9a5 100644
--- a/GlazeWM.Infrastructure/WindowsApi/SystemTrayIcon.cs
+++ b/GlazeWM.Infrastructure/WindowsApi/SystemTrayIcon.cs
@@ -21,11 +21,12 @@ namespace GlazeWM.Infrastructure.WindowsApi
foreach (var action in _config.Actions)
{
- // Convert action to `EventHandler` delegate.
- void actionDelegate(object sender, EventArgs e) => action.Value();
-
// Create an entry in the context menu that is shown on click.
- contextMenuStrip.Items.Add(action.Key, null, actionDelegate);
+ contextMenuStrip.Items.Add(
+ action.Key,
+ null,
+ (object sender, EventArgs e) => action.Value()
+ );
}
// Get the embedded icon resource from the entry assembly.
diff --git a/GlazeWM.Infrastructure/WindowsApi/WindowEventService.cs b/GlazeWM.Infrastructure/WindowsApi/WindowEventService.cs
index c879fc98..f6393f77 100644
--- a/GlazeWM.Infrastructure/WindowsApi/WindowEventService.cs
+++ b/GlazeWM.Infrastructure/WindowsApi/WindowEventService.cs
@@ -31,7 +31,14 @@ namespace GlazeWM.Infrastructure.WindowsApi
SetWinEventHook(EventConstant.EVENT_SYSTEM_FOREGROUND, EventConstant.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, _hookProc, 0, 0, 0);
}
- private void WindowEventHookProc(IntPtr hWinEventHook, EventConstant eventType, IntPtr hwnd, ObjectIdentifier idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
+ private void WindowEventHookProc(
+ IntPtr hWinEventHook,
+ EventConstant eventType,
+ IntPtr hwnd,
+ ObjectIdentifier idObject,
+ int idChild,
+ uint dwEventThread,
+ uint dwmsEventTime)
{
// Whether the event is actually associated with a window object (instead of a UI control).
var isWindowEvent = idChild == CHILDID_SELF && idObject == ObjectIdentifier.OBJID_WINDOW
diff --git a/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs b/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs
index 3f76dbd6..834a4825 100644
--- a/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs
+++ b/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs
@@ -141,7 +141,9 @@ namespace GlazeWM.Infrastructure.WindowsApi
public static IntPtr GetWindowLongPtr(IntPtr hWnd, int index)
{
- return Environment.Is64BitProcess ? GetWindowLongPtr64(hWnd, index) : GetWindowLongPtr32(hWnd, index);
+ return Environment.Is64BitProcess
+ ? GetWindowLongPtr64(hWnd, index)
+ : GetWindowLongPtr32(hWnd, index);
}
[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
@@ -152,7 +154,9 @@ namespace GlazeWM.Infrastructure.WindowsApi
public static IntPtr SetWindowLongPtr(IntPtr hWnd, int index, IntPtr newLong)
{
- return Environment.Is64BitProcess ? SetWindowLongPtr64(hWnd, index, newLong) : SetWindowLongPtr32(hWnd, index, newLong);
+ return Environment.Is64BitProcess
+ ? SetWindowLongPtr64(hWnd, index, newLong)
+ : SetWindowLongPtr32(hWnd, index, newLong);
}
[DllImport("user32.dll", SetLastError = true)]