Merge lp:~compiz-team/compiz/fix-multimonitor-unredirect into lp:compiz/0.9.8

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: 3380
Merged at revision: 3377
Proposed branch: lp:~compiz-team/compiz/fix-multimonitor-unredirect
Merge into: lp:compiz/0.9.8
Diff against target: 157 lines (+52/-21)
4 files modified
plugins/opengl/src/fsregion/fsregion.cpp (+11/-1)
plugins/opengl/src/fsregion/fsregion.h (+2/-0)
plugins/opengl/src/fsregion/tests/test-fsregion.cpp (+10/-0)
plugins/opengl/src/paint.cpp (+29/-20)
To merge this branch: bzr merge lp:~compiz-team/compiz/fix-multimonitor-unredirect
Reviewer Review Type Date Requested Status
Sam Spilsbury Approve
Daniel van Vugt Approve
jenkins continuous-integration Pending
Review via email: mp+124855@code.launchpad.net

Commit message

Fix flickering and performance problems with using Unredirect Fullscreen
Windows with multiple monitors.
(LP: #1050749) (LP: #1051885)

Written by smspillaz. Simplified by vanvugt.

Description of the change

Fix flickering and performance problems with using Unredirect Fullscreen
Windows with multiple monitors.
(LP: #1050749) (LP: #1051885)

Written by smspillaz. Simplified by vanvugt.

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Tested, approved.

review: Approve
Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/opengl/src/fsregion/fsregion.cpp'
2--- plugins/opengl/src/fsregion/fsregion.cpp 2012-09-06 08:01:54 +0000
3+++ plugins/opengl/src/fsregion/fsregion.cpp 2012-09-18 08:20:25 +0000
4@@ -30,7 +30,8 @@
5
6 FullscreenRegion::FullscreenRegion (const CompRect &rect) :
7 covered (false),
8- untouched (rect)
9+ untouched (rect),
10+ orig (untouched)
11 {
12 }
13
14@@ -50,5 +51,14 @@
15 return fullscreen;
16 }
17
18+bool
19+FullscreenRegion::allowRedirection (const CompRegion &region)
20+{
21+ /* Don't allow existing unredirected windows that cover this
22+ * region to be redirected again as they were probably unredirected
23+ * on another monitor */
24+ return region.intersects (orig);
25+}
26+
27 } // namespace opengl
28 } // namespace compiz
29
30=== modified file 'plugins/opengl/src/fsregion/fsregion.h'
31--- plugins/opengl/src/fsregion/fsregion.h 2012-09-06 08:01:54 +0000
32+++ plugins/opengl/src/fsregion/fsregion.h 2012-09-18 08:20:25 +0000
33@@ -46,10 +46,12 @@
34
35 // isCoveredBy is called for windows from TOP to BOTTOM
36 bool isCoveredBy (const CompRegion &region, WinFlags flags = 0);
37+ bool allowRedirection (const CompRegion &region);
38
39 private:
40 bool covered;
41 CompRegion untouched;
42+ CompRegion orig;
43 };
44
45 } // namespace opengl
46
47=== modified file 'plugins/opengl/src/fsregion/tests/test-fsregion.cpp'
48--- plugins/opengl/src/fsregion/tests/test-fsregion.cpp 2012-09-06 08:01:54 +0000
49+++ plugins/opengl/src/fsregion/tests/test-fsregion.cpp 2012-09-18 08:20:25 +0000
50@@ -137,4 +137,14 @@
51 FullscreenRegion::Desktop));
52 }
53
54+TEST (OpenGLFullscreenRegion, KeepUnredirectedStateIfNotOnMonitor)
55+{
56+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
57+ CompRegion window (1025, 0, 1024, 768);
58+ /* Eg, not covering the monitor, should be redirected */
59+ EXPECT_FALSE (monitor.isCoveredBy (window));
60+ /* Don't allow the redirection however, because we weren't
61+ * covering the monitor at all. */
62+ EXPECT_FALSE (monitor.allowRedirection (window));
63+}
64
65
66=== modified file 'plugins/opengl/src/paint.cpp'
67--- plugins/opengl/src/paint.cpp 2012-09-06 09:55:05 +0000
68+++ plugins/opengl/src/paint.cpp 2012-09-18 08:20:25 +0000
69@@ -27,6 +27,7 @@
70
71 #include "privates.h"
72
73+#include <set>
74 #include <stdlib.h>
75 #include <string.h>
76 #include <math.h>
77@@ -245,11 +246,11 @@
78 CompWindow *w;
79 GLWindow *gw;
80 int windowMask, odMask;
81- CompWindow *fullscreenWindow = NULL;
82 bool status, unredirectFS;
83 bool withOffset = false;
84 GLMatrix vTransform;
85 CompPoint offXY;
86+ std::set<CompWindow*> unredirected;
87
88 CompWindowList pl;
89 CompWindowList::reverse_iterator rit;
90@@ -350,32 +351,40 @@
91 * beneath them and so neither should be unredirected in that case.
92 */
93 if (unredirectFS &&
94- !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
95- fs.isCoveredBy (w->region (), flags))
96+ !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
97+ fs.isCoveredBy (w->region (), flags))
98 {
99- fullscreenWindow = w;
100+ unredirected.insert (w);
101 }
102 else
103 {
104- CompositeWindow *cw = CompositeWindow::get (w);
105- if (!cw->redirected ())
106- {
107- // 1. GLWindow::release to force gw->priv->needsRebind
108- gw->release ();
109-
110- // 2. GLWindow::bind, which redirects the window,
111- // rebinds the pixmap, and then rebinds the pixmap
112- // to a texture.
113- gw->bind ();
114-
115- // 3. Your window is now redirected again with the
116- // latest pixmap contents.
117- }
118+ CompositeWindow *cw = CompositeWindow::get (w);
119+ if (!cw->redirected ())
120+ {
121+ if (fs.allowRedirection (w->region ()))
122+ {
123+ // 1. GLWindow::release to force gw->priv->needsRebind
124+ gw->release ();
125+
126+ // 2. GLWindow::bind, which redirects the window,
127+ // rebinds the pixmap, and then rebinds the pixmap
128+ // to a texture.
129+ gw->bind ();
130+
131+ // 3. Your window is now redirected again with the
132+ // latest pixmap contents.
133+ }
134+ else
135+ {
136+ unredirected.insert (w);
137+ }
138+ }
139 }
140 }
141 }
142
143- if (fullscreenWindow)
144+ /* Unredirect any redirected fullscreen windows */
145+ foreach (CompWindow *fullscreenWindow, unredirected)
146 CompositeWindow::get (fullscreenWindow)->unredirect ();
147
148 if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
149@@ -389,7 +398,7 @@
150 if (w->destroyed ())
151 continue;
152
153- if (w == fullscreenWindow)
154+ if (unredirected.find (w) != unredirected.end ())
155 continue;
156
157 if (!w->shaded ())

Subscribers

People subscribed via source and target branches