vcl/inc/qt5/QtFrame.hxx | 1 + vcl/inc/qt5/QtInstance.hxx | 2 ++ vcl/inc/unx/gtk/gtkframe.hxx | 1 + vcl/qt5/QtFrame.cxx | 2 ++ vcl/unx/gtk3/gtkframe.cxx | 10 ++++++++++ vcl/unx/kf5/KFSalInstance.cxx | 23 +++++++++++++++++++++++ vcl/unx/kf5/KFSalInstance.hxx | 2 ++ 7 files changed, 41 insertions(+)
New commits: commit f3a4b6e1d71ed40d84ef65c6626fb7eb77a13545 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Jul 25 11:52:32 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Jul 25 14:48:26 2023 +0200 tdf#155414 kf a11y: Honor KDE Plasma setting to reduce animation When using the kf5/kf6 VCL plugin on KDE Plasma, use the animation speed setting to determine whether animations should be disabled, in line with what is documented in MDN docs for Firefox using for the "prefers-reduced-motion" CSS media feature [1] and how kde-gtk-config maps that to the "gtk-enable-animations" setting [2]. The setting can be set as described in [2]: > 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 <plub...@neooffice.org> Date: Fri Jul 21 19:55:02 2023 -0400 tdf#155414 include system "reduce animation" preferences , this basically implements the KF5/KDE Plasma equivalent of what that change does for macOS. Other than Gtk, Qt does not seem to have a general way to specify that animations should be reduced/disabled, so evaluate that based on the desktop environment instead, and implement for KDE Plasma for the kf5/kf6 VCL plugin only for now, which is probably the most common use case. Logically, this would better fit in the qt5/qt6 VCL plugin than the kf5/kf6 one, but do it in the KF-specific code to avoid a dependency on KF5/KF6 libraries in qt5/qt6. (And other than qt5/qt6, kf5/kf6 are auto-selected in Qt-based desktop environments, so it shouldn't make much of a difference in practice.) Another alternative - should the need aries - might be to move this from the VCL plugin to the desktop backend (`shell/source/backends/kf5be/` for the case of KDE Plasma 5.) and introduce a new property for that. [1] https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion [2] https://docs.gtk.org/gtk4/property.Settings.gtk-enable-animations.html [3] https://invent.kde.org/plasma/kde-gtk-config/-/blob/881ae01ad361a03396f7f327365f225ef87688e8/kded/gtkconfig.cpp#L205 Change-Id: I35cd6c2568a3716491581e51dfaeaf32cad454aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154888 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtFrame.hxx b/vcl/inc/qt5/QtFrame.hxx index 1fd010d7c8ae..90195f55a543 100644 --- a/vcl/inc/qt5/QtFrame.hxx +++ b/vcl/inc/qt5/QtFrame.hxx @@ -214,6 +214,7 @@ public: virtual void SetScreenNumber(unsigned int) override; virtual void SetApplicationID(const OUString&) override; virtual void ResolveWindowHandle(SystemEnvData& rData) const override; + virtual bool GetUseReducedAnimation() const override; inline bool CallCallback(SalEvent nEvent, const void* pEvent) const; diff --git a/vcl/inc/qt5/QtInstance.hxx b/vcl/inc/qt5/QtInstance.hxx index a0a2f6fa60f7..2073c8ac05d8 100644 --- a/vcl/inc/qt5/QtInstance.hxx +++ b/vcl/inc/qt5/QtInstance.hxx @@ -174,6 +174,8 @@ public: virtual css::uno::Reference<css::uno::XInterface> ImplCreateDropTarget(const SystemEnvData*) override; + // whether to reduce animations; KFSalInstance overrides this to read Plasma settings + virtual bool GetUseReducedAnimation() { return false; } void UpdateStyle(bool bFontsChanged); void* CreateGStreamerSink(const SystemChildWindow*) override; diff --git a/vcl/qt5/QtFrame.cxx b/vcl/qt5/QtFrame.cxx index 08d206261b88..0bd436266714 100644 --- a/vcl/qt5/QtFrame.cxx +++ b/vcl/qt5/QtFrame.cxx @@ -1349,6 +1349,8 @@ void QtFrame::ResolveWindowHandle(SystemEnvData& rData) const rData.SetWindowHandle(static_cast<QWidget*>(rData.pWidget)->winId()); } +bool QtFrame::GetUseReducedAnimation() const { return GetQtInstance()->GetUseReducedAnimation(); } + // Drag'n'drop foo void QtFrame::registerDragSource(QtDragSource* pDragSource) diff --git a/vcl/unx/kf5/KFSalInstance.cxx b/vcl/unx/kf5/KFSalInstance.cxx index bed513167957..cc280e9d99a1 100644 --- a/vcl/unx/kf5/KFSalInstance.cxx +++ b/vcl/unx/kf5/KFSalInstance.cxx @@ -21,6 +21,8 @@ #include <utility> +#include <KConfigCore/KConfigGroup> +#include <KConfigCore/KSharedConfig> #include <QtWidgets/QApplication> #include <sal/log.hxx> @@ -40,6 +42,27 @@ KFSalInstance::KFSalInstance(std::unique_ptr<QApplication>& pQApp) pSVData->maAppData.mxToolkitName = constructToolkitID(sToolkit); } +bool KFSalInstance::GetUseReducedAnimation() +{ + // since Qt doesn not have a standard way to disable animations for the toolkit + // use the animation speed setting when on KDE Plasma, in accordance with how kde-gtk-config + // sets the Gtk setting based on that: + // https://invent.kde.org/plasma/kde-gtk-config/-/blob/881ae01ad361a03396f7f327365f225ef87688e8/kded/configvalueprovider.cpp#L239 + // (ideally, this should probably be done in the desktop backend rather than directly + // in the VCL plugin) + const OUString sDesktop = Application::GetDesktopEnvironment(); + if (sDesktop == "PLASMA5" || sDesktop == "PLASMA6") + { + KSharedConfigPtr pSharedConfig = KSharedConfig::openConfig(); + KConfigGroup aGeneralConfig = pSharedConfig->group(QStringLiteral("KDE")); + const qreal fAnimationSpeedModifier + = qMax(0.0, aGeneralConfig.readEntry("AnimationDurationFactor", 1.0)); + return qFuzzyIsNull(fAnimationSpeedModifier); + } + + return QtInstance::GetUseReducedAnimation(); +} + bool KFSalInstance::hasNativeFileSelection() const { const OUString sDesktop = Application::GetDesktopEnvironment(); diff --git a/vcl/unx/kf5/KFSalInstance.hxx b/vcl/unx/kf5/KFSalInstance.hxx index b4c12e895e48..86795a1ba94a 100644 --- a/vcl/unx/kf5/KFSalInstance.hxx +++ b/vcl/unx/kf5/KFSalInstance.hxx @@ -28,6 +28,8 @@ class KFSalInstance final : public QtInstance createPicker(css::uno::Reference<css::uno::XComponentContext> const& context, QFileDialog::FileMode) override; + virtual bool GetUseReducedAnimation() override; + public: explicit KFSalInstance(std::unique_ptr<QApplication>& pQApp); }; commit e320460f9793608ef79aab402b3a03dc28ba7dd5 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Jul 25 11:40:42 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Jul 25 14:48:20 2023 +0200 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 <plub...@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.wegh...@posteo.de> diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index 890bcdb8a6ea..62878279d577 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 d8d5760a16bb..ad9b6586080f 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) {