From 910ba1eb1ee43736406e90d7d49819b3af3ddadc Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 25 Sep 2019 14:31:48 +0100 Subject: [PATCH] Load animation speed from new global animation speed controller Summary: It doesn't belong with advanced compositing settings as it's quite user friendly, and we also want to adjust other animation speeds. May as well do it together. In the current form all compositing is still completely reinitiliased like with the previous slider. Change notifications come in the form of KConfigWatcher rather than our own bespoke update interface. Test Plan: Moved new slider, minimised a window. It still behaved as expected. Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: zzag, broulik, anthonyfieroni, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D22887 --- composite.cpp | 1 + kwin.kcfg | 11 ++++++----- options.cpp | 18 ++++++++++++------ options.h | 10 +++++----- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/composite.cpp b/composite.cpp index 1a6ba4c045..319fb5ce22 100644 --- a/composite.cpp +++ b/composite.cpp @@ -131,6 +131,7 @@ Compositor::Compositor(QObject* workspace) , m_composeAtSwapCompletion(false) { connect(options, &Options::configChanged, this, &Compositor::configChanged); + connect(options, &Options::animationSpeedChanged, this, &Compositor::configChanged); m_monotonicClock.start(); diff --git a/kwin.kcfg b/kwin.kcfg index 453e2b6e9e..861b6c9943 100644 --- a/kwin.kcfg +++ b/kwin.kcfg @@ -248,11 +248,6 @@ 4 6 - - 3 - 0 - 6 - glx @@ -301,4 +296,10 @@ thumbnails + + + 1 + 0 + + diff --git a/options.cpp b/options.cpp index 8427156271..fc727855fc 100644 --- a/options.cpp +++ b/options.cpp @@ -143,10 +143,16 @@ Options::Options(QObject *parent) , borderless_maximized_windows(false) , show_geometry_tip(false) , condensed_title(false) - , animationSpeed(Options::defaultAnimationSpeed()) { m_settings->setDefaults(); syncFromKcfgc(); + + m_configWatcher = KConfigWatcher::create(m_settings->sharedConfig()); + connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, [this](const KConfigGroup &group, const QByteArrayList &names) { + if (group.name() == QLatin1String("KDE") && names.contains(QByteArrayLiteral("AnimationDurationFactor"))) { + emit animationSpeedChanged(); + } + }); } Options::~Options() @@ -933,9 +939,6 @@ void Options::reloadCompositingSettings(bool force) previews = HiddenPreviewsAlways; setHiddenPreviews(previews); - // TOOD: add setter - animationSpeed = qBound(0, config.readEntry("AnimationSpeed", Options::defaultAnimationSpeed()), 6); - auto interfaceToKey = [](OpenGLPlatformInterface interface) { switch (interface) { case GlxPlatformInterface: @@ -1062,8 +1065,11 @@ Options::MouseCommand Options::wheelToMouseCommand(MouseWheelCommand com, int de double Options::animationTimeFactor() const { - const double factors[] = { 0, 0.2, 0.5, 1, 2, 4, 20 }; - return factors[ animationSpeed ]; + #ifndef KCMRULES + return m_settings->animationDurationFactor(); +#else + return 0; +#endif } Options::WindowOperation Options::operationMaxButtonClick(Qt::MouseButtons button) const diff --git a/options.h b/options.h index 8d92f09a83..ee31cfea90 100644 --- a/options.h +++ b/options.h @@ -26,6 +26,8 @@ along with this program. If not, see . #include "main.h" #include "placement.h" +#include + namespace KWin { @@ -741,10 +743,6 @@ public: static OpenGLPlatformInterface defaultGlPlatformInterface() { return kwinApp()->shouldUseWaylandForCompositing() ? EglPlatformInterface : GlxPlatformInterface; } - static int defaultAnimationSpeed() { - return 3; - } - /** * Performs loading all settings except compositing related. */ @@ -817,6 +815,7 @@ Q_SIGNALS: void glPreferBufferSwapChanged(); void glPlatformInterfaceChanged(); void windowsBlockCompositingChanged(); + void animationSpeedChanged(); void configChanged(); @@ -824,6 +823,8 @@ private: void setElectricBorders(int borders); void syncFromKcfgc(); QScopedPointer m_settings; + KConfigWatcher::Ptr m_configWatcher; + FocusPolicy m_focusPolicy; bool m_nextFocusPrefersMouse; bool m_clickRaise; @@ -888,7 +889,6 @@ private: bool borderless_maximized_windows; bool show_geometry_tip; bool condensed_title; - int animationSpeed; // 0 - instant, 5 - very slow QHash m_modifierOnlyShortcuts;