2009-07-23 19:06:50 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2009 Marco Martin notmart@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
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#include "slidingpopups.h"
|
2016-11-16 08:02:44 +00:00
|
|
|
#include "slidingpopupsconfig.h"
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2014-02-10 16:59:16 +00:00
|
|
|
#include <QApplication>
|
2017-11-08 10:23:00 +00:00
|
|
|
#include <QFontMetrics>
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2015-09-14 14:39:39 +00:00
|
|
|
#include <KWayland/Server/surface_interface.h>
|
|
|
|
#include <KWayland/Server/slide_interface.h>
|
|
|
|
#include <KWayland/Server/display.h>
|
|
|
|
|
2009-07-23 19:06:50 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
SlidingPopupsEffect::SlidingPopupsEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2016-12-02 19:27:43 +00:00
|
|
|
initConfig<SlidingPopupsConfig>();
|
2015-09-14 14:39:39 +00:00
|
|
|
KWayland::Server::Display *display = effects->waylandDisplay();
|
|
|
|
if (display) {
|
|
|
|
display->createSlideManager(this)->create();
|
|
|
|
}
|
|
|
|
|
2014-02-10 16:59:16 +00:00
|
|
|
mSlideLength = QFontMetrics(qApp->font()).height() * 8;
|
|
|
|
|
2012-12-13 23:09:47 +00:00
|
|
|
mAtom = effects->announceSupportProperty("_KDE_SLIDE", this);
|
2012-01-29 11:29:24 +00:00
|
|
|
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, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), this, SLOT(slotPropertyNotify(KWin::EffectWindow*,long)));
|
2016-07-04 13:40:38 +00:00
|
|
|
connect(effects, &EffectsHandler::windowShown, this, &SlidingPopupsEffect::startForShow);
|
|
|
|
connect(effects, &EffectsHandler::windowHidden, this, &SlidingPopupsEffect::slotWindowClosed);
|
2017-09-10 14:51:18 +00:00
|
|
|
connect(effects, &EffectsHandler::xcbConnectionChanged, this,
|
|
|
|
[this] {
|
|
|
|
mAtom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_SLIDE"), this);
|
|
|
|
}
|
|
|
|
);
|
2011-03-19 10:46:34 +00:00
|
|
|
reconfigure(ReconfigureAll);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
|
|
|
|
SlidingPopupsEffect::~SlidingPopupsEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2017-11-23 09:34:06 +00:00
|
|
|
bool SlidingPopupsEffect::supported()
|
|
|
|
{
|
|
|
|
return effects->animationsSupported();
|
|
|
|
}
|
|
|
|
|
2011-03-19 10:46:34 +00:00
|
|
|
void SlidingPopupsEffect::reconfigure(ReconfigureFlags flags)
|
|
|
|
{
|
|
|
|
Q_UNUSED(flags)
|
2016-11-16 08:02:44 +00:00
|
|
|
SlidingPopupsConfig::self()->read();
|
2018-06-29 20:26:48 +00:00
|
|
|
mFadeInTime = std::chrono::milliseconds(
|
|
|
|
static_cast<int>(animationTime(SlidingPopupsConfig::slideInTime() != 0 ? SlidingPopupsConfig::slideInTime() : 150)));
|
|
|
|
mFadeOutTime = std::chrono::milliseconds(
|
|
|
|
static_cast<int>(animationTime(SlidingPopupsConfig::slideOutTime() != 0 ? SlidingPopupsConfig::slideOutTime() : 250)));
|
|
|
|
QHash< const EffectWindow*, TimeLine >::iterator it = mAppearingWindows.begin();
|
2011-03-19 10:46:34 +00:00
|
|
|
while (it != mAppearingWindows.end()) {
|
2018-06-29 20:26:48 +00:00
|
|
|
(*it).setDuration(mFadeInTime);
|
2011-08-02 15:21:56 +00:00
|
|
|
++it;
|
2011-03-19 10:46:34 +00:00
|
|
|
}
|
|
|
|
it = mDisappearingWindows.begin();
|
|
|
|
while (it != mDisappearingWindows.end()) {
|
2018-06-29 20:26:48 +00:00
|
|
|
(*it).setDuration(mFadeOutTime);
|
2011-08-02 15:21:56 +00:00
|
|
|
++it;
|
2011-03-19 10:46:34 +00:00
|
|
|
}
|
|
|
|
QHash< const EffectWindow*, Data >::iterator wIt = mWindowsData.begin();
|
|
|
|
while (wIt != mWindowsData.end()) {
|
|
|
|
wIt.value().fadeInDuration = mFadeInTime;
|
|
|
|
wIt.value().fadeOutDuration = mFadeOutTime;
|
2011-08-02 15:21:56 +00:00
|
|
|
++wIt;
|
2011-03-19 10:46:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void SlidingPopupsEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
effects->prePaintScreen(data, time);
|
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
|
|
|
{
|
2018-06-29 20:26:48 +00:00
|
|
|
const std::chrono::milliseconds delta(time);
|
|
|
|
|
2011-12-10 11:31:06 +00:00
|
|
|
qreal progress = 1.0;
|
|
|
|
bool appearing = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (mAppearingWindows.contains(w)) {
|
2018-06-29 20:26:48 +00:00
|
|
|
mAppearingWindows[ w ].update(delta);
|
|
|
|
if (!mAppearingWindows[ w ].done()) {
|
2009-07-23 19:06:50 +00:00
|
|
|
data.setTransformed();
|
2018-06-29 20:26:48 +00:00
|
|
|
progress = mAppearingWindows[ w ].value();
|
2011-12-10 11:31:06 +00:00
|
|
|
appearing = true;
|
2011-12-10 21:32:47 +00:00
|
|
|
} else {
|
2018-06-29 20:26:48 +00:00
|
|
|
mAppearingWindows.remove(w);
|
2011-12-10 21:32:47 +00:00
|
|
|
w->setData(WindowForceBlurRole, false);
|
2014-02-20 13:10:18 +00:00
|
|
|
if (m_backgroundContrastForced.contains(w) && w->hasAlpha() &&
|
|
|
|
w->data(WindowForceBackgroundContrastRole).toBool()) {
|
|
|
|
w->setData(WindowForceBackgroundContrastRole, QVariant());
|
|
|
|
m_backgroundContrastForced.removeAll(w);
|
|
|
|
}
|
2011-12-10 21:32:47 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else if (mDisappearingWindows.contains(w)) {
|
2009-07-27 13:27:16 +00:00
|
|
|
|
2018-06-29 20:26:48 +00:00
|
|
|
mDisappearingWindows[ w ].update(delta);
|
|
|
|
progress = mDisappearingWindows[ w ].value();
|
2011-12-10 11:31:06 +00:00
|
|
|
|
2018-06-29 20:26:48 +00:00
|
|
|
if (!mDisappearingWindows[ w ].done()) {
|
2011-12-10 11:31:06 +00:00
|
|
|
data.setTransformed();
|
2016-07-04 13:40:38 +00:00
|
|
|
w->enablePainting(EffectWindow::PAINT_DISABLED | EffectWindow::PAINT_DISABLED_BY_DELETE);
|
2011-12-10 11:31:06 +00:00
|
|
|
} else {
|
2018-06-29 20:26:48 +00:00
|
|
|
mDisappearingWindows.remove(w);
|
2013-01-08 08:19:13 +00:00
|
|
|
w->addRepaintFull();
|
2016-07-04 13:40:38 +00:00
|
|
|
if (w->isDeleted()) {
|
|
|
|
w->unrefWindow();
|
|
|
|
}
|
2011-12-10 11:31:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (progress != 1.0) {
|
|
|
|
const int start = mWindowsData[ w ].start;
|
|
|
|
if (start != 0) {
|
|
|
|
const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
|
2013-01-08 08:19:13 +00:00
|
|
|
const QRect geo = w->expandedGeometry();
|
2011-12-10 11:31:06 +00:00
|
|
|
// filter out window quads, but only if the window does not start from the edge
|
2014-02-13 18:45:42 +00:00
|
|
|
int slideLength;
|
|
|
|
if (mWindowsData[ w ].slideLength > 0) {
|
|
|
|
slideLength = mWindowsData[ w ].slideLength;
|
|
|
|
} else {
|
|
|
|
slideLength = mSlideLength;
|
|
|
|
}
|
|
|
|
|
2011-12-10 11:31:06 +00:00
|
|
|
switch(mWindowsData[ w ].from) {
|
|
|
|
case West: {
|
2014-02-13 18:45:42 +00:00
|
|
|
const double splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start) + qMin(geo.width(), slideLength) * (appearing ? 1.0 - progress : progress);
|
2011-12-10 11:31:06 +00:00
|
|
|
data.quads = data.quads.splitAtX(splitPoint);
|
|
|
|
WindowQuadList filtered;
|
|
|
|
foreach (const WindowQuad &quad, data.quads) {
|
|
|
|
if (quad.left() >= splitPoint) {
|
|
|
|
filtered << quad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data.quads = filtered;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case North: {
|
2014-02-13 18:45:42 +00:00
|
|
|
const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + qMin(geo.height(), slideLength) * (appearing ? 1.0 - progress : progress);
|
2011-12-10 11:31:06 +00:00
|
|
|
data.quads = data.quads.splitAtY(splitPoint);
|
|
|
|
WindowQuadList filtered;
|
|
|
|
foreach (const WindowQuad &quad, data.quads) {
|
|
|
|
if (quad.top() >= splitPoint) {
|
|
|
|
filtered << quad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data.quads = filtered;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case East: {
|
2014-02-13 18:45:42 +00:00
|
|
|
const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - qMin(geo.width(), slideLength) * (appearing ? 1.0 - progress : progress);
|
2011-12-10 11:31:06 +00:00
|
|
|
data.quads = data.quads.splitAtX(splitPoint);
|
|
|
|
WindowQuadList filtered;
|
|
|
|
foreach (const WindowQuad &quad, data.quads) {
|
|
|
|
if (quad.right() <= splitPoint) {
|
|
|
|
filtered << quad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data.quads = filtered;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case South:
|
|
|
|
default: {
|
2014-02-13 18:45:42 +00:00
|
|
|
const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - qMin(geo.height(), slideLength) * (appearing ? 1.0 - progress : progress);
|
2011-12-10 11:31:06 +00:00
|
|
|
data.quads = data.quads.splitAtY(splitPoint);
|
|
|
|
WindowQuadList filtered;
|
|
|
|
foreach (const WindowQuad &quad, data.quads) {
|
|
|
|
if (quad.bottom() <= splitPoint) {
|
|
|
|
filtered << quad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data.quads = filtered;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->prePaintWindow(w, data, time);
|
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
|
|
|
{
|
2009-07-23 19:06:50 +00:00
|
|
|
bool animating = false;
|
|
|
|
bool appearing = false;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (mAppearingWindows.contains(w)) {
|
2009-07-23 19:06:50 +00:00
|
|
|
appearing = true;
|
|
|
|
animating = true;
|
2016-07-04 13:40:38 +00:00
|
|
|
} else if (mDisappearingWindows.contains(w)) {
|
2009-07-23 19:06:50 +00:00
|
|
|
appearing = false;
|
|
|
|
animating = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (animating) {
|
2009-10-19 05:04:35 +00:00
|
|
|
qreal progress;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (appearing)
|
2018-06-29 20:26:48 +00:00
|
|
|
progress = 1.0 - mAppearingWindows[ w ].value();
|
2011-01-30 14:34:42 +00:00
|
|
|
else {
|
|
|
|
if (mDisappearingWindows.contains(w))
|
2018-06-29 20:26:48 +00:00
|
|
|
progress = mDisappearingWindows[ w ].value();
|
2009-10-19 05:04:35 +00:00
|
|
|
else
|
|
|
|
progress = 1.0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
const int start = mWindowsData[ w ].start;
|
|
|
|
|
2014-02-13 18:45:42 +00:00
|
|
|
int slideLength;
|
|
|
|
if (mWindowsData[ w ].slideLength > 0) {
|
|
|
|
slideLength = mWindowsData[ w ].slideLength;
|
|
|
|
} else {
|
|
|
|
slideLength = mSlideLength;
|
|
|
|
}
|
2014-02-07 14:18:45 +00:00
|
|
|
|
2011-12-10 11:31:06 +00:00
|
|
|
const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), w->desktop());
|
2011-12-10 21:32:47 +00:00
|
|
|
int splitPoint = 0;
|
2013-01-08 08:19:13 +00:00
|
|
|
const QRect geo = w->expandedGeometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
switch(mWindowsData[ w ].from) {
|
|
|
|
case West:
|
2014-02-13 18:45:42 +00:00
|
|
|
if (slideLength < geo.width()) {
|
2014-02-14 09:36:51 +00:00
|
|
|
data.multiplyOpacity(1 - progress);
|
2014-02-13 18:45:42 +00:00
|
|
|
}
|
|
|
|
data.translate(- qMin(geo.width(), slideLength) * progress);
|
2013-01-08 08:19:13 +00:00
|
|
|
splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start);
|
|
|
|
region = QRegion(geo.x() + splitPoint, geo.y(), geo.width() - splitPoint, geo.height());
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
|
|
|
case North:
|
2014-02-13 18:45:42 +00:00
|
|
|
if (slideLength < geo.height()) {
|
2014-02-14 09:36:51 +00:00
|
|
|
data.multiplyOpacity(1 - progress);
|
2014-02-13 18:45:42 +00:00
|
|
|
}
|
|
|
|
data.translate(0.0, - qMin(geo.height(), slideLength) * progress);
|
2013-01-08 08:19:13 +00:00
|
|
|
splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start);
|
|
|
|
region = QRegion(geo.x(), geo.y() + splitPoint, geo.width(), geo.height() - splitPoint);
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
|
|
|
case East:
|
2014-02-13 18:45:42 +00:00
|
|
|
if (slideLength < geo.width()) {
|
2014-02-14 09:36:51 +00:00
|
|
|
data.multiplyOpacity(1 - progress);
|
2014-02-13 18:45:42 +00:00
|
|
|
}
|
|
|
|
data.translate(qMin(geo.width(), slideLength) * progress);
|
2013-01-08 08:19:13 +00:00
|
|
|
splitPoint = screenRect.x() + screenRect.width() - geo.x() - start;
|
|
|
|
region = QRegion(geo.x(), geo.y(), splitPoint, geo.height());
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
|
|
|
case South:
|
|
|
|
default:
|
2014-02-18 10:48:18 +00:00
|
|
|
if (slideLength < geo.height()) {
|
2014-02-14 09:36:51 +00:00
|
|
|
data.multiplyOpacity(1 - progress);
|
2014-02-13 18:45:42 +00:00
|
|
|
}
|
|
|
|
data.translate(0.0, qMin(geo.height(), slideLength) * progress);
|
2013-01-08 08:19:13 +00:00
|
|
|
splitPoint = screenRect.y() + screenRect.height() - geo.y() - start;
|
|
|
|
region = QRegion(geo.x(), geo.y(), geo.width(), splitPoint);
|
2009-07-23 19:06:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-10 11:31:06 +00:00
|
|
|
effects->paintWindow(w, mask, region, data);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SlidingPopupsEffect::postPaintWindow(EffectWindow* w)
|
|
|
|
{
|
2011-03-18 17:06:03 +00:00
|
|
|
if (mAppearingWindows.contains(w) || mDisappearingWindows.contains(w)) {
|
2009-07-23 19:06:50 +00:00
|
|
|
w->addRepaintFull(); // trigger next animation repaint
|
2011-03-18 17:06:03 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->postPaintWindow(w);
|
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2011-02-25 21:06:02 +00:00
|
|
|
void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-09-14 14:39:39 +00:00
|
|
|
//X11
|
2017-09-10 14:51:18 +00:00
|
|
|
if (mAtom != XCB_ATOM_NONE) {
|
|
|
|
slotPropertyNotify(w, mAtom);
|
|
|
|
}
|
2015-09-14 14:39:39 +00:00
|
|
|
|
|
|
|
//Wayland
|
|
|
|
if (auto surf = w->surface()) {
|
|
|
|
slotWaylandSlideOnShowChanged(w);
|
|
|
|
connect(surf, &KWayland::Server::SurfaceInterface::slideOnShowHideChanged, this, [this, surf] {
|
|
|
|
slotWaylandSlideOnShowChanged(effects->findWindow(surf));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-07-04 13:40:38 +00:00
|
|
|
startForShow(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SlidingPopupsEffect::startForShow(EffectWindow *w)
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
if (w->isOnCurrentDesktop() && mWindowsData.contains(w)) {
|
2018-06-11 09:41:23 +00:00
|
|
|
if (!w->data(WindowForceBackgroundContrastRole).toBool() && w->hasAlpha()) {
|
2014-02-20 13:10:18 +00:00
|
|
|
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
|
|
|
|
m_backgroundContrastForced.append(w);
|
|
|
|
}
|
2018-06-29 20:26:48 +00:00
|
|
|
|
|
|
|
mDisappearingWindows.remove(w);
|
|
|
|
|
|
|
|
TimeLine &timeLine = mAppearingWindows[ w ];
|
|
|
|
timeLine.reset();
|
|
|
|
timeLine.setDirection(TimeLine::Forward);
|
|
|
|
timeLine.setDuration(mWindowsData[ w ].fadeInDuration);
|
|
|
|
timeLine.setEasingCurve(QEasingCurve::InOutSine);
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
slidingpopups claim windowClosedGrabRole earlier
This seems like a more proper fix for the flickering issue in the
sliding popups effect. The problem is that slidingpopups grabs the
window in windowClosed, the fade effect checks it there, which makes
it racy.
In my tests, I've not seen this problem with the WindowAddedGrab, but
as far as I understand, the problem may well be present there as well.
(And my proposed trick doesn't work.) I've not seen this happening in my
debugging, however. The problem there is also less visible since the
transparency curves go into the same direction, and are more "in line
with each other".
So, fix: Move the setData(WindowClosedGrabRole, ...) call from
windowClosed into windowAdded, which makes sure it's set whenever the
window goes away.
REVIEW:115903
BUG:329991
2014-02-20 13:38:36 +00:00
|
|
|
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
2011-12-10 21:32:47 +00:00
|
|
|
w->setData(WindowForceBlurRole, true);
|
2009-09-08 20:42:45 +00:00
|
|
|
|
2009-07-23 19:06:50 +00:00
|
|
|
w->addRepaintFull();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2011-02-27 08:25:45 +00:00
|
|
|
void SlidingPopupsEffect::slotWindowClosed(EffectWindow* w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (w->isOnCurrentDesktop() && !w->isMinimized() && mWindowsData.contains(w)) {
|
2016-07-04 13:40:38 +00:00
|
|
|
if (w->isDeleted()) {
|
|
|
|
w->refWindow();
|
|
|
|
}
|
2018-06-29 20:26:48 +00:00
|
|
|
|
|
|
|
mAppearingWindows.remove(w);
|
|
|
|
|
|
|
|
TimeLine &timeLine = mDisappearingWindows[ w ];
|
|
|
|
if (timeLine.running()) {
|
2016-07-04 13:40:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-06-29 20:26:48 +00:00
|
|
|
timeLine.setDirection(TimeLine::Forward);
|
|
|
|
timeLine.setDuration(mWindowsData[ w ].fadeOutDuration);
|
|
|
|
timeLine.setEasingCurve(QEasingCurve::InOutSine);
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2010-01-11 04:52:19 +00:00
|
|
|
// Tell other windowClosed() effects to ignore this window
|
2011-01-30 14:34:42 +00:00
|
|
|
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
2011-12-10 21:32:47 +00:00
|
|
|
w->setData(WindowForceBlurRole, true);
|
2018-06-11 09:41:23 +00:00
|
|
|
if (!w->data(WindowForceBackgroundContrastRole).toBool() && w->hasAlpha()) {
|
2014-02-20 13:10:18 +00:00
|
|
|
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
|
|
|
|
}
|
2010-01-11 04:52:19 +00:00
|
|
|
|
2009-07-23 19:06:50 +00:00
|
|
|
w->addRepaintFull();
|
|
|
|
}
|
2014-02-20 13:10:18 +00:00
|
|
|
m_backgroundContrastForced.removeAll(w);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2011-02-27 09:47:42 +00:00
|
|
|
void SlidingPopupsEffect::slotWindowDeleted(EffectWindow* w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2018-06-29 20:26:48 +00:00
|
|
|
mAppearingWindows.remove(w);
|
|
|
|
mDisappearingWindows.remove(w);
|
2011-01-30 14:34:42 +00:00
|
|
|
mWindowsData.remove(w);
|
2015-12-12 09:37:43 +00:00
|
|
|
effects->addRepaint(w->expandedGeometry());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2011-03-12 18:18:19 +00:00
|
|
|
void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2017-09-10 14:51:18 +00:00
|
|
|
if (!w || a != mAtom || mAtom == XCB_ATOM_NONE)
|
2009-07-23 19:06:50 +00:00
|
|
|
return;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QByteArray data = w->readProperty(mAtom, mAtom, 32);
|
2009-07-27 13:27:16 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (data.length() < 1) {
|
2010-11-30 20:03:03 +00:00
|
|
|
// Property was removed, thus also remove the effect for window
|
2017-03-28 15:51:00 +00:00
|
|
|
if (w->data(WindowClosedGrabRole).value<void *>() == this) {
|
|
|
|
w->setData(WindowClosedGrabRole, QVariant());
|
|
|
|
}
|
2018-06-29 20:26:48 +00:00
|
|
|
mAppearingWindows.remove(w);
|
|
|
|
mDisappearingWindows.remove(w);
|
2011-01-30 14:34:42 +00:00
|
|
|
mWindowsData.remove(w);
|
2009-07-23 19:06:50 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-09 10:05:52 +00:00
|
|
|
|
2013-09-25 06:54:22 +00:00
|
|
|
auto* d = reinterpret_cast< uint32_t* >(data.data());
|
2009-07-23 19:06:50 +00:00
|
|
|
Data animData;
|
|
|
|
animData.start = d[ 0 ];
|
|
|
|
animData.from = (Position)d[ 1 ];
|
2014-02-13 18:45:42 +00:00
|
|
|
//custom duration
|
2014-03-21 18:19:21 +00:00
|
|
|
animData.slideLength = 0;
|
2013-09-25 06:54:22 +00:00
|
|
|
if (data.length() >= (int)(sizeof(uint32_t) * 3)) {
|
2018-06-29 20:26:48 +00:00
|
|
|
animData.fadeInDuration = std::chrono::milliseconds(d[2]);
|
2013-09-25 06:54:22 +00:00
|
|
|
if (data.length() >= (int)(sizeof(uint32_t) * 4))
|
2014-02-13 18:45:42 +00:00
|
|
|
//custom fadein
|
2018-06-29 20:26:48 +00:00
|
|
|
animData.fadeOutDuration = std::chrono::milliseconds(d[3]);
|
2010-08-07 11:41:01 +00:00
|
|
|
else
|
2014-02-13 18:45:42 +00:00
|
|
|
//custom fadeout
|
2018-06-29 20:26:48 +00:00
|
|
|
animData.fadeOutDuration = std::chrono::milliseconds(d[2]);
|
2014-02-13 18:45:42 +00:00
|
|
|
|
|
|
|
//do we want an actual slide?
|
|
|
|
if (data.length() >= (int)(sizeof(uint32_t) * 5))
|
|
|
|
animData.slideLength = d[5];
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2018-06-29 20:26:48 +00:00
|
|
|
animData.fadeInDuration = mFadeInTime;
|
|
|
|
animData.fadeOutDuration = mFadeOutTime;
|
2009-07-23 19:06:50 +00:00
|
|
|
}
|
2015-09-14 14:39:39 +00:00
|
|
|
mWindowsData[ w ] = animData;
|
|
|
|
setupAnimData(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SlidingPopupsEffect::setupAnimData(EffectWindow *w)
|
|
|
|
{
|
2011-12-10 11:31:06 +00:00
|
|
|
const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop());
|
2015-09-14 14:39:39 +00:00
|
|
|
if (mWindowsData[w].start == -1) {
|
|
|
|
switch (mWindowsData[w].from) {
|
2011-12-10 11:31:06 +00:00
|
|
|
case West:
|
2015-09-14 14:39:39 +00:00
|
|
|
mWindowsData[w].start = qMax(w->x() - screenRect.x(), 0);
|
2011-12-10 11:31:06 +00:00
|
|
|
break;
|
|
|
|
case North:
|
2015-09-14 14:39:39 +00:00
|
|
|
mWindowsData[w].start = qMax(w->y() - screenRect.y(), 0);
|
2011-12-10 11:31:06 +00:00
|
|
|
break;
|
|
|
|
case East:
|
2015-09-14 14:39:39 +00:00
|
|
|
mWindowsData[w].start = qMax(screenRect.x() + screenRect.width() - (w->x() + w->width()), 0);
|
2011-12-10 11:31:06 +00:00
|
|
|
break;
|
|
|
|
case South:
|
|
|
|
default:
|
2015-09-14 14:39:39 +00:00
|
|
|
mWindowsData[w].start = qMax(screenRect.y() + screenRect.height() - (w->y() + w->height()), 0);
|
2011-12-10 11:31:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// sanitize
|
|
|
|
int difference = 0;
|
2015-09-14 14:39:39 +00:00
|
|
|
switch (mWindowsData[w].from) {
|
2011-12-10 11:31:06 +00:00
|
|
|
case West:
|
|
|
|
difference = w->x() - screenRect.x();
|
|
|
|
break;
|
|
|
|
case North:
|
|
|
|
difference = w->y() - screenRect.y();
|
|
|
|
break;
|
|
|
|
case East:
|
|
|
|
difference = w->x() + w->width() - (screenRect.x() + screenRect.width());
|
|
|
|
break;
|
|
|
|
case South:
|
|
|
|
default:
|
|
|
|
difference = w->y() + w->height() - (screenRect.y() + screenRect.height());
|
|
|
|
break;
|
|
|
|
}
|
2015-09-14 14:39:39 +00:00
|
|
|
mWindowsData[w].start = qMax<int>(mWindowsData[w].start, difference);
|
slidingpopups claim windowClosedGrabRole earlier
This seems like a more proper fix for the flickering issue in the
sliding popups effect. The problem is that slidingpopups grabs the
window in windowClosed, the fade effect checks it there, which makes
it racy.
In my tests, I've not seen this problem with the WindowAddedGrab, but
as far as I understand, the problem may well be present there as well.
(And my proposed trick doesn't work.) I've not seen this happening in my
debugging, however. The problem there is also less visible since the
transparency curves go into the same direction, and are more "in line
with each other".
So, fix: Move the setData(WindowClosedGrabRole, ...) call from
windowClosed into windowAdded, which makes sure it's set whenever the
window goes away.
REVIEW:115903
BUG:329991
2014-02-20 13:38:36 +00:00
|
|
|
// Grab the window, so other windowClosed effects will ignore it
|
|
|
|
w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2011-08-27 09:21:31 +00:00
|
|
|
|
2015-09-14 14:39:39 +00:00
|
|
|
void SlidingPopupsEffect::slotWaylandSlideOnShowChanged(EffectWindow* w)
|
|
|
|
{
|
|
|
|
if (!w) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
KWayland::Server::SurfaceInterface *surf = w->surface();
|
|
|
|
if (!surf) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surf->slideOnShowHide()) {
|
|
|
|
Data animData;
|
|
|
|
animData.start = surf->slideOnShowHide()->offset();
|
|
|
|
|
|
|
|
switch (surf->slideOnShowHide()->location()) {
|
|
|
|
case KWayland::Server::SlideInterface::Location::Top:
|
|
|
|
animData.from = North;
|
|
|
|
break;
|
|
|
|
case KWayland::Server::SlideInterface::Location::Left:
|
|
|
|
animData.from = West;
|
|
|
|
break;
|
|
|
|
case KWayland::Server::SlideInterface::Location::Right:
|
|
|
|
animData.from = East;
|
|
|
|
break;
|
|
|
|
case KWayland::Server::SlideInterface::Location::Bottom:
|
|
|
|
default:
|
|
|
|
animData.from = South;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
animData.slideLength = 0;
|
2018-06-29 20:26:48 +00:00
|
|
|
animData.fadeInDuration = mFadeInTime;
|
|
|
|
animData.fadeOutDuration = mFadeOutTime;
|
2015-09-14 14:39:39 +00:00
|
|
|
mWindowsData[ w ] = animData;
|
|
|
|
|
|
|
|
setupAnimData(w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-27 09:21:31 +00:00
|
|
|
bool SlidingPopupsEffect::isActive() const
|
|
|
|
{
|
|
|
|
return !mAppearingWindows.isEmpty() || !mDisappearingWindows.isEmpty();
|
|
|
|
}
|
|
|
|
|
2009-07-23 19:06:50 +00:00
|
|
|
} // namespace
|