GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: option to disable window transition animations (#389)
lars-bergerd67524485c83
diff --git a/GlazeWM.App.Watcher/WatcherStartup.cs b/GlazeWM.App.Watcher/WatcherStartup.csindex 84dfc835..eeed4de7 100644--- a/GlazeWM.App.Watcher/WatcherStartup.cs+++ b/GlazeWM.App.Watcher/WatcherStartup.cs@@ -10,6 +10,10 @@ namespace GlazeWM.App.Watcher{public sealed class WatcherStartup{+ /// <summary>+ /// Watcher is responsible for restoring all managed handles when the main process is+ /// killed unexpectedly.+ /// </summary>public static async Task<ExitCode> Run(int ipcServerPort){var client = new IpcClient(ipcServerPort);diff --git a/GlazeWM.App.WindowManager/WmStartup.cs b/GlazeWM.App.WindowManager/WmStartup.csindex 78488316..b4ec7750 100644--- a/GlazeWM.App.WindowManager/WmStartup.cs+++ b/GlazeWM.App.WindowManager/WmStartup.cs@@ -76,6 +76,16 @@ namespace GlazeWM.App.WindowManager_systemTrayIcon = new SystemTrayIcon(systemTrayIconConfig);_systemTrayIcon.Show();+ var windowAnimations = _userConfigService.GeneralConfig.WindowAnimations;++ // Enable/disable window transition animations.+ if (windowAnimations is not WindowAnimations.Unchanged)+ {+ SystemSettings.SetWindowAnimationsEnabled(+ windowAnimations is WindowAnimations.True+ );+ }+if (_userConfigService.FocusBorderConfig.Active.Enabled ||_userConfigService.FocusBorderConfig.Inactive.Enabled){diff --git a/GlazeWM.App/Resources/sample-config.yaml b/GlazeWM.App/Resources/sample-config.yamlindex bce40742..82ef0921 100644--- a/GlazeWM.App/Resources/sample-config.yaml+++ b/GlazeWM.App/Resources/sample-config.yaml@@ -18,6 +18,10 @@ general:floating_window_move_amount: "5%"# When enabled, switching to the current workspace activates the previously focused workspacetoggle_workspace_on_refocus: false+ # *Strongly* recommended to set to 'false'. Whether to globally enable/disable+ # window transition animations (on minimize, close, etc). Set to 'unchanged'+ # to make no setting changes.+ window_animations: "unchanged"bar:height: "30px"diff --git a/GlazeWM.Domain/UserConfigs/GeneralConfig.cs b/GlazeWM.Domain/UserConfigs/GeneralConfig.csindex 7d0f53ae..27a88df8 100644--- a/GlazeWM.Domain/UserConfigs/GeneralConfig.cs+++ b/GlazeWM.Domain/UserConfigs/GeneralConfig.cs@@ -8,7 +8,6 @@ namespace GlazeWM.Domain.UserConfigspublic bool ShowFloatingOnTop { get; set; }/// <summary>/// Center the cursor in the middle of a newly focused window- /// TODO: Not officially released because implementation is buggy. Use at own risk./// </summary>public bool CursorFollowsFocus { get; set; }/// <summary>@@ -23,5 +22,9 @@ namespace GlazeWM.Domain.UserConfigs/// If activated, by switching to the current workspace the previous focused workspace is activated./// </summary>public bool ToggleWorkspaceOnRefocus { get; set; }+ /// <summary>+ /// Whether to enable window transition animations (on minimize, close, etc).+ /// </summary>+ public WindowAnimations WindowAnimations { get; set; } = WindowAnimations.Unchanged;}}diff --git a/GlazeWM.Domain/UserConfigs/WindowAnimations.cs b/GlazeWM.Domain/UserConfigs/WindowAnimations.csnew file mode 100644index 00000000..319672b1--- /dev/null+++ b/GlazeWM.Domain/UserConfigs/WindowAnimations.cs@@ -0,0 +1,9 @@+namespace GlazeWM.Domain.UserConfigs+{+ public enum WindowAnimations+ {+ Unchanged,+ True,+ False+ }+}diff --git a/GlazeWM.Infrastructure/WindowsApi/SystemSettings.cs b/GlazeWM.Infrastructure/WindowsApi/SystemSettings.csnew file mode 100644index 00000000..a908e6ad--- /dev/null+++ b/GlazeWM.Infrastructure/WindowsApi/SystemSettings.cs@@ -0,0 +1,22 @@+using static GlazeWM.Infrastructure.WindowsApi.WindowsApiService;++namespace GlazeWM.Infrastructure.WindowsApi+{+ public static class SystemSettings+ {+ /// <summary>+ /// Modify global setting for whether window transition animations are enabled.+ /// </summary>+ public static void SetWindowAnimationsEnabled(bool enabled)+ {+ var animationInfo = AnimationInfo.Create(enabled);++ SystemParametersInfo(+ SystemParametersInfoFlags.SetAnimation,+ animationInfo.CallbackSize,+ ref animationInfo,+ 0+ );+ }+ }+}diff --git a/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs b/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.csindex 1619cb3d..5b908037 100644--- a/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs+++ b/GlazeWM.Infrastructure/WindowsApi/WindowsApiService.cs@@ -464,6 +464,37 @@ namespace GlazeWM.Infrastructure.WindowsApi[DllImport("dwmapi.dll")]public static extern int DwmSetWindowAttribute(IntPtr handle, uint attribute, ref uint value, uint size);+ [StructLayout(LayoutKind.Sequential)]+ public struct AnimationInfo+ {+ public uint CallbackSize;+ public int MinAnimate;++ public bool IsEnabled+ {+ readonly get => MinAnimate != 0;+ set => MinAnimate = value ? 1 : 0;+ }++ public static AnimationInfo Create(bool isEnabled)+ {+ return new()+ {+ IsEnabled = isEnabled,+ CallbackSize = (uint)Marshal.SizeOf(typeof(AnimationInfo))+ };+ }+ }++ public enum SystemParametersInfoFlags : uint+ {+ GetAnimation = 72,+ SetAnimation = 73,+ }++ [DllImport("User32.dll", SetLastError = true)]+ public static extern bool SystemParametersInfo(SystemParametersInfoFlags uiAction, uint uiParam, ref AnimationInfo pvParam, uint fWinIni);+[DllImport("kernel32.dll")]internal static extern bool AttachConsole(uint dwProcessId);