Merge lp:~vanvugt/compiz-core/backport-unredirection-fixes-0.9.7 into lp:compiz-core

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: 3133
Merged at revision: 3124
Proposed branch: lp:~vanvugt/compiz-core/backport-unredirection-fixes-0.9.7
Merge into: lp:compiz-core
Diff against target: 579 lines (+445/-18)
8 files modified
plugins/opengl/CMakeLists.txt (+4/-2)
plugins/opengl/src/fsregion/CMakeLists.txt (+7/-0)
plugins/opengl/src/fsregion/fsregion.cpp (+64/-0)
plugins/opengl/src/fsregion/fsregion.h (+58/-0)
plugins/opengl/src/fsregion/tests/CMakeLists.txt (+10/-0)
plugins/opengl/src/fsregion/tests/test-fsregion.cpp (+160/-0)
plugins/opengl/src/paint.cpp (+45/-16)
tests/manual/Unredirect.txt (+97/-0)
To merge this branch: bzr merge lp:~vanvugt/compiz-core/backport-unredirection-fixes-0.9.7
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Sam Spilsbury Approve
Review via email: mp+133883@code.launchpad.net

Commit message

Backport all the fixes from quantal required to support Unredirect
Fullscreen Windows mode reliably.
(LP: #980663) (LP: #1053902) (LP: #1041047) (LP: #1041066)
(LP: #1046661) (LP: #1047168) (LP: #1050749) (LP: #1051885)

Description of the change

This proposal is required by:
https://blueprints.launchpad.net/ubuntu/+spec/desktop-r-gaming-platform-unity-performance

Although, precise still has driver bugs so it's not turned on by default...
https://bugs.launchpad.net/ubuntu?field.tag=unredirect

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

Ping

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

This can be cleaned up slightly:

168 +include_directories (${GTEST_INCLUDE_DIRS} ..)
169 +set (exe "compiz_opengl_test_fsregion")
170 +add_executable (${exe} test-fsregion.cpp)
171 +target_link_libraries (${exe}
172 + compiz_opengl_fsregion
173 + compiz_core
174 + ${GTEST_BOTH_LIBRARIES}
175 +)
176 +#compiz_discover_tests(${exe} COVERAGE compiz_opengl_fsregion)
177 +gtest_add_tests (compiz_test_decor_clip_groups "" test-fsregion.cpp)

instead of ${exe} use compiz_opengl_test_fsregion.

Remove the commented out bit.

Other than that:

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hmm, that looks like a copy/paste error:
176 +#compiz_discover_tests(${exe} COVERAGE compiz_opengl_fsregion)
177 +gtest_add_tests (compiz_test_decor_clip_groups "" test-fsregion.cpp)

review: Needs Fixing
3132. By Daniel van Vugt

Fix typos naming the wrong test.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Fixed typos naming the wrong test. I noticed that 'make test' never reaches it though, despite the fact that the test is a real target that gets built and is in Makefile. Not yet sure why 'make test' doesn't know it's a test.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Wed, Nov 14, 2012 at 6:36 PM, Daniel van Vugt
<email address hidden> wrote:
> Fixed typos naming the wrong test. I noticed that 'make test' never reaches it though, despite the fact that the test is a real target that gets built and is in Makefile. Not yet sure why 'make test' doesn't know it's a test.

It is because gtest_discover_tests does not know how to handle
whitespace between the TEST and the ()

You need to do

TEST()

and not

TEST ()

(compiz_discover_tests was to solve this problem and many more, but
its obviously not in compiz-core)

> --
> https://code.launchpad.net/~vanvugt/compiz-core/backport-unredirection-fixes-0.9.7/+merge/133883
> You are reviewing the proposed merge of lp:~vanvugt/compiz-core/backport-unredirection-fixes-0.9.7 into lp:compiz-core.

--
Sam Spilsbury

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Don't know. The test cases pass if run directly:
   build/plugins/opengl/src/fsregion/tests/compiz_opengl_test_fsregion
but 'make test' doesn't find it. Not a blocker right now.

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

Well, you can fix it fairly easily. Just remove the whitespace :)

Might as well, it will take thirty seconds to do.

On Wed, Nov 14, 2012 at 7:06 PM, Daniel van Vugt
<email address hidden> wrote:
> Review: Approve
>
> Don't know. The test cases pass if run directly:
> build/plugins/opengl/src/fsregion/tests/compiz_opengl_test_fsregion
> but 'make test' doesn't find it. Not a blocker right now.
> --
> https://code.launchpad.net/~vanvugt/compiz-core/backport-unredirection-fixes-0.9.7/+merge/133883
> You are reviewing the proposed merge of lp:~vanvugt/compiz-core/backport-unredirection-fixes-0.9.7 into lp:compiz-core.

--
Sam Spilsbury

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

(might as well remove the whitespace)

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hmm, yes that makes sense. Especially since macros require no space in their definition. Because the preprocessor has a much smaller brain than a compiler and macros are quite different to functions anyway. Though I heard cpp was Turing complete :)

