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

Proposed by Daniel van Vugt on 2012-11-12
Status: Merged
Approved by: Daniel van Vugt on 2012-11-15
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 on 2012-11-15
Sam Spilsbury 2012-11-12 Approve on 2012-11-14
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.
Daniel van Vugt (vanvugt) wrote :

Ping

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
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 on 2012-11-14

Fix typos naming the wrong test.

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.

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

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
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

Sam Spilsbury (smspillaz) wrote :

(might as well remove the whitespace)

review: Approve
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 :)

Daniel van Vugt (vanvugt) :
review: Needs Fixing
3133. By Daniel van Vugt on 2012-11-15

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

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
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
=== modified file 'plugins/opengl/CMakeLists.txt'
--- plugins/opengl/CMakeLists.txt 2009-03-15 05:09:18 +0000
+++ plugins/opengl/CMakeLists.txt 2012-11-15 02:07:24 +0000
@@ -2,7 +2,9 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5add_subdirectory (src/fsregion)
6
5find_package (OpenGL)7find_package (OpenGL)
6if (OPENGL_FOUND)8if (OPENGL_FOUND)
7 compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR})
8endif ()
9\ No newline at end of file9\ No newline at end of file
10 compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} compiz_opengl_fsregion INCDIRS ${OPENGL_INCLUDE_DIR})
11endif ()
1012
=== added directory 'plugins/opengl/src/fsregion'
=== added file 'plugins/opengl/src/fsregion/CMakeLists.txt'
--- plugins/opengl/src/fsregion/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/fsregion/CMakeLists.txt 2012-11-15 02:07:24 +0000
@@ -0,0 +1,7 @@
1if (COMPIZ_BUILD_TESTING)
2add_subdirectory (tests)
3endif ()
4
5add_library (compiz_opengl_fsregion STATIC fsregion.cpp)
6target_link_libraries (compiz_opengl_fsregion compiz_core)
7
08
=== added file 'plugins/opengl/src/fsregion/fsregion.cpp'
--- plugins/opengl/src/fsregion/fsregion.cpp 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/fsregion/fsregion.cpp 2012-11-15 02:07:24 +0000
@@ -0,0 +1,64 @@
1/*
2 * Compiz opengl plugin, FullscreenRegion class
3 *
4 * Copyright (c) 2012 Canonical Ltd.
5 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25
26#include "fsregion.h"
27
28namespace compiz {
29namespace opengl {
30
31FullscreenRegion::FullscreenRegion (const CompRect &rect) :
32 untouched (rect),
33 orig (untouched)
34{
35}
36
37bool
38FullscreenRegion::isCoveredBy (const CompRegion &region, WinFlags flags)
39{
40 bool fullscreen = false;
41
42 if (!(flags & (Desktop | Alpha)) &&
43 region == untouched &&
44 region == orig)
45 {
46 fullscreen = true;
47 }
48
49 untouched -= region;
50
51 return fullscreen;
52}
53
54bool
55FullscreenRegion::allowRedirection (const CompRegion &region)
56{
57 /* Don't allow existing unredirected windows that cover this
58 * region to be redirected again as they were probably unredirected
59 * on another monitor */
60 return region.intersects (orig);
61}
62
63} // namespace opengl
64} // namespace compiz
065
=== added file 'plugins/opengl/src/fsregion/fsregion.h'
--- plugins/opengl/src/fsregion/fsregion.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/fsregion/fsregion.h 2012-11-15 02:07:24 +0000
@@ -0,0 +1,58 @@
1/*
2 * Compiz opengl plugin, FullscreenRegion class
3 *
4 * Copyright (c) 2012 Canonical Ltd.
5 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25
26#ifndef __COMPIZ_OPENGL_FSREGION_H
27#define __COMPIZ_OPENGL_FSREGION_H
28#include "core/rect.h"
29#include "core/region.h"
30
31namespace compiz {
32namespace opengl {
33
34class FullscreenRegion
35{
36public:
37 typedef enum
38 {
39 Desktop = 1,
40 Alpha = 2
41 } WinFlag;
42
43 typedef unsigned int WinFlags;
44
45 FullscreenRegion (const CompRect &rect);
46
47 // isCoveredBy is called for windows from TOP to BOTTOM
48 bool isCoveredBy (const CompRegion &region, WinFlags flags = 0);
49 bool allowRedirection (const CompRegion &region);
50
51private:
52 CompRegion untouched;
53 CompRegion orig;
54};
55
56} // namespace opengl
57} // namespace compiz
58#endif
059
=== added directory 'plugins/opengl/src/fsregion/tests'
=== added file 'plugins/opengl/src/fsregion/tests/CMakeLists.txt'
--- plugins/opengl/src/fsregion/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/fsregion/tests/CMakeLists.txt 2012-11-15 02:07:24 +0000
@@ -0,0 +1,10 @@
1include_directories (${GTEST_INCLUDE_DIRS} ..)
2set (exe "compiz_opengl_test_fsregion")
3add_executable (${exe} test-fsregion.cpp)
4target_link_libraries (${exe}
5 compiz_opengl_fsregion
6 compiz_core
7 ${GTEST_BOTH_LIBRARIES}
8)
9gtest_add_tests (compiz_opengl_test_fsregion "" ${CMAKE_CURRENT_SOURCE_DIR}/test-fsregion.cpp)
10
011
=== added file 'plugins/opengl/src/fsregion/tests/test-fsregion.cpp'
--- plugins/opengl/src/fsregion/tests/test-fsregion.cpp 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/fsregion/tests/test-fsregion.cpp 2012-11-15 02:07:24 +0000
@@ -0,0 +1,160 @@
1/*
2 * Compiz opengl plugin, FullscreenRegion class
3 *
4 * Copyright (c) 2012 Canonical Ltd.
5 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25
26#include "gtest/gtest.h"
27#include "fsregion.h"
28
29using namespace compiz::opengl;
30
31TEST(OpenGLFullscreenRegion, NoWindows)
32{
33 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
34 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
35 FullscreenRegion::Desktop));
36}
37
38TEST(OpenGLFullscreenRegion, OneFullscreen)
39{
40 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
41 EXPECT_TRUE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
42 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
43 FullscreenRegion::Desktop));
44}
45
46TEST(OpenGLFullscreenRegion, FullscreenNoDesktop)
47{
48 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
49 EXPECT_TRUE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
50}
51
52TEST(OpenGLFullscreenRegion, AlphaFullscreen)
53{
54 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
55 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
56 FullscreenRegion::Alpha));
57 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
58 FullscreenRegion::Desktop));
59}
60
61TEST(OpenGLFullscreenRegion, AlphaOverFullscreen)
62{
63 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
64 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (50, 60, 70, 80),
65 FullscreenRegion::Alpha));
66 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
67 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
68 FullscreenRegion::Desktop));
69}
70
71TEST(OpenGLFullscreenRegion, NormalWindows)
72{
73 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
74 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
75 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (20, 20, 50, 20)));
76 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
77 FullscreenRegion::Desktop));
78}
79
80TEST(OpenGLFullscreenRegion, TwoFullscreen)
81{
82 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
83 EXPECT_TRUE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
84 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
85 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (20, 20, 50, 20)));
86 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
87 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
88 FullscreenRegion::Desktop));
89}
90
91TEST(OpenGLFullscreenRegion, Offscreen)
92{
93 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
94 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (-100, -100, 1, 1)));
95 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (2000, 2000, 123, 456)));
96 EXPECT_TRUE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
97 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
98 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (20, 20, 50, 20)));
99 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
100 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
101 FullscreenRegion::Desktop));
102}
103
104TEST(OpenGLFullscreenRegion, CancelFullscreen1)
105{
106 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
107 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (500, 500, 345, 234)));
108 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
109 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
110 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (20, 20, 50, 20)));
111 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
112 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
113 FullscreenRegion::Desktop));
114}
115
116TEST(OpenGLFullscreenRegion, CancelFullscreen2)
117{
118 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
119 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (-100, -100, 1, 1)));
120 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (2000, 2000, 123, 456)));
121 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (500, 500, 345, 234)));
122 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
123 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
124 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (20, 20, 50, 20)));
125 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
126 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
127 FullscreenRegion::Desktop));
128}
129
130TEST(OpenGLFullscreenRegion, Overflow)
131{
132 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
133 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (10, 10, 40, 30)));
134 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (-10, -10, 1044, 788)));
135 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
136 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
137 FullscreenRegion::Desktop));
138}
139
140TEST(OpenGLFullscreenRegion, KeepUnredirectedStateIfNotOnMonitor)
141{
142 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
143 CompRegion window (1025, 0, 1024, 768);
144 /* Eg, not covering the monitor, should be redirected */
145 EXPECT_FALSE (monitor.isCoveredBy (window));
146 /* Don't allow the redirection however, because we weren't
147 * covering the monitor at all. */
148 EXPECT_FALSE (monitor.allowRedirection (window));
149}
150
151TEST(OpenGLFullscreenRegion, MaximizedWithDocks) // LP: #1053902
152{
153 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
154 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 24)));
155 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 24, 64, 744)));
156 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (64, 24, 960, 744)));
157 EXPECT_FALSE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768),
158 FullscreenRegion::Desktop));
159}
160
0161
=== modified file 'plugins/opengl/src/paint.cpp'
--- plugins/opengl/src/paint.cpp 2012-03-19 09:19:04 +0000
+++ plugins/opengl/src/paint.cpp 2012-11-15 02:07:24 +0000
@@ -24,7 +24,9 @@
24 */24 */
2525
26#include "privates.h"26#include "privates.h"
27#include "fsregion/fsregion.h"
2728
29#include <set>
28#include <stdlib.h>30#include <stdlib.h>
29#include <string.h>31#include <string.h>
30#include <math.h>32#include <math.h>
@@ -37,6 +39,8 @@
3739
38#define DEG2RAD (M_PI / 180.0f)40#define DEG2RAD (M_PI / 180.0f)
3941
42using namespace compiz::opengl;
43
40GLScreenPaintAttrib defaultScreenPaintAttrib = {44GLScreenPaintAttrib defaultScreenPaintAttrib = {
41 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -DEFAULT_Z_CAMERA45 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -DEFAULT_Z_CAMERA
42};46};
@@ -210,12 +214,12 @@
210 CompRegion tmpRegion (region);214 CompRegion tmpRegion (region);
211 CompWindow *w;215 CompWindow *w;
212 GLWindow *gw;216 GLWindow *gw;
213 int count, windowMask, odMask;217 int windowMask, odMask;
214 CompWindow *fullscreenWindow = NULL;
215 bool status, unredirectFS;218 bool status, unredirectFS;
216 bool withOffset = false;219 bool withOffset = false;
217 GLMatrix vTransform;220 GLMatrix vTransform;
218 CompPoint offXY;221 CompPoint offXY;
222 std::set<CompWindow*> unredirected;
219223
220 CompWindowList pl;224 CompWindowList pl;
221 CompWindowList::reverse_iterator rit;225 CompWindowList::reverse_iterator rit;
@@ -226,12 +230,10 @@
226 if (mask & PAINT_SCREEN_TRANSFORMED_MASK)230 if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
227 {231 {
228 windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;232 windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
229 count = 1;
230 }233 }
231 else234 else
232 {235 {
233 windowMask = 0;236 windowMask = 0;
234 count = 0;
235 }237 }
236238
237 /*239 /*
@@ -243,6 +245,8 @@
243245
244 if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))246 if (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK))
245 {247 {
248 FullscreenRegion fs (*output);
249
246 /* detect occlusions */250 /* detect occlusions */
247 for (rit = pl.rbegin (); rit != pl.rend (); rit++)251 for (rit = pl.rbegin (); rit != pl.rend (); rit++)
248 {252 {
@@ -303,29 +307,54 @@
303 }307 }
304 else308 else
305 tmpRegion -= w->region ();309 tmpRegion -= w->region ();
310 }
306311
307 /* unredirect top most fullscreen windows. */312 FullscreenRegion::WinFlags flags = 0;
308 if (count == 0 && unredirectFS)313 if (w->type () & CompWindowTypeDesktopMask)
314 flags |= FullscreenRegion::Desktop;
315 if (w->alpha ())
316 flags |= FullscreenRegion::Alpha;
317
318 /*
319 * Windows with alpha channels can partially occlude windows
320 * beneath them and so neither should be unredirected in that case.
321 */
322 if (unredirectFS &&
323 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
324 !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
325 fs.isCoveredBy (w->region (), flags))
326 {
327 unredirected.insert (w);
328 }
329 else
330 {
331 CompositeWindow *cw = CompositeWindow::get (w);
332 if (!cw->redirected ())
309 {333 {
310 if (w->region () == screen->region () &&334 if (fs.allowRedirection (w->region ()))
311 tmpRegion.isEmpty ())
312 {335 {
313 fullscreenWindow = w;336 // 1. GLWindow::release to force gw->priv->needsRebind
337 gw->release ();
338
339 // 2. GLWindow::bind, which redirects the window,
340 // rebinds the pixmap, and then rebinds the pixmap
341 // to a texture.
342 gw->bind ();
343
344 // 3. Your window is now redirected again with the
345 // latest pixmap contents.
314 }346 }
315 else347 else
316 {348 {
317 foreach (CompOutput &o, screen->outputDevs ())349 unredirected.insert (w);
318 if (w->region () == CompRegion (o))
319 fullscreenWindow = w;
320 }350 }
321 }351 }
322 }352 }
323
324 count++;
325 }353 }
326 }354 }
327355
328 if (fullscreenWindow)356 /* Unredirect any redirected fullscreen windows */
357 foreach (CompWindow *fullscreenWindow, unredirected)
329 CompositeWindow::get (fullscreenWindow)->unredirect ();358 CompositeWindow::get (fullscreenWindow)->unredirect ();
330359
331 if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))360 if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
@@ -337,7 +366,7 @@
337 if (w->destroyed ())366 if (w->destroyed ())
338 continue;367 continue;
339368
340 if (w == fullscreenWindow)369 if (unredirected.find (w) != unredirected.end ())
341 continue;370 continue;
342371
343 if (!w->shaded ())372 if (!w->shaded ())
344373
=== added file 'tests/manual/Unredirect.txt'
--- tests/manual/Unredirect.txt 1970-01-01 00:00:00 +0000
+++ tests/manual/Unredirect.txt 2012-11-15 02:07:24 +0000
@@ -0,0 +1,97 @@
1WINDOW UNREDIRECTION TESTS
2===========================
3Daniel van Vugt <daniel.van.vugt@canonical.com>
4
5
6Browser unredirect with context menus
7-------------------------------------
8Setup:
9#. Install Chromium or Chrome browser.
10
11Actions:
12#. Open Chrome/Chromium and hit F11 to go full screen.
13#. Right click on the web page to open a context menu.
14#. Left click on the web page to close the context menu.
15#. Right click on the web page to open a context menu.
16#. Left click on the web page to close the context menu.
17#. Press F11 to exit from full screen.
18
19Expected Result:
20 Every time you right-clicked, the context menu should be visible.
21
22
23Video unredirect with window menu
24---------------------------------
25Setup:
26#. Install mplayer.
27#. Get a video file you can play in mplayer.
28
29Actions:
30#. Open the video in mplayer.
31#. Hit F to go fullscreen.
32#. Hit Alt+Space to open the window menu.
33#. Hit Escape to close the window menu.
34#. Hit Alt+Space to open the window menu.
35#. Hit Escape to close the window menu.
36#. Hit Escape to close the video.
37
38Expected Result:
39 Every time you hit Alt+Space the window menu should have appeared and the
40 video should still be playing behind it.
41
42
43Video unredirect with transformed screen
44----------------------------------------
45Setup:
46#. Install mplayer.
47#. Get a video file you can play in mplayer.
48
49Actions:
50#. Open the video in mplayer.
51#. Hit F to go fullscreen.
52#. Trigger expo mode (Super+E or mouse to top-left corner)
53#. Leave expo mode (click on the full screen video)
54#. Trigger expo mode again.
55#. Leave expo mode (click on the full screen video)
56#. Hit Escape to close the video.
57
58Expected Result:
59 Every time you triggered expo mode, expo mode should have become visible and
60 you should see the video still playing in the expo view.
61
62
63Unredirect cancelation by alpha windows on top (LP: #1046661)
64-------------------------------------------------------------
65Setup:
66#. Install Chromium or Chrome browser.
67
68Actions:
69#. Open a Chrome/Chromium window.
70#. Open a gnome-terminal window (Ctrl+Alt+T)
71#. Move the gnome-terminal to the centre of the screen, above the Chrome
72 window.
73#. Click on the Chrome window and make it fullscreen (F11).
74#. Alt+Tab to the gnome-terminal window.
75
76Expected Result:
77 The gnome-terminal window should be visible on top.
78
79
80Unredirect cancelation by transformed windows (LP: #1047168)
81-------------------------------------------------------------
82Setup:
83#. Install Chromium or Chrome browser.
84#. Run ccsm and ensure the Scale plugin is loaded and "Initiate Window Picker"
85 is bound to Shift+Alt+Up.
86
87Actions:
88#. Open a Chrome/Chromium window.
89#. Open a gnome-terminal window (Ctrl+Alt+T)
90#. Move the gnome-terminal to the centre of the screen, above the Chrome
91 window.
92#. Click on the Chrome window and make it fullscreen (F11).
93#. Hold Shift+Alt and tap Up to engage scale mode. Keep holding Shift+Alt
94 for a few seconds.
95
96Expected Result:
97 Windows get scaled and you can see both the Chrome and Terminal windows.

Subscribers

People subscribed via source and target branches