[effects] Rewrite the Glide effect
Summary: There are several reasons why I "re-wrote" the Glide effect: * it doesn't work correctly because it suffers from undesired perspective distortions: {F5914378} The worst part is that windows are distorted so much on multiple monitor setups that it's hard to say whether that's glide animation. * window close animation is not quite intuitive: if the close button is located at the top and I click it, I would expect that window is rotated around the bottom edge, not the top; (IMHO) * it's too much distracting when working on something for quite good amount of time: e.g. when editing photos, which involves a big number of different dialogs; * there are issues with deletion of QTimeLine; * windows are not gracefully released if some other effect grabs them; * its code doesn't follow common coding style in KWin. So, the "new" Glide effect is more subtle, it's possible to have different rotation edges for window open/close animations, it doesn't animate special windows(like audio volume feedback), the code is simpler and readable. Yet, there are some issues with QTimeLine, which are common to all effects in KWin anyway. ### Demos {F5889803} //Window Open Animation// {F5889804} //Window Close Animation// {F5889805, layout=center, size=full} //KCM// CCBUG: 394245 Test Plan: * Enabled the Glide effect * Closed System Settings * Opened it again Reviewers: #kwin, #plasma, #vdg, davidedmundson Reviewed By: #kwin, #plasma, #vdg, davidedmundson Subscribers: ngraham, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D13338
This commit is contained in:
parent
df802d49a1
commit
6a7e780d74
6 changed files with 576 additions and 361 deletions
|
@ -5,6 +5,7 @@
|
|||
Copyright (C) 2007 Philip Falkner <philip.falkner@gmail.com>
|
||||
Copyright (C) 2009 Martin Gräßlin <mgraesslin@kde.org>
|
||||
Copyright (C) 2010 Alexandre Pereira <pereira.alex@gmail.com>
|
||||
Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,246 +21,293 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
|
||||
// own
|
||||
#include "glide.h"
|
||||
|
||||
// KConfigSkeleton
|
||||
#include "glideconfig.h"
|
||||
|
||||
// Qt
|
||||
#include <QMatrix4x4>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QTimeLine>
|
||||
|
||||
// Effect is based on fade effect by Philip Falkner
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
static const int IsGlideWindow = 0x22A982D4;
|
||||
|
||||
static const QSet<QString> s_blacklist {
|
||||
"ksmserver ksmserver",
|
||||
"ksplashx ksplashx",
|
||||
"ksplashsimple ksplashsimple",
|
||||
"ksplashqml ksplashqml"
|
||||
QStringLiteral("ksmserver ksmserver"),
|
||||
QStringLiteral("ksplashqml ksplashqml"),
|
||||
QStringLiteral("ksplashsimple ksplashsimple"),
|
||||
QStringLiteral("ksplashx ksplashx")
|
||||
};
|
||||
|
||||
GlideEffect::GlideEffect()
|
||||
: Effect()
|
||||
{
|
||||
initConfig<GlideConfig>();
|
||||
reconfigure(ReconfigureAll);
|
||||
connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), this, SLOT(slotWindowAdded(KWin::EffectWindow*)));
|
||||
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*)));
|
||||
connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*)));
|
||||
|
||||
|
||||
connect(effects, &EffectsHandler::windowDataChanged, this, &GlideEffect::cancelWindowGrab);
|
||||
connect(effects, &EffectsHandler::windowAdded, this, &GlideEffect::windowAdded);
|
||||
connect(effects, &EffectsHandler::windowClosed, this, &GlideEffect::windowClosed);
|
||||
connect(effects, &EffectsHandler::windowDeleted, this, &GlideEffect::windowDeleted);
|
||||
connect(effects, &EffectsHandler::windowDataChanged, this, &GlideEffect::windowDataChanged);
|
||||
}
|
||||
|
||||
GlideEffect::~GlideEffect() = default;
|
||||
|
||||
bool GlideEffect::supported()
|
||||
void GlideEffect::reconfigure(ReconfigureFlags flags)
|
||||
{
|
||||
return effects->isOpenGLCompositing() && effects->animationsSupported();
|
||||
}
|
||||
Q_UNUSED(flags)
|
||||
|
||||
void GlideEffect::reconfigure(ReconfigureFlags)
|
||||
{
|
||||
// Fetch config with KConfigXT
|
||||
GlideConfig::self()->read();
|
||||
duration = animationTime<GlideConfig>(350);
|
||||
effect = (EffectStyle) GlideConfig::glideEffect();
|
||||
angle = GlideConfig::glideAngle();
|
||||
m_duration = std::chrono::milliseconds(animationTime<GlideConfig>(160));
|
||||
|
||||
m_inParams.edge = static_cast<RotationEdge>(GlideConfig::inRotationEdge());
|
||||
m_inParams.angle.from = GlideConfig::inRotationAngle();
|
||||
m_inParams.angle.to = 0.0;
|
||||
m_inParams.distance.from = GlideConfig::inDistance();
|
||||
m_inParams.distance.to = 0.0;
|
||||
m_inParams.opacity.from = GlideConfig::inOpacity();
|
||||
m_inParams.opacity.to = 1.0;
|
||||
|
||||
m_outParams.edge = static_cast<RotationEdge>(GlideConfig::outRotationEdge());
|
||||
m_outParams.angle.from = 0.0;
|
||||
m_outParams.angle.to = GlideConfig::outRotationAngle();
|
||||
m_outParams.distance.from = 0.0;
|
||||
m_outParams.distance.to = GlideConfig::outDistance();
|
||||
m_outParams.opacity.from = 1.0;
|
||||
m_outParams.opacity.to = GlideConfig::outOpacity();
|
||||
}
|
||||
|
||||
void GlideEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
||||
void GlideEffect::prePaintScreen(ScreenPrePaintData &data, int time)
|
||||
{
|
||||
if (!windows.isEmpty())
|
||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||
const std::chrono::milliseconds delta(time);
|
||||
|
||||
auto animationIt = m_animations.begin();
|
||||
while (animationIt != m_animations.end()) {
|
||||
(*animationIt).update(delta);
|
||||
++animationIt;
|
||||
}
|
||||
|
||||
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
||||
|
||||
effects->prePaintScreen(data, time);
|
||||
}
|
||||
|
||||
void GlideEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
||||
void GlideEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time)
|
||||
{
|
||||
InfoHash::iterator info = windows.find(w);
|
||||
if (info != windows.end()) {
|
||||
if (m_animations.contains(w)) {
|
||||
data.setTransformed();
|
||||
if (info->added)
|
||||
info->timeLine->setCurrentTime(info->timeLine->currentTime() + time);
|
||||
else if (info->closed) {
|
||||
info->timeLine->setCurrentTime(info->timeLine->currentTime() - time);
|
||||
if (info->deleted)
|
||||
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
|
||||
}
|
||||
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
|
||||
}
|
||||
|
||||
effects->prePaintWindow(w, data, time);
|
||||
|
||||
// if the window isn't to be painted, then let's make sure
|
||||
// to track its progress
|
||||
if (info != windows.end() && !w->isPaintingEnabled() && !effects->activeFullScreenEffect())
|
||||
w->addRepaintFull();
|
||||
}
|
||||
|
||||
void GlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
||||
void GlideEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
|
||||
{
|
||||
InfoHash::const_iterator info = windows.constFind(w);
|
||||
if (info != windows.constEnd()) {
|
||||
const double progress = info->timeLine->currentValue();
|
||||
data.setRotationAxis(Qt::XAxis);
|
||||
data.setRotationAngle(angle * (1 - progress));
|
||||
data.multiplyOpacity(progress);
|
||||
switch(effect) {
|
||||
default:
|
||||
case GlideInOut:
|
||||
if (info->added)
|
||||
glideIn(w, data, info);
|
||||
else if (info->closed)
|
||||
glideOut(w, data, info);
|
||||
break;
|
||||
case GlideOutIn:
|
||||
if (info->added)
|
||||
glideOut(w, data, info);
|
||||
if (info->closed)
|
||||
glideIn(w, data, info);
|
||||
break;
|
||||
case GlideIn: glideIn(w, data, info); break;
|
||||
case GlideOut: glideOut(w, data, info); break;
|
||||
}
|
||||
auto animationIt = m_animations.constFind(w);
|
||||
if (animationIt == m_animations.constEnd()) {
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
return;
|
||||
}
|
||||
|
||||
// Perspective projection distorts objects near edges
|
||||
// of the viewport. This is critical because distortions
|
||||
// near edges of the viewport are not desired with this effect.
|
||||
// To fix this, the center of the window will be moved to the origin,
|
||||
// after applying perspective projection, the center is moved back
|
||||
// to its "original" projected position. Overall, this is how the window
|
||||
// will be transformed:
|
||||
// [move to the origin] -> [rotate] -> [translate] ->
|
||||
// -> [perspective projection] -> [reverse "move to the origin"]
|
||||
const QMatrix4x4 oldProjMatrix = data.screenProjectionMatrix();
|
||||
const QRectF windowGeo = w->geometry();
|
||||
const QVector3D invOffset = oldProjMatrix.map(QVector3D(windowGeo.center()));
|
||||
QMatrix4x4 invOffsetMatrix;
|
||||
invOffsetMatrix.translate(invOffset.x(), invOffset.y());
|
||||
data.setProjectionMatrix(invOffsetMatrix * oldProjMatrix);
|
||||
|
||||
// Move the center of the window to the origin.
|
||||
const QRectF screenGeo = effects->virtualScreenGeometry();
|
||||
const QPointF offset = screenGeo.center() - windowGeo.center();
|
||||
data.translate(offset.x(), offset.y());
|
||||
|
||||
const GlideParams params = w->isDeleted() ? m_outParams : m_inParams;
|
||||
const qreal t = (*animationIt).value();
|
||||
|
||||
switch (params.edge) {
|
||||
case RotationEdge::Top:
|
||||
data.setRotationAxis(Qt::XAxis);
|
||||
data.setRotationOrigin(QVector3D(0, 0, 0));
|
||||
data.setRotationAngle(-interpolate(params.angle.from, params.angle.to, t));
|
||||
break;
|
||||
|
||||
case RotationEdge::Right:
|
||||
data.setRotationAxis(Qt::YAxis);
|
||||
data.setRotationOrigin(QVector3D(w->width(), 0, 0));
|
||||
data.setRotationAngle(-interpolate(params.angle.from, params.angle.to, t));
|
||||
break;
|
||||
|
||||
case RotationEdge::Bottom:
|
||||
data.setRotationAxis(Qt::XAxis);
|
||||
data.setRotationOrigin(QVector3D(0, w->height(), 0));
|
||||
data.setRotationAngle(interpolate(params.angle.from, params.angle.to, t));
|
||||
break;
|
||||
|
||||
case RotationEdge::Left:
|
||||
data.setRotationAxis(Qt::YAxis);
|
||||
data.setRotationOrigin(QVector3D(0, 0, 0));
|
||||
data.setRotationAngle(interpolate(params.angle.from, params.angle.to, t));
|
||||
break;
|
||||
|
||||
default:
|
||||
// Fallback to Top.
|
||||
data.setRotationAxis(Qt::XAxis);
|
||||
data.setRotationOrigin(QVector3D(0, 0, 0));
|
||||
data.setRotationAngle(-interpolate(params.angle.from, params.angle.to, t));
|
||||
break;
|
||||
}
|
||||
|
||||
data.setZTranslation(-interpolate(params.distance.from, params.distance.to, t));
|
||||
data.multiplyOpacity(interpolate(params.opacity.from, params.opacity.to, t));
|
||||
|
||||
effects->paintWindow(w, mask, region, data);
|
||||
}
|
||||
|
||||
void GlideEffect::glideIn(EffectWindow* w, WindowPaintData& data, const InfoHash::const_iterator &info)
|
||||
void GlideEffect::postPaintScreen()
|
||||
{
|
||||
const double progress = info->timeLine->currentValue();
|
||||
data *= progress;
|
||||
data.translate(int(w->width() / 2 * (1 - progress)), int(w->height() / 2 * (1 - progress)));
|
||||
}
|
||||
|
||||
void GlideEffect::glideOut(EffectWindow* w, WindowPaintData& data, const InfoHash::const_iterator &info)
|
||||
{
|
||||
const double progress = info->timeLine->currentValue();
|
||||
data *= (2 - progress);
|
||||
data.translate(- int(w->width() / 2 * (1 - progress)), - int(w->height() / 2 * (1 - progress)));
|
||||
}
|
||||
|
||||
void GlideEffect::postPaintWindow(EffectWindow* w)
|
||||
{
|
||||
InfoHash::iterator info = windows.find(w);
|
||||
if (info != windows.end()) {
|
||||
if (info->added && info->timeLine->currentValue() == 1.0) {
|
||||
windows.remove(w);
|
||||
effects->addRepaintFull();
|
||||
} else if (info->closed && info->timeLine->currentValue() == 0.0) {
|
||||
info->closed = false;
|
||||
if (info->deleted) {
|
||||
windows.remove(w);
|
||||
auto animationIt = m_animations.begin();
|
||||
while (animationIt != m_animations.end()) {
|
||||
if ((*animationIt).done()) {
|
||||
EffectWindow *w = animationIt.key();
|
||||
if (w->isDeleted()) {
|
||||
w->unrefWindow();
|
||||
}
|
||||
effects->addRepaintFull();
|
||||
animationIt = m_animations.erase(animationIt);
|
||||
} else {
|
||||
++animationIt;
|
||||
}
|
||||
if (info->added || info->closed)
|
||||
w->addRepaintFull();
|
||||
}
|
||||
effects->postPaintWindow(w);
|
||||
}
|
||||
|
||||
void GlideEffect::slotWindowAdded(EffectWindow* w)
|
||||
{
|
||||
if (!isGlideWindow(w))
|
||||
return;
|
||||
w->setData(IsGlideWindow, true);
|
||||
const void *addGrab = w->data(WindowAddedGrabRole).value<void*>();
|
||||
if (addGrab && addGrab != this)
|
||||
return;
|
||||
w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
||||
|
||||
InfoHash::iterator it = windows.find(w);
|
||||
WindowInfo *info = (it == windows.end()) ? &windows[w] : &it.value();
|
||||
info->added = true;
|
||||
info->closed = false;
|
||||
info->deleted = false;
|
||||
delete info->timeLine;
|
||||
info->timeLine = new QTimeLine(duration);
|
||||
info->timeLine->setCurveShape(QTimeLine::EaseOutCurve);
|
||||
w->addRepaintFull();
|
||||
}
|
||||
|
||||
void GlideEffect::slotWindowClosed(EffectWindow* w)
|
||||
{
|
||||
if (!isGlideWindow(w))
|
||||
return;
|
||||
const void *closeGrab = w->data(WindowClosedGrabRole).value<void*>();
|
||||
if (closeGrab && closeGrab != this)
|
||||
return;
|
||||
w->refWindow();
|
||||
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
||||
|
||||
InfoHash::iterator it = windows.find(w);
|
||||
WindowInfo *info = (it == windows.end()) ? &windows[w] : &it.value();
|
||||
info->added = false;
|
||||
info->closed = true;
|
||||
info->deleted = true;
|
||||
delete info->timeLine;
|
||||
info->timeLine = new QTimeLine(duration);
|
||||
info->timeLine->setCurveShape(QTimeLine::EaseInCurve);
|
||||
info->timeLine->setCurrentTime(info->timeLine->duration());
|
||||
w->addRepaintFull();
|
||||
}
|
||||
|
||||
void GlideEffect::slotWindowDeleted(EffectWindow* w)
|
||||
{
|
||||
windows.remove(w);
|
||||
}
|
||||
|
||||
bool GlideEffect::isGlideWindow(EffectWindow* w)
|
||||
{
|
||||
if (effects->activeFullScreenEffect())
|
||||
return false;
|
||||
if (!w->isVisible())
|
||||
return false;
|
||||
if (s_blacklist.contains(w->windowClass()))
|
||||
return false;
|
||||
if (w->data(IsGlideWindow).toBool())
|
||||
return true;
|
||||
if (w->hasDecoration())
|
||||
return true;
|
||||
if (!w->isManaged() || w->isMenu() || w->isNotification() || w->isDesktop() ||
|
||||
w->isDock() || w->isSplash() || w->isToolbar())
|
||||
return false;
|
||||
return true;
|
||||
effects->addRepaintFull();
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
|
||||
bool GlideEffect::isActive() const
|
||||
{
|
||||
return !windows.isEmpty();
|
||||
return !m_animations.isEmpty();
|
||||
}
|
||||
|
||||
void GlideEffect::cancelWindowGrab(EffectWindow *w, int grabRole)
|
||||
bool GlideEffect::supported()
|
||||
{
|
||||
if (grabRole != WindowAddedGrabRole && grabRole != WindowClosedGrabRole) {
|
||||
return effects->isOpenGLCompositing()
|
||||
&& effects->animationsSupported();
|
||||
}
|
||||
|
||||
void GlideEffect::windowAdded(EffectWindow *w)
|
||||
{
|
||||
if (effects->activeFullScreenEffect()) {
|
||||
return;
|
||||
}
|
||||
if (!w->data(IsGlideWindow).toBool()) {
|
||||
|
||||
if (!isGlideWindow(w)) {
|
||||
return;
|
||||
}
|
||||
if (w->data(grabRole).value<void*>() != this) {
|
||||
windows.remove(w);
|
||||
w->setData(IsGlideWindow, false);
|
||||
|
||||
if (!w->isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const void *addGrab = w->data(WindowAddedGrabRole).value<void*>();
|
||||
if (addGrab && addGrab != this) {
|
||||
return;
|
||||
}
|
||||
|
||||
w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
||||
|
||||
TimeLine &timeLine = m_animations[w];
|
||||
timeLine.reset();
|
||||
timeLine.setDirection(TimeLine::Forward);
|
||||
timeLine.setDuration(m_duration);
|
||||
timeLine.setEasingCurve(QEasingCurve::InCurve);
|
||||
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
GlideEffect::WindowInfo::WindowInfo()
|
||||
: deleted(false)
|
||||
, added(false)
|
||||
, closed(false)
|
||||
, timeLine(0)
|
||||
void GlideEffect::windowClosed(EffectWindow *w)
|
||||
{
|
||||
if (effects->activeFullScreenEffect()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isGlideWindow(w)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!w->isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const void *closeGrab = w->data(WindowClosedGrabRole).value<void*>();
|
||||
if (closeGrab && closeGrab != this) {
|
||||
return;
|
||||
}
|
||||
|
||||
w->refWindow();
|
||||
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
||||
|
||||
TimeLine &timeLine = m_animations[w];
|
||||
timeLine.reset();
|
||||
timeLine.setDirection(TimeLine::Forward);
|
||||
timeLine.setDuration(m_duration);
|
||||
timeLine.setEasingCurve(QEasingCurve::OutCurve);
|
||||
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
GlideEffect::WindowInfo::~WindowInfo()
|
||||
void GlideEffect::windowDeleted(EffectWindow *w)
|
||||
{
|
||||
delete timeLine;
|
||||
m_animations.remove(w);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
void GlideEffect::windowDataChanged(EffectWindow *w, int role)
|
||||
{
|
||||
if (role != WindowAddedGrabRole && role != WindowClosedGrabRole) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (w->data(role).value<void*>() == this) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto animationIt = m_animations.find(w);
|
||||
if (animationIt == m_animations.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (w->isDeleted() && role == WindowClosedGrabRole) {
|
||||
w->unrefWindow();
|
||||
}
|
||||
|
||||
m_animations.erase(animationIt);
|
||||
}
|
||||
|
||||
bool GlideEffect::isGlideWindow(EffectWindow *w) const
|
||||
{
|
||||
if (s_blacklist.contains(w->windowClass())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (w->hasDecoration()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!w->isManaged()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return w->isNormalWindow()
|
||||
|| w->isDialog();
|
||||
}
|
||||
|
||||
} // namespace KWin
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
Copyright (C) 2007 Philip Falkner <philip.falkner@gmail.com>
|
||||
Copyright (C) 2009 Martin Gräßlin <mgraesslin@kde.org>
|
||||
Copyright (C) 2010 Alexandre Pereira <pereira.alex@gmail.com>
|
||||
Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -23,81 +24,133 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#ifndef KWIN_GLIDE_H
|
||||
#define KWIN_GLIDE_H
|
||||
|
||||
// kwineffects
|
||||
#include <kwineffects.h>
|
||||
|
||||
class QTimeLine;
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class GlideEffect
|
||||
: public Effect
|
||||
class GlideEffect : public Effect
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int duration READ configuredDuration)
|
||||
Q_PROPERTY(int effect READ configuredEffect)
|
||||
Q_PROPERTY(int angle READ configuredAngle)
|
||||
Q_PROPERTY(int duration READ duration)
|
||||
Q_PROPERTY(RotationEdge inRotationEdge READ inRotationEdge)
|
||||
Q_PROPERTY(qreal inRotationAngle READ inRotationAngle)
|
||||
Q_PROPERTY(qreal inDistance READ inDistance)
|
||||
Q_PROPERTY(qreal inOpacity READ inOpacity)
|
||||
Q_PROPERTY(RotationEdge outRotationEdge READ outRotationEdge)
|
||||
Q_PROPERTY(qreal outRotationAngle READ outRotationAngle)
|
||||
Q_PROPERTY(qreal outDistance READ outDistance)
|
||||
Q_PROPERTY(qreal outOpacity READ outOpacity)
|
||||
|
||||
public:
|
||||
GlideEffect();
|
||||
~GlideEffect();
|
||||
virtual void reconfigure(ReconfigureFlags);
|
||||
virtual void prePaintScreen(ScreenPrePaintData& data, int time);
|
||||
virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
|
||||
virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
|
||||
virtual void postPaintWindow(EffectWindow* w);
|
||||
virtual bool isActive() const;
|
||||
~GlideEffect() override;
|
||||
|
||||
int requestedEffectChainPosition() const override {
|
||||
return 50;
|
||||
}
|
||||
void reconfigure(ReconfigureFlags flags) override;
|
||||
|
||||
void prePaintScreen(ScreenPrePaintData &data, int time) override;
|
||||
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override;
|
||||
void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
|
||||
void postPaintScreen() override;
|
||||
|
||||
bool isActive() const override;
|
||||
int requestedEffectChainPosition() const override;
|
||||
|
||||
static bool supported();
|
||||
|
||||
// for properties
|
||||
int configuredDuration() const {
|
||||
return duration;
|
||||
}
|
||||
int configuredEffect() const {
|
||||
return effect;
|
||||
}
|
||||
int configuredAngle() const {
|
||||
return angle;
|
||||
}
|
||||
public Q_SLOTS:
|
||||
void slotWindowAdded(KWin::EffectWindow* c);
|
||||
void slotWindowClosed(KWin::EffectWindow *c);
|
||||
void slotWindowDeleted(KWin::EffectWindow *w);
|
||||
enum RotationEdge {
|
||||
Top = 0,
|
||||
Right = 1,
|
||||
Bottom = 2,
|
||||
Left = 3
|
||||
};
|
||||
Q_ENUM(RotationEdge)
|
||||
|
||||
int duration() const;
|
||||
RotationEdge inRotationEdge() const;
|
||||
qreal inRotationAngle() const;
|
||||
qreal inDistance() const;
|
||||
qreal inOpacity() const;
|
||||
RotationEdge outRotationEdge() const;
|
||||
qreal outRotationAngle() const;
|
||||
qreal outDistance() const;
|
||||
qreal outOpacity() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void windowAdded(EffectWindow *w);
|
||||
void windowClosed(EffectWindow *w);
|
||||
void windowDeleted(EffectWindow *w);
|
||||
void windowDataChanged(EffectWindow *w, int role);
|
||||
|
||||
private:
|
||||
class WindowInfo;
|
||||
typedef QMap< const EffectWindow*, WindowInfo > InfoHash;
|
||||
void glideIn(EffectWindow* w, WindowPaintData& data, const InfoHash::const_iterator &info);
|
||||
void glideOut(EffectWindow* w, WindowPaintData& data, const InfoHash::const_iterator &info);
|
||||
bool isGlideWindow(EffectWindow* w);
|
||||
void cancelWindowGrab(EffectWindow *w, int grabRole);
|
||||
InfoHash windows;
|
||||
float duration;
|
||||
int angle;
|
||||
enum EffectStyle {
|
||||
GlideIn = 0,
|
||||
GlideInOut = 1,
|
||||
GlideOutIn = 2,
|
||||
GlideOut = 3
|
||||
bool isGlideWindow(EffectWindow *w) const;
|
||||
|
||||
std::chrono::milliseconds m_duration;
|
||||
QHash<EffectWindow*, TimeLine> m_animations;
|
||||
|
||||
struct GlideParams {
|
||||
RotationEdge edge;
|
||||
struct {
|
||||
qreal from;
|
||||
qreal to;
|
||||
} angle, distance, opacity;
|
||||
};
|
||||
EffectStyle effect;
|
||||
|
||||
GlideParams m_inParams;
|
||||
GlideParams m_outParams;
|
||||
};
|
||||
|
||||
class GlideEffect::WindowInfo
|
||||
inline int GlideEffect::requestedEffectChainPosition() const
|
||||
{
|
||||
public:
|
||||
WindowInfo();
|
||||
~WindowInfo();
|
||||
bool deleted;
|
||||
bool added;
|
||||
bool closed;
|
||||
QTimeLine *timeLine;
|
||||
};
|
||||
return 50;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
inline int GlideEffect::duration() const
|
||||
{
|
||||
return m_duration.count();
|
||||
}
|
||||
|
||||
inline GlideEffect::RotationEdge GlideEffect::inRotationEdge() const
|
||||
{
|
||||
return m_inParams.edge;
|
||||
}
|
||||
|
||||
inline qreal GlideEffect::inRotationAngle() const
|
||||
{
|
||||
return m_inParams.angle.from;
|
||||
}
|
||||
|
||||
inline qreal GlideEffect::inDistance() const
|
||||
{
|
||||
return m_inParams.distance.from;
|
||||
}
|
||||
|
||||
inline qreal GlideEffect::inOpacity() const
|
||||
{
|
||||
return m_inParams.opacity.from;
|
||||
}
|
||||
|
||||
inline GlideEffect::RotationEdge GlideEffect::outRotationEdge() const
|
||||
{
|
||||
return m_outParams.edge;
|
||||
}
|
||||
|
||||
inline qreal GlideEffect::outRotationAngle() const
|
||||
{
|
||||
return m_outParams.angle.to;
|
||||
}
|
||||
|
||||
inline qreal GlideEffect::outDistance() const
|
||||
{
|
||||
return m_outParams.distance.to;
|
||||
}
|
||||
|
||||
inline qreal GlideEffect::outOpacity() const
|
||||
{
|
||||
return m_outParams.opacity.to;
|
||||
}
|
||||
|
||||
} // namespace KWin
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,11 +8,33 @@
|
|||
<entry name="Duration" type="UInt">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="GlideEffect" type="Int">
|
||||
<entry name="InRotationEdge" type="Int">
|
||||
<default>0</default>
|
||||
</entry>
|
||||
<entry name="GlideAngle" type="Int">
|
||||
<default>-90</default>
|
||||
<entry name="InRotationAngle" type="Double">
|
||||
<default>3.0</default>
|
||||
</entry>
|
||||
<entry name="InDistance" type="Double">
|
||||
<default>30.0</default>
|
||||
</entry>
|
||||
<entry name="InOpacity" type="Double">
|
||||
<default>0.4</default>
|
||||
<min>0.0</min>
|
||||
<max>1.0</max>
|
||||
</entry>
|
||||
<entry name="OutRotationEdge" type="Int">
|
||||
<default>2</default>
|
||||
</entry>
|
||||
<entry name="OutRotationAngle" type="Double">
|
||||
<default>3.0</default>
|
||||
</entry>
|
||||
<entry name="OutDistance" type="Double">
|
||||
<default>30.0</default>
|
||||
</entry>
|
||||
<entry name="OutOpacity" type="Double">
|
||||
<default>0.0</default>
|
||||
<min>0.0</min>
|
||||
<max>1.0</max>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
||||
|
|
|
@ -55,5 +55,7 @@ void GlideEffectConfig::save()
|
|||
QDBusConnection::sessionBus());
|
||||
interface.reconfigureEffect(QStringLiteral("glide"));
|
||||
}
|
||||
|
||||
} // namespace KWin
|
||||
|
||||
#include "glide_config.moc"
|
||||
|
|
|
@ -32,10 +32,10 @@ class GlideEffectConfig : public KCModule
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GlideEffectConfig(QWidget *parent = 0, const QVariantList& args = QVariantList());
|
||||
~GlideEffectConfig();
|
||||
explicit GlideEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList());
|
||||
~GlideEffectConfig() override;
|
||||
|
||||
void save();
|
||||
void save() override;
|
||||
|
||||
private:
|
||||
::Ui::GlideEffectConfig ui;
|
||||
|
|
|
@ -6,159 +6,249 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>306</width>
|
||||
<height>130</height>
|
||||
<width>440</width>
|
||||
<height>375</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="glideEffectLabel">
|
||||
<property name="text">
|
||||
<string>Glide Effect:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutGlideEffect">
|
||||
<item>
|
||||
<spacer name="horizontalSpacerGlideEffect">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="inGlideEffectLabel">
|
||||
<layout class="QFormLayout" name="layout_Duration">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_Duration">
|
||||
<property name="text">
|
||||
<string>In</string>
|
||||
<string>Duration:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="kcfg_GlideEffect">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="kcfg_Duration">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="specialValueText">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> milliseconds</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>3</number>
|
||||
<number>9999</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="outGlideEffectLabel">
|
||||
<property name="text">
|
||||
<string>Out</string>
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacerUnderGlideEffect">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="glideAngleLabel">
|
||||
<property name="text">
|
||||
<string>Glide Angle:</string>
|
||||
<widget class="QGroupBox" name="groupBox_InAnimation">
|
||||
<property name="title">
|
||||
<string>Window Open Animation</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_InRotationEdge">
|
||||
<property name="text">
|
||||
<string>Rotation edge:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="kcfg_InRotationEdge">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_InRotationAngle">
|
||||
<property name="text">
|
||||
<string>Rotation angle:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="kcfg_InRotationAngle">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-360</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>360</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_InDistance">
|
||||
<property name="text">
|
||||
<string>Distance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="kcfg_InDistance">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-5000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutGlideAngle">
|
||||
<item>
|
||||
<spacer name="horizontalSpacerGlideAngle">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="glideAnglenegLabel">
|
||||
<property name="text">
|
||||
<string>-90</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="kcfg_GlideAngle">
|
||||
<property name="minimum">
|
||||
<number>-90</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>90</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>45</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition">
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="glideAngleposLabel">
|
||||
<property name="text">
|
||||
<string>90</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QGroupBox" name="groupBox_OutAnimation">
|
||||
<property name="title">
|
||||
<string>Window Close Animation</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_OutRotationEdge">
|
||||
<property name="text">
|
||||
<string>Rotation edge:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="kcfg_OutRotationEdge">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Bottom</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Left</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_OutRotationAngle">
|
||||
<property name="text">
|
||||
<string>Rotation angle:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_OutDistance">
|
||||
<property name="text">
|
||||
<string>Distance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="kcfg_OutRotationAngle">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-360</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>360</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="kcfg_OutDistance">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>-5000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>5000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacerUnderGlideAngle">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
|
Loading…
Reference in a new issue