2008-08-12 15:22:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
|
2008-12-13 10:11:26 +00:00
|
|
|
Copyright (C) 2008 Lucas Murray <lmurray@undefinedfire.com>
|
2008-08-12 15:22:06 +00:00
|
|
|
|
|
|
|
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 "slide.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
SlideEffect::SlideEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
: slide(false)
|
|
|
|
{
|
2011-02-25 19:41:10 +00:00
|
|
|
connect(effects, SIGNAL(desktopChanged(int,int)), this, SLOT(slotDesktopChanged(int,int)));
|
Force-enable blur for Plasma's windows during desktop slide
Without setting the property, Plasma's panel and dialogs lose the
backgroundcontrast effect during slides, which makes them flicker.
As the panel is shown on screen all the time, this is quite a visible
bug. To fix this, when the slide effect is started, we check for window
types and properties of each window, and force the blur flag on if it's
unset.
If the background contrast flag is set to false, we leave the window
alone assuming that there's a reason to force it off. Windows that
are newly added during the slide get the same treatment, so something
popping up while sliding (such as the desktop switch OSD) also gets
the background effect applied.When the effect stops or is interupted, we
unset what we've set, and clean up our internal bookkeeping.
Thanks Martin and Thomas for the thorough review!
REVIEW:115857
2014-02-19 13:02:09 +00:00
|
|
|
connect(effects, &EffectsHandler::windowAdded, this, &SlideEffect::windowAdded);
|
|
|
|
connect(effects, &EffectsHandler::windowDeleted, [this](EffectWindow *w) {
|
|
|
|
m_backgroundContrastForcedBefore.removeAll(w);
|
|
|
|
});
|
2011-03-14 21:50:05 +00:00
|
|
|
mTimeLine.setCurveShape(QTimeLine::EaseInOutCurve);
|
2011-01-30 14:34:42 +00:00
|
|
|
reconfigure(ReconfigureAll);
|
|
|
|
}
|
2008-10-09 05:31:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void SlideEffect::reconfigure(ReconfigureFlags)
|
|
|
|
{
|
|
|
|
mTimeLine.setDuration(animationTime(250));
|
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void SlideEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
if (slide) {
|
2011-03-14 21:50:05 +00:00
|
|
|
mTimeLine.setCurrentTime(mTimeLine.currentTime() + time);
|
2008-08-12 15:22:06 +00:00
|
|
|
|
|
|
|
// PAINT_SCREEN_BACKGROUND_FIRST is needed because screen will be actually painted more than once,
|
|
|
|
// so with normal screen painting second screen paint would erase parts of the first paint
|
2011-03-14 21:50:05 +00:00
|
|
|
if (mTimeLine.currentValue() != 1)
|
2008-08-12 15:22:06 +00:00
|
|
|
data.mask |= PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_BACKGROUND_FIRST;
|
2011-01-30 14:34:42 +00:00
|
|
|
else {
|
2011-12-10 21:16:41 +00:00
|
|
|
foreach (EffectWindow * w, effects->stackingOrder()) {
|
|
|
|
w->setData(WindowForceBlurRole, QVariant(false));
|
Force-enable blur for Plasma's windows during desktop slide
Without setting the property, Plasma's panel and dialogs lose the
backgroundcontrast effect during slides, which makes them flicker.
As the panel is shown on screen all the time, this is quite a visible
bug. To fix this, when the slide effect is started, we check for window
types and properties of each window, and force the blur flag on if it's
unset.
If the background contrast flag is set to false, we leave the window
alone assuming that there's a reason to force it off. Windows that
are newly added during the slide get the same treatment, so something
popping up while sliding (such as the desktop switch OSD) also gets
the background effect applied.When the effect stops or is interupted, we
unset what we've set, and clean up our internal bookkeeping.
Thanks Martin and Thomas for the thorough review!
REVIEW:115857
2014-02-19 13:02:09 +00:00
|
|
|
if (m_backgroundContrastForcedBefore.contains(w)) {
|
|
|
|
w->setData(WindowForceBackgroundContrastRole, QVariant());
|
|
|
|
}
|
2011-12-10 21:16:41 +00:00
|
|
|
}
|
Force-enable blur for Plasma's windows during desktop slide
Without setting the property, Plasma's panel and dialogs lose the
backgroundcontrast effect during slides, which makes them flicker.
As the panel is shown on screen all the time, this is quite a visible
bug. To fix this, when the slide effect is started, we check for window
types and properties of each window, and force the blur flag on if it's
unset.
If the background contrast flag is set to false, we leave the window
alone assuming that there's a reason to force it off. Windows that
are newly added during the slide get the same treatment, so something
popping up while sliding (such as the desktop switch OSD) also gets
the background effect applied.When the effect stops or is interupted, we
unset what we've set, and clean up our internal bookkeeping.
Thanks Martin and Thomas for the thorough review!
REVIEW:115857
2014-02-19 13:02:09 +00:00
|
|
|
m_backgroundContrastForcedBefore.clear();
|
|
|
|
slide = false;
|
|
|
|
mTimeLine.setCurrentTime(0);
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->setActiveFullScreenEffect(NULL);
|
2008-08-12 15:22:06 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->prePaintScreen(data, time);
|
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void SlideEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
if (slide) {
|
|
|
|
if (w->isOnAllDesktops()) {
|
2011-12-10 21:16:41 +00:00
|
|
|
bool keep_above = w->keepAbove() || w->isDock();
|
|
|
|
if ((!slide_painting_sticky || keep_above) &&
|
|
|
|
(!keep_above || !slide_painting_keep_above)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
|
2011-12-10 21:16:41 +00:00
|
|
|
}
|
2011-09-22 15:16:05 +00:00
|
|
|
} else if (w->isOnDesktop(painting_desktop)) {
|
|
|
|
data.setTransformed();
|
2011-01-30 14:34:42 +00:00
|
|
|
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
|
2011-09-22 15:16:05 +00:00
|
|
|
} else {
|
2011-01-30 14:34:42 +00:00
|
|
|
w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
|
2011-09-22 15:16:05 +00:00
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->prePaintWindow(w, data, time);
|
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void SlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
|
|
|
|
{
|
2011-03-14 21:50:05 +00:00
|
|
|
if (mTimeLine.currentValue() == 0) {
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->paintScreen(mask, region, data);
|
2008-08-12 15:22:06 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2008-08-12 15:22:06 +00:00
|
|
|
/*
|
|
|
|
Transformations are done by remembering starting position of the change and the progress
|
|
|
|
of it, the destination is computed from the current desktop. Positions of desktops
|
|
|
|
are done using their topleft corner.
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
QPoint destPos = desktopRect(effects->currentDesktop()).topLeft();
|
2008-08-12 15:22:06 +00:00
|
|
|
QPoint diffPos = destPos - slide_start_pos;
|
|
|
|
int w = 0;
|
|
|
|
int h = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (effects->optionRollOverDesktops()) {
|
2009-02-14 14:49:46 +00:00
|
|
|
w = effects->workspaceWidth();
|
|
|
|
h = effects->workspaceHeight();
|
2008-08-12 15:22:06 +00:00
|
|
|
// wrap around if shorter
|
2011-01-30 14:34:42 +00:00
|
|
|
if (diffPos.x() > 0 && diffPos.x() > w / 2)
|
|
|
|
diffPos.setX(diffPos.x() - w);
|
|
|
|
if (diffPos.x() < 0 && abs(diffPos.x()) > w / 2)
|
|
|
|
diffPos.setX(diffPos.x() + w);
|
|
|
|
if (diffPos.y() > 0 && diffPos.y() > h / 2)
|
|
|
|
diffPos.setY(diffPos.y() - h);
|
|
|
|
if (diffPos.y() < 0 && abs(diffPos.y()) > h / 2)
|
|
|
|
diffPos.setY(diffPos.y() + h);
|
|
|
|
}
|
2011-03-14 21:50:05 +00:00
|
|
|
QPoint currentPos = slide_start_pos + mTimeLine.currentValue() * diffPos;
|
2011-01-30 14:34:42 +00:00
|
|
|
QSize displaySize(displayWidth(), displayHeight());
|
|
|
|
QRegion currentRegion = QRect(currentPos, displaySize);
|
|
|
|
if (effects->optionRollOverDesktops()) {
|
|
|
|
currentRegion |= (currentRegion & QRect(-w, 0, w, h)).translated(w, 0);
|
|
|
|
currentRegion |= (currentRegion & QRect(0, -h, w, h)).translated(0, h);
|
|
|
|
currentRegion |= (currentRegion & QRect(w, 0, w, h)).translated(-w, 0);
|
|
|
|
currentRegion |= (currentRegion & QRect(0, h, w, h)).translated(0, -h);
|
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
bool do_sticky = true;
|
2011-12-10 21:16:41 +00:00
|
|
|
// Assure that the windows that are on all desktops and always on top
|
|
|
|
// are painted with the last screen (e.g. plasma's tooltips). All other windows
|
|
|
|
// that are on all desktops (e.g. the background window) are painted together
|
|
|
|
// with the first screen.
|
|
|
|
int last_desktop = 0;
|
|
|
|
QList<QRect> desktop_rects;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int desktop = 1;
|
|
|
|
desktop <= effects->numberOfDesktops();
|
|
|
|
++desktop) {
|
|
|
|
QRect rect = desktopRect(desktop);
|
2011-12-10 21:16:41 +00:00
|
|
|
desktop_rects << rect;
|
|
|
|
if (currentRegion.contains(rect)) {
|
|
|
|
last_desktop = desktop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int desktop = 1;
|
|
|
|
desktop <= effects->numberOfDesktops();
|
|
|
|
++desktop) {
|
|
|
|
QRect rect = desktop_rects[desktop-1];
|
2011-01-30 14:34:42 +00:00
|
|
|
if (currentRegion.contains(rect)) { // part of the desktop needs painting
|
2008-08-12 15:22:06 +00:00
|
|
|
painting_desktop = desktop;
|
|
|
|
slide_painting_sticky = do_sticky;
|
2011-12-10 21:16:41 +00:00
|
|
|
slide_painting_keep_above = (last_desktop == desktop);
|
2008-08-12 15:22:06 +00:00
|
|
|
slide_painting_diff = rect.topLeft() - currentPos;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (effects->optionRollOverDesktops()) {
|
|
|
|
if (slide_painting_diff.x() > displayWidth())
|
|
|
|
slide_painting_diff.setX(slide_painting_diff.x() - w);
|
|
|
|
if (slide_painting_diff.x() < -displayWidth())
|
|
|
|
slide_painting_diff.setX(slide_painting_diff.x() + w);
|
|
|
|
if (slide_painting_diff.y() > displayHeight())
|
|
|
|
slide_painting_diff.setY(slide_painting_diff.y() - h);
|
|
|
|
if (slide_painting_diff.y() < -displayHeight())
|
|
|
|
slide_painting_diff.setY(slide_painting_diff.y() + h);
|
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
do_sticky = false; // paint on-all-desktop windows only once
|
|
|
|
// TODO mask parts that are not visible?
|
2011-09-22 15:16:05 +00:00
|
|
|
effects->paintScreen(mask, region, data);
|
2008-08-12 15:22:06 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void SlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
|
|
|
|
{
|
|
|
|
if (slide) {
|
|
|
|
// don't move windows on all desktops (compensate screen transformation)
|
2011-09-22 15:16:05 +00:00
|
|
|
if (!w->isOnAllDesktops()) { // TODO also fix 'Workspace::movingClient'
|
2012-05-28 12:45:46 +00:00
|
|
|
data += slide_painting_diff;
|
2008-08-12 15:22:06 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->paintWindow(w, mask, region, data);
|
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
|
|
|
|
void SlideEffect::postPaintScreen()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (slide)
|
2008-08-12 15:22:06 +00:00
|
|
|
effects->addRepaintFull();
|
|
|
|
effects->postPaintScreen();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
|
|
|
|
// Gives a position of the given desktop when all desktops are arranged in a grid
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect SlideEffect::desktopRect(int desktop) const
|
|
|
|
{
|
|
|
|
QRect rect(0, 0, displayWidth(), displayHeight());
|
|
|
|
rect.translate(effects->desktopCoords(desktop));
|
2008-08-12 15:22:06 +00:00
|
|
|
return rect;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
|
2011-02-25 19:41:10 +00:00
|
|
|
void SlideEffect::slotDesktopChanged(int old, int current)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
|
2008-08-12 15:22:06 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
if (slide) { // old slide still in progress
|
|
|
|
QPoint diffPos = desktopRect(old).topLeft() - slide_start_pos;
|
2008-08-12 15:22:06 +00:00
|
|
|
int w = 0;
|
|
|
|
int h = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (effects->optionRollOverDesktops()) {
|
2009-02-14 14:49:46 +00:00
|
|
|
w = effects->workspaceWidth();
|
|
|
|
h = effects->workspaceHeight();
|
2008-08-12 15:22:06 +00:00
|
|
|
// wrap around if shorter
|
2011-01-30 14:34:42 +00:00
|
|
|
if (diffPos.x() > 0 && diffPos.x() > w / 2)
|
|
|
|
diffPos.setX(diffPos.x() - w);
|
|
|
|
if (diffPos.x() < 0 && abs(diffPos.x()) > w / 2)
|
|
|
|
diffPos.setX(diffPos.x() + w);
|
|
|
|
if (diffPos.y() > 0 && diffPos.y() > h / 2)
|
|
|
|
diffPos.setY(diffPos.y() - h);
|
|
|
|
if (diffPos.y() < 0 && abs(diffPos.y()) > h / 2)
|
|
|
|
diffPos.setY(diffPos.y() + h);
|
|
|
|
}
|
2011-03-14 21:50:05 +00:00
|
|
|
QPoint currentPos = slide_start_pos + mTimeLine.currentValue() * diffPos;
|
2011-01-30 14:34:42 +00:00
|
|
|
QRegion currentRegion = QRect(currentPos, QSize(displayWidth(), displayHeight()));
|
|
|
|
if (effects->optionRollOverDesktops()) {
|
|
|
|
currentRegion |= (currentRegion & QRect(-w, 0, w, h)).translated(w, 0);
|
|
|
|
currentRegion |= (currentRegion & QRect(0, -h, w, h)).translated(0, h);
|
|
|
|
currentRegion |= (currentRegion & QRect(w, 0, w, h)).translated(-w, 0);
|
|
|
|
currentRegion |= (currentRegion & QRect(0, h, w, h)).translated(0, -h);
|
|
|
|
}
|
2011-02-25 19:41:10 +00:00
|
|
|
QRect rect = desktopRect(current);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (currentRegion.contains(rect)) {
|
|
|
|
// current position is in new current desktop (e.g. quickly changing back),
|
|
|
|
// don't do full progress
|
|
|
|
if (abs(currentPos.x() - rect.x()) > abs(currentPos.y() - rect.y()))
|
2011-03-14 21:50:05 +00:00
|
|
|
mTimeLine.setCurrentTime((1.0 - abs(currentPos.x() - rect.x()) / double(displayWidth()))*(qreal)mTimeLine.currentValue());
|
2008-08-12 15:22:06 +00:00
|
|
|
else
|
2011-03-14 21:50:05 +00:00
|
|
|
mTimeLine.setCurrentTime((1.0 - abs(currentPos.y() - rect.y()) / double(displayHeight()))*(qreal)mTimeLine.currentValue());
|
2011-01-30 14:34:42 +00:00
|
|
|
} else // current position is not on current desktop, do full progress
|
2011-03-14 21:50:05 +00:00
|
|
|
mTimeLine.setCurrentTime(0);
|
2008-08-12 15:22:06 +00:00
|
|
|
diffPos = rect.topLeft() - currentPos;
|
2011-03-14 21:50:05 +00:00
|
|
|
if (mTimeLine.currentValue() <= 0) {
|
2008-08-12 15:22:06 +00:00
|
|
|
// Compute starting point for this new move (given current and end positions)
|
2011-03-14 21:50:05 +00:00
|
|
|
slide_start_pos = rect.topLeft() - diffPos * 1 / (1 - mTimeLine.currentValue());
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
|
|
|
// at the end, stop
|
Force-enable blur for Plasma's windows during desktop slide
Without setting the property, Plasma's panel and dialogs lose the
backgroundcontrast effect during slides, which makes them flicker.
As the panel is shown on screen all the time, this is quite a visible
bug. To fix this, when the slide effect is started, we check for window
types and properties of each window, and force the blur flag on if it's
unset.
If the background contrast flag is set to false, we leave the window
alone assuming that there's a reason to force it off. Windows that
are newly added during the slide get the same treatment, so something
popping up while sliding (such as the desktop switch OSD) also gets
the background effect applied.When the effect stops or is interupted, we
unset what we've set, and clean up our internal bookkeeping.
Thanks Martin and Thomas for the thorough review!
REVIEW:115857
2014-02-19 13:02:09 +00:00
|
|
|
foreach (EffectWindow * w, m_backgroundContrastForcedBefore) {
|
|
|
|
w->setData(WindowForceBackgroundContrastRole, QVariant());
|
|
|
|
}
|
|
|
|
m_backgroundContrastForcedBefore.clear();
|
2008-08-12 15:22:06 +00:00
|
|
|
slide = false;
|
2011-03-14 21:50:05 +00:00
|
|
|
mTimeLine.setCurrentTime(0);
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->setActiveFullScreenEffect(NULL);
|
2008-08-12 15:22:06 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
|
|
|
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
|
2008-11-18 13:36:34 +00:00
|
|
|
return;
|
2011-03-14 21:50:05 +00:00
|
|
|
mTimeLine.setCurrentTime(0);
|
2011-01-30 14:34:42 +00:00
|
|
|
slide_start_pos = desktopRect(old).topLeft();
|
2008-08-12 15:22:06 +00:00
|
|
|
slide = true;
|
2011-12-10 21:16:41 +00:00
|
|
|
foreach (EffectWindow * w, effects->stackingOrder()) {
|
|
|
|
w->setData(WindowForceBlurRole, QVariant(true));
|
Force-enable blur for Plasma's windows during desktop slide
Without setting the property, Plasma's panel and dialogs lose the
backgroundcontrast effect during slides, which makes them flicker.
As the panel is shown on screen all the time, this is quite a visible
bug. To fix this, when the slide effect is started, we check for window
types and properties of each window, and force the blur flag on if it's
unset.
If the background contrast flag is set to false, we leave the window
alone assuming that there's a reason to force it off. Windows that
are newly added during the slide get the same treatment, so something
popping up while sliding (such as the desktop switch OSD) also gets
the background effect applied.When the effect stops or is interupted, we
unset what we've set, and clean up our internal bookkeeping.
Thanks Martin and Thomas for the thorough review!
REVIEW:115857
2014-02-19 13:02:09 +00:00
|
|
|
if (shouldForceBackgroundContrast(w)) {
|
|
|
|
m_backgroundContrastForcedBefore.append(w);
|
|
|
|
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
|
|
|
|
}
|
2011-12-10 21:16:41 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->setActiveFullScreenEffect(this);
|
2008-08-12 15:22:06 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->addRepaintFull();
|
|
|
|
}
|
2008-08-12 15:22:06 +00:00
|
|
|
|
Force-enable blur for Plasma's windows during desktop slide
Without setting the property, Plasma's panel and dialogs lose the
backgroundcontrast effect during slides, which makes them flicker.
As the panel is shown on screen all the time, this is quite a visible
bug. To fix this, when the slide effect is started, we check for window
types and properties of each window, and force the blur flag on if it's
unset.
If the background contrast flag is set to false, we leave the window
alone assuming that there's a reason to force it off. Windows that
are newly added during the slide get the same treatment, so something
popping up while sliding (such as the desktop switch OSD) also gets
the background effect applied.When the effect stops or is interupted, we
unset what we've set, and clean up our internal bookkeeping.
Thanks Martin and Thomas for the thorough review!
REVIEW:115857
2014-02-19 13:02:09 +00:00
|
|
|
void SlideEffect::windowAdded(EffectWindow *w)
|
|
|
|
{
|
|
|
|
if (slide && shouldForceBackgroundContrast(w)) {
|
|
|
|
m_backgroundContrastForcedBefore.append(w);
|
|
|
|
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SlideEffect::shouldForceBackgroundContrast(const EffectWindow *w) const
|
|
|
|
{
|
|
|
|
// Windows that are docks, kept above (such as panel popups), and do not
|
|
|
|
// have the background contrast explicitely disabled should be forced on
|
|
|
|
// during the slide animation
|
|
|
|
const bool bgWindow = (w->hasAlpha() && w->isOnAllDesktops() && (w->isDock() || w->keepAbove()));
|
|
|
|
return bgWindow && (!w->data(WindowForceBackgroundContrastRole).isValid());
|
|
|
|
}
|
|
|
|
|
2011-08-27 09:21:31 +00:00
|
|
|
bool SlideEffect::isActive() const
|
|
|
|
{
|
|
|
|
return slide;
|
|
|
|
}
|
|
|
|
|
2008-08-12 15:22:06 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "slide.moc"
|