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
|
[effects/slidingpopups] Don't crash when sliding virtual desktops
Summary:
If you switch virtual desktops while krunner is sliding in, then
depending on whether your distro strips assert statements away,
KWin can crash.
The reason why it crashes is the sliding popups effect tries to unref
deleted windows that it hasn't referenced before (if there is an active
full screen effect, then popups won't be slided out, which in its turn
means that we won't reference deleted windows). So, in the end, the
refcount of those windows can be -1. That triggers an assert statement
in the destructor of the Deleted class, which checks whether the
refcount is equal to 0.
Popups are not slided while there is an active full screen effect because
we don't know what the full screen effect does.
This patch adjusts the sliding popups effect so it stops all active
animations when user switches virtual desktops or when a full screen
effect kicks in. We need to do that so the effect won't try to
unreference windows in postPaintWindow.
Visually, it doesn't look quite nice, but for now that's good enough.
A proper fix would be more complex: we would need to make sure that
full screen effects ignore sliding popups (and also maybe docks) and
perform some input redirection.
BUG: 400170
FIXED-IN: 5.14.4
Test Plan: I'm not able anymore to reproduce bug 400170.
Reviewers: #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: davidedmundson, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16731
2018-11-05 12:59:42 +00:00
|
|
|
Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
|
2009-07-23 19:06:50 +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/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
2009-12-17 20:50:07 +00:00
|
|
|
#ifndef KWIN_SLIDINGPOPUPS_H
|
|
|
|
#define KWIN_SLIDINGPOPUPS_H
|
2009-07-23 19:06:50 +00:00
|
|
|
|
|
|
|
// Include with base class for effects.
|
|
|
|
#include <kwineffects.h>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2018-08-14 10:10:04 +00:00
|
|
|
class SlidingPopupsEffect : public Effect
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-02-25 21:06:02 +00:00
|
|
|
Q_OBJECT
|
2018-07-15 07:57:35 +00:00
|
|
|
Q_PROPERTY(int slideInDuration READ slideInDuration)
|
|
|
|
Q_PROPERTY(int slideOutDuration READ slideOutDuration)
|
2018-08-14 10:10:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
|
|
|
SlidingPopupsEffect();
|
2018-07-26 18:40:46 +00:00
|
|
|
~SlidingPopupsEffect() override;
|
2018-07-13 08:01:29 +00:00
|
|
|
|
2018-08-14 10:10:04 +00:00
|
|
|
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override;
|
|
|
|
void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override;
|
|
|
|
void postPaintWindow(EffectWindow *w) override;
|
2018-07-26 18:40:46 +00:00
|
|
|
void reconfigure(ReconfigureFlags flags) override;
|
|
|
|
bool isActive() const override;
|
2014-03-24 10:50:09 +00:00
|
|
|
|
|
|
|
int requestedEffectChainPosition() const override {
|
|
|
|
return 40;
|
|
|
|
}
|
2017-11-23 09:34:06 +00:00
|
|
|
|
|
|
|
static bool supported();
|
|
|
|
|
2018-07-15 07:57:35 +00:00
|
|
|
int slideInDuration() const;
|
|
|
|
int slideOutDuration() const;
|
|
|
|
|
2018-08-14 09:51:56 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void slotWindowAdded(EffectWindow *w);
|
|
|
|
void slotWindowDeleted(EffectWindow *w);
|
2018-08-15 14:30:02 +00:00
|
|
|
void slotPropertyNotify(EffectWindow *w, long atom);
|
2018-08-14 10:10:04 +00:00
|
|
|
void slotWaylandSlideOnShowChanged(EffectWindow *w);
|
2018-07-13 12:08:31 +00:00
|
|
|
|
|
|
|
void slideIn(EffectWindow *w);
|
|
|
|
void slideOut(EffectWindow *w);
|
[effects/slidingpopups] Don't crash when sliding virtual desktops
Summary:
If you switch virtual desktops while krunner is sliding in, then
depending on whether your distro strips assert statements away,
KWin can crash.
The reason why it crashes is the sliding popups effect tries to unref
deleted windows that it hasn't referenced before (if there is an active
full screen effect, then popups won't be slided out, which in its turn
means that we won't reference deleted windows). So, in the end, the
refcount of those windows can be -1. That triggers an assert statement
in the destructor of the Deleted class, which checks whether the
refcount is equal to 0.
Popups are not slided while there is an active full screen effect because
we don't know what the full screen effect does.
This patch adjusts the sliding popups effect so it stops all active
animations when user switches virtual desktops or when a full screen
effect kicks in. We need to do that so the effect won't try to
unreference windows in postPaintWindow.
Visually, it doesn't look quite nice, but for now that's good enough.
A proper fix would be more complex: we would need to make sure that
full screen effects ignore sliding popups (and also maybe docks) and
perform some input redirection.
BUG: 400170
FIXED-IN: 5.14.4
Test Plan: I'm not able anymore to reproduce bug 400170.
Reviewers: #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: davidedmundson, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16731
2018-11-05 12:59:42 +00:00
|
|
|
void stopAnimations();
|
2018-07-13 12:08:31 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
2015-09-14 14:39:39 +00:00
|
|
|
void setupAnimData(EffectWindow *w);
|
|
|
|
|
2018-08-14 10:10:04 +00:00
|
|
|
long m_atom;
|
2014-02-20 13:10:18 +00:00
|
|
|
|
2018-08-14 10:10:04 +00:00
|
|
|
int m_slideLength;
|
2018-07-15 07:57:35 +00:00
|
|
|
std::chrono::milliseconds m_slideInDuration;
|
|
|
|
std::chrono::milliseconds m_slideOutDuration;
|
2018-07-13 12:08:31 +00:00
|
|
|
|
|
|
|
enum class AnimationKind {
|
|
|
|
In,
|
|
|
|
Out
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Animation {
|
|
|
|
AnimationKind kind;
|
|
|
|
TimeLine timeLine;
|
|
|
|
};
|
[effects/slidingpopups] Don't crash when sliding virtual desktops
Summary:
If you switch virtual desktops while krunner is sliding in, then
depending on whether your distro strips assert statements away,
KWin can crash.
The reason why it crashes is the sliding popups effect tries to unref
deleted windows that it hasn't referenced before (if there is an active
full screen effect, then popups won't be slided out, which in its turn
means that we won't reference deleted windows). So, in the end, the
refcount of those windows can be -1. That triggers an assert statement
in the destructor of the Deleted class, which checks whether the
refcount is equal to 0.
Popups are not slided while there is an active full screen effect because
we don't know what the full screen effect does.
This patch adjusts the sliding popups effect so it stops all active
animations when user switches virtual desktops or when a full screen
effect kicks in. We need to do that so the effect won't try to
unreference windows in postPaintWindow.
Visually, it doesn't look quite nice, but for now that's good enough.
A proper fix would be more complex: we would need to make sure that
full screen effects ignore sliding popups (and also maybe docks) and
perform some input redirection.
BUG: 400170
FIXED-IN: 5.14.4
Test Plan: I'm not able anymore to reproduce bug 400170.
Reviewers: #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: davidedmundson, graesslin, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D16731
2018-11-05 12:59:42 +00:00
|
|
|
QHash<EffectWindow *, Animation> m_animations;
|
2018-07-15 07:57:35 +00:00
|
|
|
|
|
|
|
enum class Location {
|
|
|
|
Left,
|
|
|
|
Top,
|
|
|
|
Right,
|
|
|
|
Bottom
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AnimationData {
|
|
|
|
int offset;
|
|
|
|
Location location;
|
|
|
|
std::chrono::milliseconds slideInDuration;
|
|
|
|
std::chrono::milliseconds slideOutDuration;
|
|
|
|
int slideLength;
|
|
|
|
};
|
|
|
|
QHash<const EffectWindow*, AnimationData> m_animationsData;
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
2009-07-23 19:06:50 +00:00
|
|
|
|
2018-07-15 07:57:35 +00:00
|
|
|
inline int SlidingPopupsEffect::slideInDuration() const
|
|
|
|
{
|
|
|
|
return m_slideInDuration.count();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int SlidingPopupsEffect::slideOutDuration() const
|
|
|
|
{
|
|
|
|
return m_slideOutDuration.count();
|
|
|
|
}
|
|
|
|
|
2009-07-23 19:06:50 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|