[effects/slide] Handle moving clients

Summary:
Currently, slide effect doesn't handle a case when there
is a moving client. This results in having window jumps.
This commit fixes it by fixing position of the moving client
during switching to another desktop.

Test Plan: * send window one desktop to the left/right using shortcuts

Reviewers: #kwin, #plasma, graesslin

Reviewed By: #kwin, #plasma, graesslin

Subscribers: graesslin, plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9487
This commit is contained in:
Vlad Zagorodniy 2018-01-01 17:07:41 +02:00
parent 8a02a802ae
commit 20780c6f21
2 changed files with 21 additions and 9 deletions

View file

@ -32,11 +32,10 @@ SlideEffect::SlideEffect()
: slide(false)
{
initConfig<SlideConfig>();
connect(effects, SIGNAL(desktopChanged(int,int)), this, SLOT(slotDesktopChanged(int,int)));
connect(effects, SIGNAL(desktopChanged(int,int,KWin::EffectWindow*)),
this, SLOT(slotDesktopChanged(int,int,KWin::EffectWindow*)));
connect(effects, &EffectsHandler::windowAdded, this, &SlideEffect::windowAdded);
connect(effects, &EffectsHandler::windowDeleted, this, [this](EffectWindow *w) {
m_backgroundContrastForcedBefore.removeAll(w);
});
connect(effects, &EffectsHandler::windowDeleted, this, &SlideEffect::windowDeleted);
mTimeLine.setCurveShape(QTimeLine::EaseInOutCurve);
reconfigure(ReconfigureAll);
}
@ -72,6 +71,7 @@ void SlideEffect::prePaintScreen(ScreenPrePaintData& data, int time)
}
}
m_backgroundContrastForcedBefore.clear();
m_movingWindow = nullptr;
slide = false;
mTimeLine.setCurrentTime(0);
effects->setActiveFullScreenEffect(NULL);
@ -82,7 +82,7 @@ void SlideEffect::prePaintScreen(ScreenPrePaintData& data, int time)
void SlideEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if (slide) {
if (slide && w != m_movingWindow) {
if (w->isOnAllDesktops()) {
bool keep_above = w->keepAbove() || w->isDock();
if ((!slide_painting_sticky || keep_above) &&
@ -182,8 +182,8 @@ void SlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
void SlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if (slide) {
// don't move windows on all desktops (compensate screen transformation)
if (!w->isOnAllDesktops()) { // TODO also fix 'Workspace::movingClient'
// Do not move a window if it is on all desktops or being moved to another desktop.
if (!w->isOnAllDesktops() && w != m_movingWindow) {
data += slide_painting_diff;
}
}
@ -205,7 +205,7 @@ QRect SlideEffect::desktopRect(int desktop) const
return rect;
}
void SlideEffect::slotDesktopChanged(int old, int current)
void SlideEffect::slotDesktopChanged(int old, int current, EffectWindow* with)
{
if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this)
return;
@ -275,6 +275,9 @@ void SlideEffect::slotDesktopChanged(int old, int current)
}
effects->setActiveFullScreenEffect(this);
}
m_movingWindow = with;
effects->addRepaintFull();
}
@ -286,6 +289,13 @@ void SlideEffect::windowAdded(EffectWindow *w)
}
}
void SlideEffect::windowDeleted(EffectWindow *w)
{
m_backgroundContrastForcedBefore.removeAll(w);
if (w == m_movingWindow)
m_movingWindow = nullptr;
}
bool SlideEffect::shouldForceBackgroundContrast(const EffectWindow *w) const
{
// Windows that are docks, kept above (such as panel popups), and do not

View file

@ -50,10 +50,11 @@ public:
static bool supported();
private Q_SLOTS:
void slotDesktopChanged(int old, int current);
void slotDesktopChanged(int old, int current, KWin::EffectWindow* with);
private:
void windowAdded(EffectWindow* w);
void windowDeleted(EffectWindow* w);
bool shouldForceBackgroundContrast(const EffectWindow* w) const;
QList< EffectWindow* > m_backgroundContrastForcedBefore;
QRect desktopRect(int desktop) const;
@ -64,6 +65,7 @@ private:
bool slide_painting_sticky;
bool slide_painting_keep_above;
QPoint slide_painting_diff;
EffectWindow* m_movingWindow = nullptr;
};