Revision history for this message
Daniel van Vugt (vanvugt) :
review: Needs Fixing
3133. By Daniel van Vugt

test-fsregion.cpp: Remove space in "TEST (" syntax so that gtest_add_tests
can parse them correctly :P

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

OK, the tests now run. And I'm a little bit sad about having to introduce potential future conflicts to do so.

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

Well, gtest_add_tests is a sed script, and the script requires a that
there be no space between TEST_F and TEST and the ().

It also does not support TEST_P or TYPED_TEST :(

On Thu, Nov 15, 2012 at 9:43 AM, Daniel van Vugt
<email address hidden> wrote:
> Hmm, yes that makes sense. Especially since macros require no space in their definition. Because the preprocessor has a much smaller brain than a compiler and macros are quite different to functions anyway. Though I heard cpp was Turing complete :)
> --
> https://code.launchpad.net/~vanvugt/compiz-core/backport-unredirection-fixes-0.9.7/+merge/133883
> You are reviewing the proposed merge of lp:~vanvugt/compiz-core/backport-unredirection-fixes-0.9.7 into lp:compiz-core.

--
Sam Spilsbury

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/opengl/CMakeLists.txt'
2--- plugins/opengl/CMakeLists.txt 2009-03-15 05:09:18 +0000
3+++ plugins/opengl/CMakeLists.txt 2012-11-15 02:07:24 +0000
4@@ -2,7 +2,9 @@
5
6 include (CompizPlugin)
7
8+add_subdirectory (src/fsregion)
9+
10 find_package (OpenGL)
11 if (OPENGL_FOUND)
12- compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
13-endif ()
14\ No newline at end of file
15+ compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} compiz_opengl_fsregion INCDIRS ${OPENGL_INCLUDE_DIR})
16+endif ()
17
18=== added directory 'plugins/opengl/src/fsregion'
19=== added file 'plugins/opengl/src/fsregion/CMakeLists.txt'
20--- plugins/opengl/src/fsregion/CMakeLists.txt 1970-01-01 00:00:00 +0000
21+++ plugins/opengl/src/fsregion/CMakeLists.txt 2012-11-15 02:07:24 +0000
22@@ -0,0 +1,7 @@
23+if (COMPIZ_BUILD_TESTING)
24+add_subdirectory (tests)
25+endif ()
26+
27+add_library (compiz_opengl_fsregion STATIC fsregion.cpp)
28+target_link_libraries (compiz_opengl_fsregion compiz_core)
29+
30
31=== added file 'plugins/opengl/src/fsregion/fsregion.cpp'
32--- plugins/opengl/src/fsregion/fsregion.cpp 1970-01-01 00:00:00 +0000
33+++ plugins/opengl/src/fsregion/fsregion.cpp 2012-11-15 02:07:24 +0000
34@@ -0,0 +1,64 @@
35+/*
36+ * Compiz opengl plugin, FullscreenRegion class
37+ *
38+ * Copyright (c) 2012 Canonical Ltd.
39+ * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
40+ *
41+ * Permission is hereby granted, free of charge, to any person obtaining a
42+ * copy of this software and associated documentation files (the "Software"),
43+ * to deal in the Software without restriction, including without limitation
44+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
45+ * and/or sell copies of the Software, and to permit persons to whom the
46+ * Software is furnished to do so, subject to the following conditions:
47+ *
48+ * The above copyright notice and this permission notice shall be included in
49+ * all copies or substantial portions of the Software.
50+ *
51+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
54+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
56+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
57+ * DEALINGS IN THE SOFTWARE.
58+ */
59+
60+#include "fsregion.h"
61+
62+namespace compiz {
63+namespace opengl {
64+
65+FullscreenRegion::FullscreenRegion (const CompRect &rect) :
66+ untouched (rect),
67+ orig (untouched)
68+{
69+}
70+
71+bool
72+FullscreenRegion::isCoveredBy (const CompRegion &region, WinFlags flags)
73+{
74+ bool fullscreen = false;
75+
76+ if (!(flags & (Desktop | Alpha)) &&
77+ region == untouched &&
78+ region == orig)
79+ {
80+ fullscreen = true;
81+ }
82+
83+ untouched -= region;
84+
85+ return fullscreen;
86+}
87+
88+bool
89+FullscreenRegion::allowRedirection (const CompRegion &region)
90+{
91+ /* Don't allow existing unredirected windows that cover this
92+ * region to be redirected again as they were probably unredirected
93+ * on another monitor */
94+ return region.intersects (orig);
95+}
96+
97+} // namespace opengl
98+} // namespace compiz
99
100=== added file 'plugins/opengl/src/fsregion/fsregion.h'
101--- plugins/opengl/src/fsregion/fsregion.h 1970-01-01 00:00:00 +0000
102+++ plugins/opengl/src/fsregion/fsregion.h 2012-11-15 02:07:24 +0000
103@@ -0,0 +1,58 @@
104+/*
105+ * Compiz opengl plugin, FullscreenRegion class
106+ *
107+ * Copyright (c) 2012 Canonical Ltd.
108+ * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
109+ *
110+ * Permission is hereby granted, free of charge, to any person obtaining a
111+ * copy of this software and associated documentation files (the "Software"),
112+ * to deal in the Software without restriction, including without limitation
113+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
114+ * and/or sell copies of the Software, and to permit persons to whom the
115+ * Software is furnished to do so, subject to the following conditions:
116+ *
117+ * The above copyright notice and this permission notice shall be included in
118+ * all copies or substantial portions of the Software.
119+ *
120+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
121+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
122+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
123+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
124+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
125+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
126+ * DEALINGS IN THE SOFTWARE.
127+ */
128+
129+#ifndef __COMPIZ_OPENGL_FSREGION_H
130+#define __COMPIZ_OPENGL_FSREGION_H
131+#include "core/rect.h"
132+#include "core/region.h"
133+
134+namespace compiz {
135+namespace opengl {
136+
137+class FullscreenRegion
138+{
139+public:
140+ typedef enum
141+ {
142+ Desktop = 1,
143+ Alpha = 2
144+ } WinFlag;
145+
146+ typedef unsigned int WinFlags;
147+
148+ FullscreenRegion (const CompRect &rect);
149+
150+ // isCoveredBy is called for windows from TOP to BOTTOM
151+ bool isCoveredBy (const CompRegion &region, WinFlags flags = 0);
152+ bool allowRedirection (const CompRegion &region);
153+
154+private:
155+ CompRegion untouched;
156+ CompRegion orig;
157+};
158+
159+} // namespace opengl
160+} // namespace compiz
161+#endif
162
163=== added directory 'plugins/opengl/src/fsregion/tests'
164=== added file 'plugins/opengl/src/fsregion/tests/CMakeLists.txt'
165--- plugins/opengl/src/fsregion/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
166+++ plugins/opengl/src/fsregion/tests/CMakeLists.txt 2012-11-15 02:07:24 +0000
167@@ -0,0 +1,10 @@
168+include_directories (${GTEST_INCLUDE_DIRS} ..)
169+set (exe "compiz_opengl_test_fsregion")
170+add_executable (${exe} test-fsregion.cpp)
171+target_link_libraries (${exe}
172+ compiz_opengl_fsregion
173+ compiz_core
174+ ${GTEST_BOTH_LIBRARIES}
175+)
176+gtest_add_tests (compiz_opengl_test_fsregion "" ${CMAKE_CURRENT_SOURCE_DIR}/test-fsregion.cpp)
177+
178
179=== added file 'plugins/opengl/src/fsregion/tests/test-fsregion.cpp'
180--- plugins/opengl/src/fsregion/tests/test-fsregion.cpp 1970-01-01 00:00:00 +0000
181+++ plugins/opengl/src/fsregion/tests/test-fsregion.cpp 2012-11-15 02:07:24 +0000
182@@ -0,0 +1,160 @@
183+/*
184+ * Compiz opengl plugin, FullscreenRegion class
185+ *
186+ * Copyright (c) 2012 Canonical Ltd.
187+ * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
188+ *
189+ * Permission is hereby granted, free of charge, to any person obtaining a
190+ * copy of this software and associated documentation files (the "Software"),
191+ * to deal in the Software without restriction, including without limitation
192+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
193+ * and/or sell copies of the Software, and to permit persons to whom the
194+ * Software is furnished to do so, subject to the following conditions:
195+ *
196+ * The above copyright notice and this permission notice shall be included in
197+ * all copies or substantial portions of the Software.
198+ *
199+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
200+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
201+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
202+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
203+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
204+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
205+ * DEALINGS IN THE SOFTWARE.
206+ */
207+
208+#include "gtest/gtest.h"
209+#include "fsregion.h"
210+
211+using namespace compiz::opengl;
212+
213+TEST(OpenGLFullscreenRegion, NoWindows)
214+{
215+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
216+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
217+ FullscreenRegion::Desktop));
218+}
219+
220+TEST(OpenGLFullscreenRegion, OneFullscreen)
221+{
222+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
223+ EXPECT_TRUE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
224+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
225+ FullscreenRegion::Desktop));
226+}
227+
228+TEST(OpenGLFullscreenRegion, FullscreenNoDesktop)
229+{
230+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
231+ EXPECT_TRUE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
232+}
233+
234+TEST(OpenGLFullscreenRegion, AlphaFullscreen)
235+{
236+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
237+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
238+ FullscreenRegion::Alpha));
239+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
240+ FullscreenRegion::Desktop));
241+}
242+
243+TEST(OpenGLFullscreenRegion, AlphaOverFullscreen)
244+{
245+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
246+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (50, 60, 70, 80),
247+ FullscreenRegion::Alpha));
248+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
249+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
250+ FullscreenRegion::Desktop));
251+}
252+
253+TEST(OpenGLFullscreenRegion, NormalWindows)
254+{
255+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
256+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
257+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (20, 20, 50, 20)));
258+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
259+ FullscreenRegion::Desktop));
260+}
261+
262+TEST(OpenGLFullscreenRegion, TwoFullscreen)
263+{
264+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
265+ EXPECT_TRUE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
266+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
267+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (20, 20, 50, 20)));
268+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
269+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
270+ FullscreenRegion::Desktop));
271+}
272+
273+TEST(OpenGLFullscreenRegion, Offscreen)
274+{
275+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
276+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (-100, -100, 1, 1)));
277+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (2000, 2000, 123, 456)));
278+ EXPECT_TRUE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
279+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
280+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (20, 20, 50, 20)));
281+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
282+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
283+ FullscreenRegion::Desktop));
284+}
285+
286+TEST(OpenGLFullscreenRegion, CancelFullscreen1)
287+{
288+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
289+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (500, 500, 345, 234)));
290+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
291+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
292+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (20, 20, 50, 20)));
293+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
294+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
295+ FullscreenRegion::Desktop));
296+}
297+
298+TEST(OpenGLFullscreenRegion, CancelFullscreen2)
299+{
300+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
301+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (-100, -100, 1, 1)));
302+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (2000, 2000, 123, 456)));
303+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (500, 500, 345, 234)));
304+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
305+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
306+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (20, 20, 50, 20)));
307+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
308+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
309+ FullscreenRegion::Desktop));
310+}
311+
312+TEST(OpenGLFullscreenRegion, Overflow)
313+{
314+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
315+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
316+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (-10, -10, 1044, 788)));
317+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
318+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
319+ FullscreenRegion::Desktop));
320+}
321+
322+TEST(OpenGLFullscreenRegion, KeepUnredirectedStateIfNotOnMonitor)
323+{
324+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
325+ CompRegion window (1025, 0, 1024, 768);
326+ /* Eg, not covering the monitor, should be redirected */
327+ EXPECT_FALSE (monitor.isCoveredBy (window));
328+ /* Don't allow the redirection however, because we weren't
329+ * covering the monitor at all. */
330+ EXPECT_FALSE (monitor.allowRedirection (window));
331+}
332+
333+TEST(OpenGLFullscreenRegion, MaximizedWithDocks) // LP: #1053902
334+{
335+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
336+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 24)));
337+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 24, 64, 744)));
338+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (64, 24, 960, 744)));
339+ EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
340+ FullscreenRegion::Desktop));
341+}
342+
343
344=== modified file 'plugins/opengl/src/paint.cpp'
345--- plugins/opengl/src/paint.cpp 2012-03-19 09:19:04 +0000
346+++ plugins/opengl/src/paint.cpp 2012-11-15 02:07:24 +0000
347@@ -24,7 +24,9 @@
348 */
349
350 #include "privates.h"
351+#include "fsregion/fsregion.h"
352
353+#include <set>
354 #include <stdlib.h>
355 #include <string.h>
356 #include <math.h>
357@@ -37,6 +39,8 @@
358
359 #define DEG2RAD (M_PI / 180.0f)
360
361+using namespace compiz::opengl;
362+
363 GLScreenPaintAttrib defaultScreenPaintAttrib = {
364 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -DEFAULT_Z_CAMERA
365 };
366@@ -210,12 +214,12 @@
367 CompRegion tmpRegion (region);
368 CompWindow *w;
369 GLWindow *gw;
370- int count, windowMask, odMask;
371- CompWindow *fullscreenWindow = NULL;
372+ int windowMask, odMask;
373 bool status, unredirectFS;
374 bool withOffset = false;
375 GLMatrix vTransform;
376 CompPoint offXY;
377+ std::set<CompWindow*> unredirected;
378
379 CompWindowList pl;
380 CompWindowList::reverse_iterator rit;
381@@ -226,12 +230,10 @@
382 if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
383 {
384 windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
385- count = 1;
386 }
387 else
388 {
389 windowMask = 0;
390- count = 0;
391 }
392
393 /*
394@@ -243,6 +245,8 @@
395
396 if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
397 {
398+ FullscreenRegion fs (*output);
399+
400 /* detect occlusions */
401 for (rit = pl.rbegin (); rit != pl.rend (); rit++)
402 {
403@@ -303,29 +307,54 @@
404 }
405 else
406 tmpRegion -= w->region ();
407+ }
408
409- /* unredirect top most fullscreen windows. */
410- if (count == 0 && unredirectFS)
411+ FullscreenRegion::WinFlags flags = 0;
412+ if (w->type () & CompWindowTypeDesktopMask)
413+ flags |= FullscreenRegion::Desktop;
414+ if (w->alpha ())
415+ flags |= FullscreenRegion::Alpha;
416+
417+ /*
418+ * Windows with alpha channels can partially occlude windows
419+ * beneath them and so neither should be unredirected in that case.
420+ */
421+ if (unredirectFS &&
422+ !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
423+ !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
424+ fs.isCoveredBy (w->region (), flags))
425+ {
426+ unredirected.insert (w);
427+ }
428+ else
429+ {
430+ CompositeWindow *cw = CompositeWindow::get (w);
431+ if (!cw->redirected ())
432 {
433- if (w->region () == screen->region () &&
434- tmpRegion.isEmpty ())
435+ if (fs.allowRedirection (w->region ()))
436 {
437- fullscreenWindow = w;
438+ // 1. GLWindow::release to force gw->priv->needsRebind
439+ gw->release ();
440+
441+ // 2. GLWindow::bind, which redirects the window,
442+ // rebinds the pixmap, and then rebinds the pixmap
443+ // to a texture.
444+ gw->bind ();
445+
446+ // 3. Your window is now redirected again with the
447+ // latest pixmap contents.
448 }
449 else
450 {
451- foreach (CompOutput &o, screen->outputDevs ())
452- if (w->region () == CompRegion (o))
453- fullscreenWindow = w;
454+ unredirected.insert (w);
455 }
456 }
457 }
458-
459- count++;
460 }
461 }
462
463- if (fullscreenWindow)
464+ /* Unredirect any redirected fullscreen windows */
465+ foreach (CompWindow *fullscreenWindow, unredirected)
466 CompositeWindow::get (fullscreenWindow)->unredirect ();
467
468 if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
469@@ -337,7 +366,7 @@
470 if (w->destroyed ())
471 continue;
472
473- if (w == fullscreenWindow)
474+ if (unredirected.find (w) != unredirected.end ())
475 continue;
476
477 if (!w->shaded ())
478
479=== added file 'tests/manual/Unredirect.txt'
480--- tests/manual/Unredirect.txt 1970-01-01 00:00:00 +0000
481+++ tests/manual/Unredirect.txt 2012-11-15 02:07:24 +0000
482@@ -0,0 +1,97 @@
483+WINDOW UNREDIRECTION TESTS
484+===========================
485+Daniel van Vugt <daniel.van.vugt@canonical.com>
486+
487+
488+Browser unredirect with context menus
489+-------------------------------------
490+Setup:
491+#. Install Chromium or Chrome browser.
492+
493+Actions:
494+#. Open Chrome/Chromium and hit F11 to go full screen.
495+#. Right click on the web page to open a context menu.
496+#. Left click on the web page to close the context menu.
497+#. Right click on the web page to open a context menu.
498+#. Left click on the web page to close the context menu.
499+#. Press F11 to exit from full screen.
500+
501+Expected Result:
502+ Every time you right-clicked, the context menu should be visible.
503+
504+
505+Video unredirect with window menu
506+---------------------------------
507+Setup:
508+#. Install mplayer.
509+#. Get a video file you can play in mplayer.
510+
511+Actions:
512+#. Open the video in mplayer.
513+#. Hit F to go fullscreen.
514+#. Hit Alt+Space to open the window menu.
515+#. Hit Escape to close the window menu.
516+#. Hit Alt+Space to open the window menu.
517+#. Hit Escape to close the window menu.
518+#. Hit Escape to close the video.
519+
520+Expected Result:
521+ Every time you hit Alt+Space the window menu should have appeared and the
522+ video should still be playing behind it.
523+
524+
525+Video unredirect with transformed screen
526+----------------------------------------
527+Setup:
528+#. Install mplayer.
529+#. Get a video file you can play in mplayer.
530+
531+Actions:
532+#. Open the video in mplayer.
533+#. Hit F to go fullscreen.
534+#. Trigger expo mode (Super+E or mouse to top-left corner)
535+#. Leave expo mode (click on the full screen video)
536+#. Trigger expo mode again.
537+#. Leave expo mode (click on the full screen video)
538+#. Hit Escape to close the video.
539+
540+Expected Result:
541+ Every time you triggered expo mode, expo mode should have become visible and
542+ you should see the video still playing in the expo view.
543+
544+
545+Unredirect cancelation by alpha windows on top (LP: #1046661)
546+-------------------------------------------------------------
547+Setup:
548+#. Install Chromium or Chrome browser.
549+
550+Actions:
551+#. Open a Chrome/Chromium window.
552+#. Open a gnome-terminal window (Ctrl+Alt+T)
553+#. Move the gnome-terminal to the centre of the screen, above the Chrome
554+ window.
555+#. Click on the Chrome window and make it fullscreen (F11).
556+#. Alt+Tab to the gnome-terminal window.
557+
558+Expected Result:
559+ The gnome-terminal window should be visible on top.
560+
561+
562+Unredirect cancelation by transformed windows (LP: #1047168)
563+-------------------------------------------------------------
564+Setup:
565+#. Install Chromium or Chrome browser.
566+#. Run ccsm and ensure the Scale plugin is loaded and "Initiate Window Picker"
567+ is bound to Shift+Alt+Up.
568+
569+Actions:
570+#. Open a Chrome/Chromium window.
571+#. Open a gnome-terminal window (Ctrl+Alt+T)
572+#. Move the gnome-terminal to the centre of the screen, above the Chrome
573+ window.
574+#. Click on the Chrome window and make it fullscreen (F11).
575+#. Hold Shift+Alt and tap Up to engage scale mode. Keep holding Shift+Alt
576+ for a few seconds.
577+
578+Expected Result:
579+ Windows get scaled and you can see both the Chrome and Terminal windows.

Subscribers

People subscribed via source and target branches