Commit 910ba1eb authored by David Edmundson's avatar David Edmundson
Browse files

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
parent d78fda30
......@@ -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();
......
......@@ -248,11 +248,6 @@
<min>4</min>
<max>6</max>
</entry>
<entry name="AnimationSpeed" type="Int">
<default>3</default>
<min>0</min>
<max>6</max>
</entry>
<entry name="GLPlatformInterface" type="String">
<default>glx</default>
</entry>
......@@ -301,4 +296,10 @@
<default>thumbnails</default>
</entry>
</group>
<group name="KDE">
<entry name="AnimationDurationFactor" type="Double">
<default>1</default>
<min>0</min>
</entry>
</group>
</kcfg>
......@@ -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
......
......@@ -26,6 +26,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "main.h"
#include "placement.h"
#include <KConfigWatcher>
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<Settings> 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<Qt::KeyboardModifier, QStringList> m_modifierOnlyShortcuts;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment