summaryrefslogtreecommitdiff
blob: 4e480a06be8e2dfd1f6a7757e03b2306effaca67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
From ad28da84e78c7eb7ff1e608c4819707b2142daea Mon Sep 17 00:00:00 2001
From: Vlad Zagorodniy <vladzzag@gmail.com>
Date: Mon, 5 Nov 2018 14:59:42 +0200
Subject: [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
---
 effects/slidingpopups/slidingpopups.cpp | 22 ++++++++++++++++++++++
 effects/slidingpopups/slidingpopups.h   |  6 +++---
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/effects/slidingpopups/slidingpopups.cpp b/effects/slidingpopups/slidingpopups.cpp
index a104a5c..066b2a3 100644
--- a/effects/slidingpopups/slidingpopups.cpp
+++ b/effects/slidingpopups/slidingpopups.cpp
@@ -3,6 +3,7 @@
  This file is part of the KDE project.
 
 Copyright (C) 2009 Marco Martin notmart@gmail.com
+Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
 
 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
@@ -53,6 +54,11 @@ SlidingPopupsEffect::SlidingPopupsEffect()
             m_atom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_SLIDE"), this);
         }
     );
+    connect(effects, qOverload<int, int, EffectWindow *>(&EffectsHandler::desktopChanged),
+            this, &SlidingPopupsEffect::stopAnimations);
+    connect(effects, &EffectsHandler::activeFullScreenEffectChanged,
+            this, &SlidingPopupsEffect::stopAnimations);
+
     reconfigure(ReconfigureAll);
 }
 
@@ -434,6 +440,22 @@ void SlidingPopupsEffect::slideOut(EffectWindow *w)
     w->addRepaintFull();
 }
 
+void SlidingPopupsEffect::stopAnimations()
+{
+    for (auto it = m_animations.constBegin(); it != m_animations.constEnd(); ++it) {
+        EffectWindow *w = it.key();
+
+        if (w->isDeleted()) {
+            w->unrefWindow();
+        } else {
+            w->setData(WindowForceBackgroundContrastRole, QVariant());
+            w->setData(WindowForceBlurRole, QVariant());
+        }
+    }
+
+    m_animations.clear();
+}
+
 bool SlidingPopupsEffect::isActive() const
 {
     return !m_animations.isEmpty();
diff --git a/effects/slidingpopups/slidingpopups.h b/effects/slidingpopups/slidingpopups.h
index 821640a..32e8fb5 100644
--- a/effects/slidingpopups/slidingpopups.h
+++ b/effects/slidingpopups/slidingpopups.h
@@ -3,6 +3,7 @@
  This file is part of the KDE project.
 
 Copyright (C) 2009 Marco Martin notmart@gmail.com
+Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com>
 
 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
@@ -49,8 +50,6 @@ public:
 
     static bool supported();
 
-    // TODO react also on virtual desktop changes
-
     int slideInDuration() const;
     int slideOutDuration() const;
 
@@ -62,6 +61,7 @@ private Q_SLOTS:
 
     void slideIn(EffectWindow *w);
     void slideOut(EffectWindow *w);
+    void stopAnimations();
 
 private:
     void setupAnimData(EffectWindow *w);
@@ -81,7 +81,7 @@ private:
         AnimationKind kind;
         TimeLine timeLine;
     };
-    QHash<const EffectWindow*, Animation> m_animations;
+    QHash<EffectWindow *, Animation> m_animations;
 
     enum class Location {
         Left,
-- 
cgit v0.11.2