Commit a486b471 authored by David Edmundson's avatar David Edmundson
Browse files

[kcmkwin/compositing] Hide animation speed slider on Plasma

Summary:
Hide the animation speed slider on Plasma as this becomes duplicated
with the global "animation speed" slider.

Also port to the new format for the config option which stores the
actual multiplier, not a magic number.

Test Plan:
Didn't appear normally
Manually modified env; slider appeared
Tested load/save of defaults and the two extremes

Reviewers: zzag

Reviewed By: zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24075
parent 78a66fcf
......@@ -37,7 +37,7 @@ namespace Compositing {
Compositing::Compositing(QObject *parent)
: QObject(parent)
, m_animationSpeed(0)
, m_animationSpeed(1.0)
, m_windowThumbnail(0)
, m_glScaleFilter(0)
, m_xrScaleFilter(false)
......@@ -49,6 +49,7 @@ Compositing::Compositing(QObject *parent)
, m_openGLPlatformInterface(0)
, m_windowsBlockCompositing(true)
, m_compositingInterface(new OrgKdeKwinCompositingInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Compositor"), QDBusConnection::sessionBus(), this))
, m_config(KSharedConfig::openConfig("kwinrc"))
{
reset();
connect(this, &Compositing::animationSpeedChanged, this, &Compositing::changed);
......@@ -68,8 +69,10 @@ Compositing::Compositing(QObject *parent)
void Compositing::reset()
{
KConfigGroup kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc")), QStringLiteral("Compositing"));
setAnimationSpeed(kwinConfig.readEntry("AnimationSpeed", 3));
KConfigGroup globalConfig(m_config, QStringLiteral("KDE"));
setAnimationSpeed(globalConfig.readEntry("AnimationDurationFactor", 1.0));
KConfigGroup kwinConfig(m_config, QStringLiteral("Compositing"));
setWindowThumbnail(kwinConfig.readEntry("HiddenPreviews", 5) - 4);
setGlScaleFilter(kwinConfig.readEntry("GLTextureFilter", 2));
setXrScaleFilter(kwinConfig.readEntry("XRenderSmoothScale", false));
......@@ -119,7 +122,7 @@ void Compositing::reset()
void Compositing::defaults()
{
setAnimationSpeed(3);
setAnimationSpeed(1.0);
setWindowThumbnail(1);
setGlScaleFilter(2);
setXrScaleFilter(false);
......@@ -133,13 +136,13 @@ void Compositing::defaults()
bool Compositing::OpenGLIsUnsafe() const
{
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Compositing");
KConfigGroup kwinConfig(m_config, "Compositing");
return kwinConfig.readEntry("OpenGLIsUnsafe", true);
}
bool Compositing::OpenGLIsBroken()
{
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Compositing");
KConfigGroup kwinConfig(m_config, "Compositing");
QString oldBackend = kwinConfig.readEntry("Backend", "OpenGL");
kwinConfig.writeEntry("Backend", "OpenGL");
......@@ -158,12 +161,12 @@ bool Compositing::OpenGLIsBroken()
void Compositing::reenableOpenGLDetection()
{
KConfigGroup kwinConfig(KSharedConfig::openConfig("kwinrc"), "Compositing");
KConfigGroup kwinConfig(m_config, "Compositing");
kwinConfig.writeEntry("OpenGLIsUnsafe", false);
kwinConfig.sync();
}
int Compositing::animationSpeed() const
qreal Compositing::animationSpeed() const
{
return m_animationSpeed;
}
......@@ -198,7 +201,7 @@ bool Compositing::compositingEnabled() const
return m_compositingEnabled;
}
void Compositing::setAnimationSpeed(int speed)
void Compositing::setAnimationSpeed(qreal speed)
{
if (speed == m_animationSpeed) {
return;
......@@ -267,8 +270,14 @@ void Compositing::setCompositingEnabled(bool enabled)
void Compositing::save()
{
KConfigGroup kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc")), "Compositing");
kwinConfig.writeEntry("AnimationSpeed", animationSpeed());
// this writes to the KDE group of the kwinrc, when loading we rely on kconfig cascading to
// load a global value, or allow a kwin override
KConfigGroup generalConfig(m_config, "KDE");
if (!isRunningPlasma()) {
generalConfig.writeEntry("AnimationDurationFactor", animationSpeed());
}
KConfigGroup kwinConfig(m_config, "Compositing");
kwinConfig.writeEntry("HiddenPreviews", windowThumbnail() + 4);
kwinConfig.writeEntry("GLTextureFilter", glScaleFilter());
kwinConfig.writeEntry("XRenderSmoothScale", xrScaleFilter());
......@@ -365,6 +374,11 @@ bool Compositing::compositingRequired() const
return m_compositingInterface->platformRequiresCompositing();
}
bool Compositing::isRunningPlasma()
{
return qgetenv("XDG_CURRENT_DESKTOP") == "KDE";
}
CompositingType::CompositingType(QObject *parent)
: QAbstractItemModel(parent) {
......
......@@ -24,6 +24,7 @@
#include <QAbstractItemModel>
#include <QObject>
#include <KSharedConfig>
class OrgKdeKwinCompositingInterface;
......@@ -53,7 +54,7 @@ public:
Q_INVOKABLE bool OpenGLIsUnsafe() const;
Q_INVOKABLE bool OpenGLIsBroken();
Q_INVOKABLE void reenableOpenGLDetection();
int animationSpeed() const;
qreal animationSpeed() const;
int windowThumbnail() const;
int glScaleFilter() const;
bool xrScaleFilter() const;
......@@ -66,7 +67,7 @@ public:
OpenGLPlatformInterfaceModel *openGLPlatformInterfaceModel() const;
void setAnimationSpeed(int speed);
void setAnimationSpeed(qreal speed);
void setWindowThumbnail(int index);
void setGlScaleFilter(int index);
void setXrScaleFilter(bool filter);
......@@ -78,13 +79,15 @@ public:
void save();
static bool isRunningPlasma();
public Q_SLOTS:
void reset();
void defaults();
Q_SIGNALS:
void changed();
void animationSpeedChanged(int);
void animationSpeedChanged(qreal);
void windowThumbnailChanged(int);
void glScaleFilterChanged(int);
void xrScaleFilterChanged(int);
......@@ -95,7 +98,7 @@ Q_SIGNALS:
void windowsBlockCompositingChanged(bool);
private:
int m_animationSpeed;
qreal m_animationSpeed;
int m_windowThumbnail;
int m_glScaleFilter;
bool m_xrScaleFilter;
......@@ -108,6 +111,7 @@ private:
bool m_windowsBlockCompositing;
bool m_windowsBlockingCompositing;
OrgKdeKwinCompositingInterface *m_compositingInterface;
KSharedConfigPtr m_config;
};
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>462</width>
<height>349</height>
<width>526</width>
<height>395</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
......@@ -78,72 +78,21 @@ Alternatively, you might want to use the XRender backend instead.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<item row="3" column="0">
<widget class="QLabel" name="animationSpeedLabel">
<property name="text">
<string>Animation speed:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QSlider" name="animationSpeed">
<property name="maximum">
<number>6</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Instant</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Very slow</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="glScaleFilterLabel">
<property name="text">
<string>Scale method:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QComboBox" name="glScaleFilter">
<item>
<property name="text">
......@@ -162,14 +111,14 @@ Alternatively, you might want to use the XRender backend instead.</string>
</item>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="xrScaleFilterLabel">
<property name="text">
<string>Scale method:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QComboBox" name="xrScaleFilter">
<item>
<property name="text">
......@@ -183,38 +132,38 @@ Alternatively, you might want to use the XRender backend instead.</string>
</item>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Rendering backend:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QComboBox" name="type"/>
</item>
<item row="8" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Tearing prevention (&quot;vsync&quot;):</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QComboBox" name="tearingPrevention">
<item>
<property name="text">
......@@ -243,14 +192,14 @@ Alternatively, you might want to use the XRender backend instead.</string>
</item>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Keep window thumbnails:</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QComboBox" name="windowThumbnail">
<item>
<property name="text">
......@@ -269,7 +218,7 @@ Alternatively, you might want to use the XRender backend instead.</string>
</item>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QCheckBox" name="windowsBlockCompositing">
<property name="toolTip">
<string>Applications can set a hint to block compositing when the window is open.
......@@ -281,6 +230,68 @@ Alternatively, you might want to use the XRender backend instead.</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QWidget" name="animationSpeedControls" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSlider" name="animationSpeed">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="_3">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Very slow</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Instant</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
......@@ -29,6 +29,9 @@
#include <kcmodule.h>
#include <kservice.h>
#include <algorithm>
#include <functional>
class KWinCompositingSettings : public KCModule
{
Q_OBJECT
......@@ -46,6 +49,8 @@ private:
Ui_CompositingForm m_form;
};
static const QVector<qreal> s_animationMultipliers = {8, 4, 2, 1, 0.5, 0.25, 0.125, 0};
KWinCompositingSettings::KWinCompositingSettings(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
, m_compositing(new KWin::Compositing::Compositing(this))
......@@ -79,9 +84,22 @@ void KWinCompositingSettings::init()
connect(m_form.compositingEnabled, &QCheckBox::toggled, m_compositing, &Compositing::setCompositingEnabled);
// animation speed
m_form.animationSpeed->setValue(m_compositing->animationSpeed());
connect(m_compositing, &Compositing::animationSpeedChanged, m_form.animationSpeed, &QSlider::setValue);
connect(m_form.animationSpeed, &QSlider::valueChanged, m_compositing, &Compositing::setAnimationSpeed);
m_form.animationSpeed->setMaximum(s_animationMultipliers.size() - 1);
auto setSpeed = [this](const qreal multiplier) {
auto const it = std::lower_bound(s_animationMultipliers.begin(), s_animationMultipliers.end(), multiplier, std::greater<qreal>());
const int index = std::distance(s_animationMultipliers.begin(), it);
m_form.animationSpeed->setValue(index);
};
setSpeed(m_compositing->animationSpeed());
connect(m_compositing, &Compositing::animationSpeedChanged, m_form.animationSpeed, setSpeed);
connect(m_form.animationSpeed, &QSlider::valueChanged, m_compositing, [this](int index) {
m_compositing->setAnimationSpeed(s_animationMultipliers[index]);
});
if (Compositing::isRunningPlasma()) {
m_form.animationSpeedLabel->hide();
m_form.animationSpeedControls->hide();
}
// gl scale filter
m_form.glScaleFilter->setCurrentIndex(m_compositing->glScaleFilter());
......
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