GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: set minimized and maximized commands (#99)
lars-berger621c146cd29c
diff --git a/GlazeWM.Bootstrapper/sample-config.yaml b/GlazeWM.Bootstrapper/sample-config.yamlindex b5e00f2a..a47899b0 100644--- a/GlazeWM.Bootstrapper/sample-config.yaml+++ b/GlazeWM.Bootstrapper/sample-config.yaml@@ -93,6 +93,12 @@ keybindings:- command: "toggle floating"binding: "Alt+Shift+Space"+ - command: "set minimized"+ binding: "Alt+M"++ - command: "toggle maximized"+ binding: "Alt+X"+- command: "close"binding: "Alt+Shift+Q"diff --git a/GlazeWM.Domain/DependencyInjection.cs b/GlazeWM.Domain/DependencyInjection.csindex 6b12b33f..036c8cb1 100644--- a/GlazeWM.Domain/DependencyInjection.cs+++ b/GlazeWM.Domain/DependencyInjection.cs@@ -60,8 +60,11 @@ namespace GlazeWM.Domainservices.AddSingleton<ICommandHandler<ResizeWindowCommand>, ResizeWindowHandler>();services.AddSingleton<ICommandHandler<ResizeWindowBordersCommand>, ResizeWindowBordersHandler>();services.AddSingleton<ICommandHandler<SetFloatingCommand>, SetFloatingHandler>();+ services.AddSingleton<ICommandHandler<SetMinimizedCommand>, SetMinimizedHandler>();+ services.AddSingleton<ICommandHandler<SetMaximizedCommand>, SetMaximizedHandler>();services.AddSingleton<ICommandHandler<ShowAllWindowsCommand>, ShowAllWindowsHandler>();services.AddSingleton<ICommandHandler<ToggleFloatingCommand>, ToggleFloatingHandler>();+ services.AddSingleton<ICommandHandler<ToggleMaximizedCommand>, ToggleMaximizedHandler>();services.AddSingleton<ICommandHandler<ActivateWorkspaceCommand>, ActivateWorkspaceHandler>();services.AddSingleton<ICommandHandler<DeactivateWorkspaceCommand>, DeactivateWorkspaceHandler>();services.AddSingleton<ICommandHandler<DisplayWorkspaceCommand>, DisplayWorkspaceHandler>();diff --git a/GlazeWM.Domain/UserConfigs/CommandParsingService.cs b/GlazeWM.Domain/UserConfigs/CommandParsingService.csindex 624ad800..5769f472 100644--- a/GlazeWM.Domain/UserConfigs/CommandParsingService.cs+++ b/GlazeWM.Domain/UserConfigs/CommandParsingService.cs@@ -138,6 +138,12 @@ namespace GlazeWM.Domain.UserConfigs"floating" => subjectContainer is Window? new SetFloatingCommand(subjectContainer as Window): new NoopCommand(),+ "minimized" => subjectContainer is Window+ ? new SetMinimizedCommand(subjectContainer as Window)+ : new NoopCommand(),+ "maximized" => subjectContainer is Window+ ? new SetMaximizedCommand(subjectContainer as Window)+ : new NoopCommand(),_ => throw new ArgumentException(null, nameof(commandParts)),};}@@ -149,6 +155,9 @@ namespace GlazeWM.Domain.UserConfigs"floating" => subjectContainer is Window? new ToggleFloatingCommand(subjectContainer as Window): new NoopCommand(),+ "maximized" => subjectContainer is Window+ ? new ToggleMaximizedCommand(subjectContainer as Window)+ : new NoopCommand(),"focus" => commandParts[2] switch{"mode" => new ToggleFocusModeCommand(),diff --git a/GlazeWM.Domain/Windows/CommandHandlers/SetMaximizedHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/SetMaximizedHandler.csnew file mode 100644index 00000000..05630b4c--- /dev/null+++ b/GlazeWM.Domain/Windows/CommandHandlers/SetMaximizedHandler.cs@@ -0,0 +1,18 @@+using GlazeWM.Domain.Windows.Commands;+using GlazeWM.Infrastructure.Bussing;+using static GlazeWM.Infrastructure.WindowsApi.WindowsApiService;++namespace GlazeWM.Domain.Windows.CommandHandlers+{+ internal class SetMaximizedHandler : ICommandHandler<SetMaximizedCommand>+ {+ public CommandResponse Handle(SetMaximizedCommand command)+ {+ var window = command.Window;++ ShowWindow(window.Hwnd, ShowWindowCommands.MAXIMIZE);++ return CommandResponse.Ok;+ }+ }+}diff --git a/GlazeWM.Domain/Windows/CommandHandlers/SetMinimizedHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/SetMinimizedHandler.csnew file mode 100644index 00000000..b09204c1--- /dev/null+++ b/GlazeWM.Domain/Windows/CommandHandlers/SetMinimizedHandler.cs@@ -0,0 +1,18 @@+using GlazeWM.Domain.Windows.Commands;+using GlazeWM.Infrastructure.Bussing;+using static GlazeWM.Infrastructure.WindowsApi.WindowsApiService;++namespace GlazeWM.Domain.Windows.CommandHandlers+{+ internal class SetMinimizedHandler : ICommandHandler<SetMinimizedCommand>+ {+ public CommandResponse Handle(SetMinimizedCommand command)+ {+ var window = command.Window;++ ShowWindow(window.Hwnd, ShowWindowCommands.MINIMIZE);++ return CommandResponse.Ok;+ }+ }+}diff --git a/GlazeWM.Domain/Windows/CommandHandlers/ToggleMaximizedHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/ToggleMaximizedHandler.csnew file mode 100644index 00000000..b3574558--- /dev/null+++ b/GlazeWM.Domain/Windows/CommandHandlers/ToggleMaximizedHandler.cs@@ -0,0 +1,21 @@+using GlazeWM.Domain.Windows.Commands;+using GlazeWM.Infrastructure.Bussing;+using static GlazeWM.Infrastructure.WindowsApi.WindowsApiService;++namespace GlazeWM.Domain.Windows.CommandHandlers+{+ internal class ToggleMaximizedHandler : ICommandHandler<ToggleMaximizedCommand>+ {+ public CommandResponse Handle(ToggleMaximizedCommand command)+ {+ var window = command.Window;++ if (window.HasWindowStyle(WS.WS_MAXIMIZE))+ ShowWindow(window.Hwnd, ShowWindowCommands.RESTORE);+ else+ ShowWindow(window.Hwnd, ShowWindowCommands.MAXIMIZE);++ return CommandResponse.Ok;+ }+ }+}diff --git a/GlazeWM.Domain/Windows/Commands/SetMaximizedCommand.cs b/GlazeWM.Domain/Windows/Commands/SetMaximizedCommand.csnew file mode 100644index 00000000..edc55d2a--- /dev/null+++ b/GlazeWM.Domain/Windows/Commands/SetMaximizedCommand.cs@@ -0,0 +1,14 @@+using GlazeWM.Infrastructure.Bussing;++namespace GlazeWM.Domain.Windows.Commands+{+ public class SetMaximizedCommand : Command+ {+ public Window Window { get; }++ public SetMaximizedCommand(Window window)+ {+ Window = window;+ }+ }+}diff --git a/GlazeWM.Domain/Windows/Commands/SetMinimizedCommand.cs b/GlazeWM.Domain/Windows/Commands/SetMinimizedCommand.csnew file mode 100644index 00000000..b2e4529d--- /dev/null+++ b/GlazeWM.Domain/Windows/Commands/SetMinimizedCommand.cs@@ -0,0 +1,14 @@+using GlazeWM.Infrastructure.Bussing;++namespace GlazeWM.Domain.Windows.Commands+{+ public class SetMinimizedCommand : Command+ {+ public Window Window { get; }++ public SetMinimizedCommand(Window window)+ {+ Window = window;+ }+ }+}diff --git a/GlazeWM.Domain/Windows/Commands/ToggleMaximizedCommand.cs b/GlazeWM.Domain/Windows/Commands/ToggleMaximizedCommand.csnew file mode 100644index 00000000..b088ef19--- /dev/null+++ b/GlazeWM.Domain/Windows/Commands/ToggleMaximizedCommand.cs@@ -0,0 +1,14 @@+using GlazeWM.Infrastructure.Bussing;++namespace GlazeWM.Domain.Windows.Commands+{+ public class ToggleMaximizedCommand : Command+ {+ public Window Window { get; }++ public ToggleMaximizedCommand(Window window)+ {+ Window = window;+ }+ }+}diff --git a/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs b/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.csindex adcfea3a..cc59c72e 100644--- a/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs+++ b/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs@@ -191,6 +191,8 @@ namespace GlazeWM.Infrastructure.WindowsApi/// </summary>public enum ShowWindowCommands : uint{+ MINIMIZE = 2,+ MAXIMIZE = 3,RESTORE = 9,}