2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2009 Michael Zanetti <michael_zanetti@gmx.net>
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2009-04-15 19:31:20 +00:00
|
|
|
|
|
|
|
#include "slideback.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
SlideBackEffect::SlideBackEffect()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-01-30 20:50:09 +00:00
|
|
|
m_tabboxActive = 0;
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
m_justMapped = m_upmostWindow = nullptr;
|
2019-01-01 20:48:53 +00:00
|
|
|
connect(effects, &EffectsHandler::windowAdded, this, &SlideBackEffect::slotWindowAdded);
|
|
|
|
connect(effects, &EffectsHandler::windowDeleted, this, &SlideBackEffect::slotWindowDeleted);
|
|
|
|
connect(effects, &EffectsHandler::windowUnminimized, this, &SlideBackEffect::slotWindowUnminimized);
|
|
|
|
connect(effects, &EffectsHandler::tabBoxAdded, this, &SlideBackEffect::slotTabBoxAdded);
|
|
|
|
connect(effects, &EffectsHandler::stackingOrderChanged, this, &SlideBackEffect::slotStackingOrderChanged);
|
|
|
|
connect(effects, &EffectsHandler::tabBoxClosed, this, &SlideBackEffect::slotTabBoxClosed);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2013-01-30 20:50:09 +00:00
|
|
|
void SlideBackEffect::slotStackingOrderChanged()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-01-30 20:50:09 +00:00
|
|
|
if (effects->activeFullScreenEffect() || m_tabboxActive) {
|
|
|
|
oldStackingOrder = effects->stackingOrder();
|
|
|
|
usableOldStackingOrder = usableWindows(oldStackingOrder);
|
2009-04-15 19:31:20 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2013-01-30 20:50:09 +00:00
|
|
|
EffectWindowList newStackingOrder = effects->stackingOrder(),
|
|
|
|
usableNewStackingOrder = usableWindows(newStackingOrder);
|
|
|
|
if (usableNewStackingOrder == usableOldStackingOrder || usableNewStackingOrder.isEmpty()) {
|
|
|
|
oldStackingOrder = newStackingOrder;
|
|
|
|
usableOldStackingOrder = usableNewStackingOrder;
|
2009-04-15 19:31:20 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-07-06 11:13:48 +00:00
|
|
|
|
2013-01-30 20:50:09 +00:00
|
|
|
m_upmostWindow = usableNewStackingOrder.last();
|
2009-07-06 11:13:48 +00:00
|
|
|
|
2013-01-30 20:50:09 +00:00
|
|
|
if (m_upmostWindow == m_justMapped ) // a window was added, got on top, stacking changed. Nothing impressive
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
m_justMapped = nullptr;
|
2013-02-20 21:40:57 +00:00
|
|
|
else if (!usableOldStackingOrder.isEmpty() && m_upmostWindow != usableOldStackingOrder.last())
|
2013-01-30 20:50:09 +00:00
|
|
|
windowRaised(m_upmostWindow);
|
|
|
|
|
|
|
|
oldStackingOrder = newStackingOrder;
|
|
|
|
usableOldStackingOrder = usableNewStackingOrder;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2013-01-30 20:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SlideBackEffect::windowRaised(EffectWindow *w)
|
|
|
|
{
|
2009-04-15 19:31:20 +00:00
|
|
|
// Determine all windows on top of the activated one
|
|
|
|
bool currentFound = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (EffectWindow * tmp, oldStackingOrder) {
|
|
|
|
if (!currentFound) {
|
|
|
|
if (tmp == w) {
|
2009-04-15 19:31:20 +00:00
|
|
|
currentFound = true;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2019-01-03 16:47:28 +00:00
|
|
|
if (isWindowUsable(tmp) && tmp->isOnCurrentDesktop() && w->isOnCurrentDesktop()) {
|
2009-04-15 19:31:20 +00:00
|
|
|
// Do we have to move it?
|
2011-01-30 14:34:42 +00:00
|
|
|
if (intersects(w, tmp->geometry())) {
|
2009-04-22 12:49:28 +00:00
|
|
|
QRect slideRect;
|
2011-01-30 14:34:42 +00:00
|
|
|
slideRect = getSlideDestination(getModalGroupGeometry(w), tmp->geometry());
|
|
|
|
effects->setElevatedWindow(tmp, true);
|
|
|
|
elevatedList.append(tmp);
|
|
|
|
motionManager.manage(tmp);
|
|
|
|
motionManager.moveWindow(tmp, slideRect);
|
|
|
|
destinationList.insert(tmp, slideRect);
|
|
|
|
coveringWindows.append(tmp);
|
|
|
|
} else {
|
2009-04-15 19:31:20 +00:00
|
|
|
//Does it intersect with a moved (elevated) window and do we have to elevate it too?
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (EffectWindow * elevatedWindow, elevatedList) {
|
|
|
|
if (tmp->geometry().intersects(elevatedWindow->geometry())) {
|
|
|
|
effects->setElevatedWindow(tmp, true);
|
|
|
|
elevatedList.append(tmp);
|
2009-04-15 19:31:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2009-04-15 19:31:20 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (tmp->isDock() || tmp->keepAbove()) {
|
|
|
|
effects->setElevatedWindow(tmp, true);
|
|
|
|
elevatedList.append(tmp);
|
2009-04-15 19:31:20 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
// If a window is minimized it could happen that the panels stay elevated without any windows sliding.
|
|
|
|
// clear all elevation settings
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!motionManager.managingWindows()) {
|
|
|
|
foreach (EffectWindow * tmp, elevatedList) {
|
|
|
|
effects->setElevatedWindow(tmp, false);
|
2009-04-15 19:31:20 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect SlideBackEffect::getSlideDestination(const QRect &windowUnderGeometry, const QRect &windowOverGeometry)
|
|
|
|
{
|
2009-04-20 21:19:14 +00:00
|
|
|
// Determine the shortest way:
|
|
|
|
int leftSlide = windowUnderGeometry.left() - windowOverGeometry.right() - 20;
|
|
|
|
int rightSlide = windowUnderGeometry.right() - windowOverGeometry.left() + 20;
|
|
|
|
int upSlide = windowUnderGeometry.top() - windowOverGeometry.bottom() - 20;
|
|
|
|
int downSlide = windowUnderGeometry.bottom() - windowOverGeometry.top() + 20;
|
|
|
|
|
|
|
|
int horizSlide = leftSlide;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (qAbs(horizSlide) > qAbs(rightSlide)) {
|
2009-04-20 21:19:14 +00:00
|
|
|
horizSlide = rightSlide;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-20 21:19:14 +00:00
|
|
|
int vertSlide = upSlide;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (qAbs(vertSlide) > qAbs(downSlide)) {
|
|
|
|
vertSlide = downSlide;
|
|
|
|
}
|
2009-04-20 21:19:14 +00:00
|
|
|
|
|
|
|
QRect slideRect = windowOverGeometry;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (qAbs(horizSlide) < qAbs(vertSlide)) {
|
|
|
|
slideRect.moveLeft(slideRect.x() + horizSlide);
|
|
|
|
} else {
|
|
|
|
slideRect.moveTop(slideRect.y() + vertSlide);
|
2009-04-20 21:19:14 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return slideRect;
|
|
|
|
}
|
2009-04-20 21:19:14 +00:00
|
|
|
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
void SlideBackEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
int time = 0;
|
|
|
|
if (m_lastPresentTime.count()) {
|
|
|
|
time = (presentTime - m_lastPresentTime).count();
|
|
|
|
}
|
|
|
|
m_lastPresentTime = presentTime;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (motionManager.managingWindows()) {
|
|
|
|
motionManager.calculate(time);
|
2009-04-15 19:31:20 +00:00
|
|
|
data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
|
|
|
}
|
2018-05-01 21:06:47 +00:00
|
|
|
|
|
|
|
for (auto const &w : effects->stackingOrder()) {
|
|
|
|
w->setData(WindowForceBlurRole, QVariant(true));
|
|
|
|
}
|
|
|
|
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
effects->prePaintScreen(data, presentTime);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
|
|
|
void SlideBackEffect::postPaintScreen()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (motionManager.areWindowsMoving()) {
|
2009-04-15 19:31:20 +00:00
|
|
|
effects->addRepaintFull();
|
|
|
|
}
|
2018-05-01 21:06:47 +00:00
|
|
|
|
|
|
|
for (auto &w : effects->stackingOrder()) {
|
2018-06-11 11:25:10 +00:00
|
|
|
w->setData(WindowForceBlurRole, QVariant());
|
2018-05-01 21:06:47 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->postPaintScreen();
|
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
void SlideBackEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (motionManager.isManaging(w)) {
|
2009-05-19 13:52:50 +00:00
|
|
|
data.setTransformed();
|
|
|
|
}
|
|
|
|
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
effects->prePaintWindow(w, data, presentTime);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SlideBackEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
|
|
|
|
{
|
|
|
|
if (motionManager.isManaging(w)) {
|
|
|
|
motionManager.apply(w, data);
|
|
|
|
}
|
2011-07-03 17:52:14 +00:00
|
|
|
foreach (const QRegion &r, clippedRegions) {
|
|
|
|
region = region.intersected(r);
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->paintWindow(w, mask, region, data);
|
|
|
|
for (int i = clippedRegions.count() - 1; i > -1; --i)
|
|
|
|
PaintClipper::pop(clippedRegions.at(i));
|
|
|
|
clippedRegions.clear();
|
|
|
|
}
|
2009-05-19 13:52:50 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void SlideBackEffect::postPaintWindow(EffectWindow* w)
|
|
|
|
{
|
|
|
|
if (motionManager.isManaging(w)) {
|
|
|
|
if (destinationList.contains(w)) {
|
2011-06-20 19:56:56 +00:00
|
|
|
if (!motionManager.isWindowMoving(w)) { // has window reched its destination?
|
2013-01-30 20:50:09 +00:00
|
|
|
// If we are still intersecting with the upmostWindow it is moving. slide to somewhere else
|
2009-04-20 21:19:14 +00:00
|
|
|
// restore the stacking order of all windows not intersecting any more except panels
|
2011-01-30 14:34:42 +00:00
|
|
|
if (coveringWindows.contains(w)) {
|
2009-04-22 11:24:19 +00:00
|
|
|
EffectWindowList tmpList;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (EffectWindow * tmp, elevatedList) {
|
2009-04-27 12:57:52 +00:00
|
|
|
QRect elevatedGeometry = tmp->geometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (motionManager.isManaging(tmp)) {
|
|
|
|
elevatedGeometry = motionManager.transformedGeometry(tmp).toAlignedRect();
|
|
|
|
}
|
2013-01-30 20:50:09 +00:00
|
|
|
if (m_upmostWindow && !tmp->isDock() && !tmp->keepAbove() && m_upmostWindow->geometry().intersects(elevatedGeometry)) {
|
2009-04-22 12:49:28 +00:00
|
|
|
QRect newDestination;
|
2013-01-30 20:50:09 +00:00
|
|
|
newDestination = getSlideDestination(getModalGroupGeometry(m_upmostWindow), elevatedGeometry);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!motionManager.isManaging(tmp)) {
|
|
|
|
motionManager.manage(tmp);
|
2009-04-20 21:19:14 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
motionManager.moveWindow(tmp, newDestination);
|
|
|
|
destinationList[tmp] = newDestination;
|
|
|
|
} else {
|
|
|
|
if (!tmp->isDock()) {
|
2009-04-22 11:24:19 +00:00
|
|
|
bool keepElevated = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (EffectWindow * elevatedWindow, tmpList) {
|
|
|
|
if (tmp->geometry().intersects(elevatedWindow->geometry())) {
|
2009-04-22 11:24:19 +00:00
|
|
|
keepElevated = true;
|
|
|
|
}
|
2009-04-20 21:19:14 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!keepElevated) {
|
|
|
|
effects->setElevatedWindow(tmp, false);
|
|
|
|
elevatedList.removeAll(tmp);
|
|
|
|
}
|
2009-04-20 21:19:14 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
tmpList.append(tmp);
|
2009-04-20 21:19:14 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2009-04-20 21:19:14 +00:00
|
|
|
// Move the window back where it belongs
|
2011-01-30 14:34:42 +00:00
|
|
|
motionManager.moveWindow(w, w->geometry());
|
|
|
|
destinationList.remove(w);
|
2009-04-15 19:31:20 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2009-04-15 19:31:20 +00:00
|
|
|
// is window back at its original position?
|
2011-06-20 19:56:56 +00:00
|
|
|
if (!motionManager.isWindowMoving(w)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
motionManager.unmanage(w);
|
2009-07-24 09:03:10 +00:00
|
|
|
effects->addRepaintFull();
|
2009-04-15 19:31:20 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (coveringWindows.contains(w)) {
|
2009-04-15 19:31:20 +00:00
|
|
|
// It could happen that there is no aciveWindow() here if the user clicks the close-button on an inactive window.
|
|
|
|
// Just skip... the window will be removed in windowDeleted() later
|
2013-01-30 20:50:09 +00:00
|
|
|
if (m_upmostWindow && !intersects(m_upmostWindow, motionManager.transformedGeometry(w).toAlignedRect())) {
|
2011-01-30 14:34:42 +00:00
|
|
|
coveringWindows.removeAll(w);
|
|
|
|
if (coveringWindows.isEmpty()) {
|
2009-04-15 19:31:20 +00:00
|
|
|
// Restore correct stacking order
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (EffectWindow * tmp, elevatedList) {
|
|
|
|
effects->setElevatedWindow(tmp, false);
|
2009-04-15 19:31:20 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
elevatedList.clear();
|
2009-04-15 19:31:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.
While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.
Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.
Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.
Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.
Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.
We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-11-20 15:44:04 +00:00
|
|
|
if (!isActive()) {
|
|
|
|
m_lastPresentTime = std::chrono::milliseconds::zero();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->postPaintWindow(w);
|
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2011-02-27 09:47:42 +00:00
|
|
|
void SlideBackEffect::slotWindowDeleted(EffectWindow* w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-01-30 20:50:09 +00:00
|
|
|
if (w == m_upmostWindow)
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
m_upmostWindow = nullptr;
|
2013-01-30 20:50:09 +00:00
|
|
|
if (w == m_justMapped)
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
m_justMapped = nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
usableOldStackingOrder.removeAll(w);
|
|
|
|
oldStackingOrder.removeAll(w);
|
|
|
|
coveringWindows.removeAll(w);
|
|
|
|
elevatedList.removeAll(w);
|
|
|
|
if (motionManager.isManaging(w)) {
|
|
|
|
motionManager.unmanage(w);
|
2009-04-15 19:31:20 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2011-02-25 21:06:02 +00:00
|
|
|
void SlideBackEffect::slotWindowAdded(EffectWindow *w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-01-30 20:50:09 +00:00
|
|
|
m_justMapped = w;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2011-03-06 10:08:19 +00:00
|
|
|
void SlideBackEffect::slotWindowUnminimized(EffectWindow* w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-07-06 11:13:48 +00:00
|
|
|
// SlideBack should not be triggered on an unminimized window. For this we need to store the last unminimized window.
|
2013-01-30 20:50:09 +00:00
|
|
|
m_justMapped = w;
|
2015-11-22 09:37:21 +00:00
|
|
|
// the stackingOrderChanged() signal came before the window turned an effect window
|
|
|
|
// usually this is no problem as the change shall not be caught anyway, but
|
|
|
|
// the window may have changed its stack position, bug #353745
|
|
|
|
slotStackingOrderChanged();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2013-01-30 20:50:09 +00:00
|
|
|
void SlideBackEffect::slotTabBoxAdded()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-01-30 20:50:09 +00:00
|
|
|
++m_tabboxActive;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2013-01-30 20:50:09 +00:00
|
|
|
void SlideBackEffect::slotTabBoxClosed()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-01-30 20:50:09 +00:00
|
|
|
m_tabboxActive = qMax(m_tabboxActive-1, 0);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool SlideBackEffect::isWindowUsable(EffectWindow* w)
|
|
|
|
{
|
|
|
|
return w && (w->isNormalWindow() || w->isDialog()) && !w->keepAbove() && !w->isDeleted() && !w->isMinimized()
|
2019-09-14 08:58:12 +00:00
|
|
|
&& w->isPaintingEnabled();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool SlideBackEffect::intersects(EffectWindow* windowUnder, const QRect &windowOverGeometry)
|
|
|
|
{
|
|
|
|
QRect windowUnderGeometry = getModalGroupGeometry(windowUnder);
|
|
|
|
return windowUnderGeometry.intersects(windowOverGeometry);
|
|
|
|
}
|
2009-04-22 12:49:28 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
EffectWindowList SlideBackEffect::usableWindows(const EffectWindowList & allWindows)
|
|
|
|
{
|
2009-04-15 19:31:20 +00:00
|
|
|
EffectWindowList retList;
|
2017-07-02 12:26:53 +00:00
|
|
|
auto isWindowVisible = [] (const EffectWindow *window) {
|
|
|
|
return window && effects->virtualScreenGeometry().intersects(window->geometry());
|
|
|
|
};
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (EffectWindow * tmp, allWindows) {
|
2017-07-02 12:26:53 +00:00
|
|
|
if (isWindowUsable(tmp) && isWindowVisible(tmp)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
retList.append(tmp);
|
2009-04-15 19:31:20 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return retList;
|
|
|
|
}
|
2009-04-15 19:31:20 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect SlideBackEffect::getModalGroupGeometry(EffectWindow *w)
|
|
|
|
{
|
2009-09-14 14:22:31 +00:00
|
|
|
QRect modalGroupGeometry = w->geometry();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (w->isModal()) {
|
|
|
|
foreach (EffectWindow * modalWindow, w->mainWindows()) {
|
|
|
|
modalGroupGeometry = modalGroupGeometry.united(getModalGroupGeometry(modalWindow));
|
2009-09-14 14:22:31 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return modalGroupGeometry;
|
|
|
|
}
|
2009-09-14 14:22:31 +00:00
|
|
|
|
2011-08-27 09:21:31 +00:00
|
|
|
bool SlideBackEffect::isActive() const
|
|
|
|
{
|
|
|
|
return motionManager.managingWindows();
|
|
|
|
}
|
|
|
|
|
2009-04-15 19:31:20 +00:00
|
|
|
} //Namespace
|