13#include "fallapartconfig.h"
15#include <QEasingCurve>
19Q_LOGGING_CATEGORY(KWIN_FALLAPART,
"kwin_effect_fallapart", QtWarningMsg)
21static const QSet<QString> s_blacklist{
23 QStringLiteral(
"spectacle spectacle"),
24 QStringLiteral(
"spectacle org.kde.spectacle"),
45 FallApartConfig::self()->read();
51 if (!windows.isEmpty()) {
59 auto animationIt = windows.find(w);
60 if (animationIt != windows.end() && isRealWindow(w)) {
62 if (animationIt->lastPresentTime.count()) {
63 time = (presentTime - animationIt->lastPresentTime).count();
65 animationIt->lastPresentTime = presentTime;
75 auto animationIt = windows.constFind(w);
76 if (animationIt != windows.constEnd() && isRealWindow(w)) {
77 QEasingCurve easing(QEasingCurve::InCubic);
78 const qreal t = easing.valueForProgress(animationIt->progress);
85 QPointF p1(quad[0].x(), quad[0].y());
87 if (p1.x() < w->
width() / 2) {
88 xdiff = -(w->
width() / 2 - p1.x()) / w->
width() * 100;
90 if (p1.x() > w->
width() / 2) {
91 xdiff = (p1.x() - w->
width() / 2) / w->
width() * 100;
94 if (p1.y() < w->
height() / 2) {
97 if (p1.y() > w->
height() / 2) {
100 double modif = t * 64;
102 xdiff += (rand() % 21 - 10);
103 ydiff += (rand() % 21 - 10);
107 quad[j].move(quad[j].x() + xdiff * modif, quad[j].y() + ydiff * modif);
110 QPointF center((quad[0].x() + quad[1].x() + quad[2].x() + quad[3].x()) / 4,
111 (quad[0].y() + quad[1].y() + quad[2].y() + quad[3].y()) / 4);
112 double adiff = (rand() % 720 - 360) / 360. * 2 * M_PI;
116 double x = quad[j].x() - center.x();
117 double y = quad[j].y() - center.y();
118 double angle = atan2(y, x);
119 angle += animationIt->progress * adiff;
120 double dist = sqrt(x * x + y * y);
121 x =
dist * cos(angle);
122 y =
dist * sin(angle);
123 quad[j].move(center.x() + x, center.y() + y);
133 for (
auto it = windows.begin(); it != windows.end();) {
134 if (it->progress < 1) {
138 it = windows.erase(it);
177 if (!isRealWindow(c)) {
187 if (e && e !=
this) {
205 if (w->
data(role).value<
void *>() ==
this) {
209 auto it = windows.find(w);
210 if (it != windows.end()) {
218 return !windows.isEmpty();
223#include "moc_fallapart.cpp"
Representation of a window used by/for Effect classes.
bool isNormalWindow() const
Q_SCRIPTABLE void setData(int role, const QVariant &data)
Q_SCRIPTABLE QVariant data(int role) const
bool isPopupWindow() const
bool animationsSupported() const
void windowClosed(KWin::EffectWindow *w)
void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime)
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime)
KSharedConfigPtr config() const
Q_SCRIPTABLE void addRepaintFull()
Effect * activeFullScreenEffect() const
void windowDataChanged(KWin::EffectWindow *w, int role)
void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override
bool isActive() const override
void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override
void apply(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads) override
void slotWindowClosed(KWin::EffectWindow *c)
void reconfigure(ReconfigureFlags) override
void postPaintScreen() override
void slotWindowDataChanged(KWin::EffectWindow *w, int role)
void unredirect(EffectWindow *window)
void redirect(EffectWindow *window)
Class representing one area of a window.
WindowQuadList makeGrid(int maxquadsize) const
qreal multiplyOpacity(qreal factor)
static double interpolate(double x, double y, double a)
static double animationTime(const KConfigGroup &cfg, const QString &key, int defaultTime)
@ PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS
EffectWindowDeletedRef deletedRef