diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs
index c7b294747..9159f042c 100644
--- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs
+++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs
@@ -1,8 +1,10 @@
using System.Collections.Generic;
+using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
+using System.Runtime.InteropServices;
using Dalamud.Game.Text;
using Dalamud.Interface.FontIdentifier;
@@ -370,7 +372,7 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
///
/// Gets or sets a value indicating whether to reduce motions (animations).
///
- public bool ReduceMotions { get; set; } = false;
+ public bool? ReduceMotions { get; set; }
///
/// Gets or sets a value indicating whether or not market board data should be uploaded.
@@ -486,6 +488,15 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
deserialized ??= new DalamudConfiguration();
deserialized.configPath = path;
+
+ try
+ {
+ deserialized.SetDefaults();
+ }
+ catch (Exception e)
+ {
+ Log.Error(e, "Failed to set defaults for DalamudConfiguration");
+ }
return deserialized;
}
@@ -527,6 +538,31 @@ internal sealed class DalamudConfiguration : IInternalDisposableService
}
}
+ private void SetDefaults()
+ {
+ // "Reduced motion"
+ if (!this.ReduceMotions.HasValue)
+ {
+ // https://source.chromium.org/chromium/chromium/src/+/main:ui/gfx/animation/animation_win.cc;l=29?q=ReducedMotion&ss=chromium
+ var winAnimEnabled = 0;
+ var success = NativeFunctions.SystemParametersInfo(
+ (uint)NativeFunctions.AccessibilityParameter.SPI_GETCLIENTAREAANIMATION,
+ 0,
+ ref winAnimEnabled,
+ 0);
+
+ if (!success)
+ {
+ Log.Warning("Failed to get Windows animation setting, assuming reduced motion is off (GetLastError: {GetLastError:X})", Marshal.GetLastPInvokeError());
+ this.ReduceMotions = false;
+ }
+ else
+ {
+ this.ReduceMotions = winAnimEnabled == 0;
+ }
+ }
+ }
+
private void Save()
{
ThreadSafety.AssertMainThread();
diff --git a/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.ImGui.cs b/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.ImGui.cs
index 08e2817a5..6d7a47c27 100644
--- a/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.ImGui.cs
+++ b/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.ImGui.cs
@@ -456,7 +456,7 @@ internal sealed partial class ActiveNotification
private void DrawExpiryPie(bool warrantsExtension, Vector2 offset, Vector2 size)
{
- if (!Service.Get().ReduceMotions)
+ if (!Service.Get().ReduceMotions ?? false)
return;
// circle here; 0 means 0deg; 1 means 360deg
@@ -536,7 +536,7 @@ internal sealed partial class ActiveNotification
private void DrawExpiryBar(bool warrantsExtension)
{
- if (Service.Get().ReduceMotions)
+ if (Service.Get().ReduceMotions ?? false)
return;
float barL, barR;
diff --git a/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs b/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs
index 3cad13242..5ae7de5f7 100644
--- a/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs
+++ b/Dalamud/Interface/ImGuiNotification/Internal/ActiveNotification.cs
@@ -188,7 +188,7 @@ internal sealed partial class ActiveNotification : IActiveNotification
set => this.newProgress = value;
}
- private static bool ReducedMotions => Service.Get().ReduceMotions;
+ private static bool ReducedMotions => Service.Get().ReduceMotions ?? false;
/// Gets the eased progress.
private float ProgressEased
diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs
index 53faed6ec..c7fcdc58d 100644
--- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs
+++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs
@@ -134,7 +134,7 @@ public class SettingsTabLook : SettingsTab
new SettingsEntry(
Loc.Localize("DalamudSettingReducedMotion", "Reduce motions"),
Loc.Localize("DalamudSettingReducedMotion", "This will suppress certain animations from Dalamud, such as the notification popup."),
- c => c.ReduceMotions,
+ c => c.ReduceMotions ?? false,
(v, c) => c.ReduceMotions = v),
};
diff --git a/Dalamud/NativeFunctions.cs b/Dalamud/NativeFunctions.cs
index 92dfe5dd7..14a39a6be 100644
--- a/Dalamud/NativeFunctions.cs
+++ b/Dalamud/NativeFunctions.cs
@@ -826,6 +826,27 @@ internal static partial class NativeFunctions
///
public uint Timeout;
}
+
+ ///
+ /// Parameters for use with SystemParametersInfo.
+ ///
+ public enum AccessibilityParameter
+ {
+#pragma warning disable SA1602
+ SPI_GETCLIENTAREAANIMATION = 0x1042,
+#pragma warning restore SA1602
+ }
+
+ ///
+ /// Retrieves or sets the value of one of the system-wide parameters. This function can also update the user profile while setting a parameter.
+ ///
+ /// The system-wide parameter to be retrieved or set.
+ /// A parameter whose usage and format depends on the system parameter being queried or set.
+ /// A parameter whose usage and format depends on the system parameter being queried or set. If not otherwise indicated, you must specify zero for this parameter.
+ /// If a system parameter is being set, specifies whether the user profile is to be updated, and if so, whether the WM_SETTINGCHANGE message is to be broadcast to all top-level windows to notify them of the change.
+ /// If the function succeeds, the return value is a nonzero value.
+ [DllImport("user32.dll", SetLastError = true)]
+ public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref int pvParam, uint fWinIni);
}
///