tdf#155414 gtk3 a11y: Honor gtk setting to reduce animation
Use the "gtk-enable-animations" setting [1] to determine whether
animations should be disabled, as is documented in MDN docs
for Firefox using for the "prefers-reduced-motion" CSS media
feature [2].
Note that KDE Plasma's system settings also set this Gtk preference
when taking the steps that [2] describes for reducing motion on KDE
Plasma (s. implementation in [3]):
> In Plasma/KDE: System Settings > Workspace Behavior -> General Behavior >
> "Animation speed" is set all the way to right to "Instant".
On top of
commit 9d68c794d67259a38de1465090f6f1e7fb588d62
Author: Patrick Luby <plubius@neooffice.org>
Date: Fri Jul 21 19:55:02 2023 -0400
tdf#155414 include system "reduce animation" preferences
, this implements the Gtk equivalent of what that change does for macOS.
[1] https://docs.gtk.org/gtk4/property.Settings.gtk-enable-animations.html
[2] https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
[3] https://invent.kde.org/plasma/kde-gtk-config/-/blob/881ae01ad361a03396f7f327365f225ef87688e8/kded/gtkconfig.cpp#L205
Change-Id: Ie229f0d58d53f4629721dd6db465e5b029d9699e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154887
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 890bcdb..6287827 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -618,6 +618,7 @@ public:
virtual weld::Window* GetFrameWeld() const override;
virtual void UpdateDarkMode() override;
virtual bool GetUseDarkMode() const override;
virtual bool GetUseReducedAnimation() const override;
static GtkSalFrame *getFromWindow( GtkWidget *pWindow );
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index d8d5760..ad9b658 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -1399,6 +1399,16 @@ bool GtkSalFrame::GetUseDarkMode() const
return bDarkIconTheme;
}
bool GtkSalFrame::GetUseReducedAnimation() const
{
if (!m_pWindow)
return false;
GtkSettings* pSettings = gtk_widget_get_settings(m_pWindow);
gboolean bAnimations;
g_object_get(pSettings, "gtk-enable-animations", &bAnimations, nullptr);
return !bAnimations;
}
static void settings_portal_changed_cb(GDBusProxy*, const char*, const char* signal_name,
GVariant* parameters, gpointer frame)
{