Merge lp:~vanvugt/compiz/fix-1046661 into lp:compiz/0.9.8

Proposed by Daniel van Vugt
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3349
Merged at revision: 3346
Proposed branch: lp:~vanvugt/compiz/fix-1046661
Merge into: lp:compiz/0.9.8
Diff against target: 171 lines (+77/-36)
5 files modified
plugins/opengl/src/fsregion/fsregion.cpp (+2/-2)
plugins/opengl/src/fsregion/fsregion.h (+6/-4)
plugins/opengl/src/fsregion/tests/test-fsregion.cpp (+19/-0)
plugins/opengl/src/paint.cpp (+34/-30)
tests/manual/Unredirect.txt (+16/-0)
To merge this branch: bzr merge lp:~vanvugt/compiz/fix-1046661
Reviewer Review Type Date Requested Status
Sam Spilsbury Approve
jenkins (community) continuous-integration Approve
Review via email: mp+123026@code.launchpad.net

Commit message

Fixed: Windows with an alpha-channel, like gnome-terminal, were not being
considered as possibly covering fullscreen windows. But they most certainly
can. This ensures such RGBA windows are visible if they're stacked above a
fullscreen window. (LP: #1046661)
.

Description of the change

Fixed: Windows with an alpha-channel, like gnome-terminal, were not being
considered as possibly covering fullscreen windows. But they most certainly
can. This ensures such RGBA windows are visible if they're stacked above a
fullscreen window. (LP: #1046661)

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

!(flags & (Desktop | Alpha)

That can be expressed as a temporary rather than in a compound if statement

const bool ignoreWindow = (flags & (Desktop | Alpha)

119 + /*
120 + * Alpha windows (status == false) can cover/cancel fullscreen
121 + * unredirected windows. But they can't be unredirected themselves.
122 + * I wonder if this is sensible as some games may use fullscreen
123 + * RGBA (alpha) windows that are fully opaque and need unredirect.
124 + */

This comment is confusing. We're checking whether or not the window has an rgba visual (eg, w->alpha () not whether or not it failed to paint (as status == false) would indicate to me.

Also, the default visual for most windows would be an RGB24 visual, so I don't think the concern is too much. (And we wouldn't be able to detect it anyways, as an RGBA visual just means a client is at liberty to have alpha values in its backing pixmap, which we must blend).

I'm also a bit confused as to why it matters that the window has an alpha channel as to whether or not a fullscreen window underneath it is unredirected. Shouldn't the fullscreen window underneath always be unredirected if there is some other window that is occluding it?

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

> Shouldn't the fullscreen window underneath always be
> unredirected if there is some other window that is occluding it?

Correction: That should read

"Shouldn't the fullscreen window underneath always be redirected if there is some other window that is occluding it"

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

!(flags & (Desktop | Alpha) is clearer, I think. Programmers think in logic, not words. We don't need to be translating clear logic into extraneous English. It complicates the thought process. Also, "ignoreWindow" is not accurate because it's not the only condition for ignoring a window.

Yeah, the comment is slightly out-dated still. It belongs next to some code that's not there any more. But technically it's still true. status is false for alpha windows (and other cases too).

Alpha "matters" for FullscreenRegion, only because we don't want to accidentally unredirect a translucent fullscreen window. You are right that alpha does not matter for the non-fullscreen windows.

lp:~vanvugt/compiz/fix-1046661 updated
3349. By Daniel van Vugt

Clarify comment per smspillaz suggestion.

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

Okay, I'm good with it now after discussing.

Noted that this proposal doesn't deal with the issue of "not counting" windows that are fully-transparent or not painted at all on top of fullscreen windows. This case should be dealt with later.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/opengl/src/fsregion/fsregion.cpp'
--- plugins/opengl/src/fsregion/fsregion.cpp 2012-09-04 10:19:19 +0000
+++ plugins/opengl/src/fsregion/fsregion.cpp 2012-09-06 09:57:22 +0000
@@ -35,11 +35,11 @@
35}35}
3636
37bool37bool
38FullscreenRegion::isCoveredBy (const CompRegion &region, WinType type)38FullscreenRegion::isCoveredBy (const CompRegion &region, WinFlags flags)
39{39{
40 bool fullscreen = false;40 bool fullscreen = false;
4141
42 if (!covered && type == Normal && region == untouched)42 if (!covered && !(flags & (Desktop | Alpha)) && region == untouched)
43 {43 {
44 covered = true;44 covered = true;
45 fullscreen = true;45 fullscreen = true;
4646
=== modified file 'plugins/opengl/src/fsregion/fsregion.h'
--- plugins/opengl/src/fsregion/fsregion.h 2012-09-04 10:19:19 +0000
+++ plugins/opengl/src/fsregion/fsregion.h 2012-09-06 09:57:22 +0000
@@ -36,14 +36,16 @@
36public:36public:
37 typedef enum37 typedef enum
38 {38 {
39 Normal,39 Desktop = 1,
40 Desktop40 Alpha = 2
41 } WinType;41 } WinFlag;
42
43 typedef unsigned int WinFlags;
4244
43 FullscreenRegion (const CompRect &rect);45 FullscreenRegion (const CompRect &rect);
4446
45 // isCoveredBy is called for windows from TOP to BOTTOM47 // isCoveredBy is called for windows from TOP to BOTTOM
46 bool isCoveredBy (const CompRegion &region, WinType type = Normal);48 bool isCoveredBy (const CompRegion &region, WinFlags flags = 0);
4749
48private:50private:
49 bool covered;51 bool covered;
5052
=== modified file 'plugins/opengl/src/fsregion/tests/test-fsregion.cpp'
--- plugins/opengl/src/fsregion/tests/test-fsregion.cpp 2012-09-04 09:51:05 +0000
+++ plugins/opengl/src/fsregion/tests/test-fsregion.cpp 2012-09-06 09:57:22 +0000
@@ -49,6 +49,25 @@
49 EXPECT_TRUE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));49 EXPECT_TRUE (monitor.isCoveredBy (CompRegion (0, 0, 1024, 768)));
50}50}
5151
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
52TEST (OpenGLFullscreenRegion, NormalWindows)71TEST (OpenGLFullscreenRegion, NormalWindows)
53{72{
54 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));73 FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
5574
=== modified file 'plugins/opengl/src/paint.cpp'
--- plugins/opengl/src/paint.cpp 2012-09-05 10:20:20 +0000
+++ plugins/opengl/src/paint.cpp 2012-09-06 09:57:22 +0000
@@ -337,36 +337,40 @@
337 }337 }
338 else338 else
339 tmpRegion -= w->region ();339 tmpRegion -= w->region ();
340340 }
341 /* unredirect top most fullscreen windows. */341
342 FullscreenRegion::WinType type =342 FullscreenRegion::WinFlags flags = 0;
343 w->type () & CompWindowTypeDesktopMask ?343 if (w->type () & CompWindowTypeDesktopMask)
344 FullscreenRegion::Desktop :344 flags |= FullscreenRegion::Desktop;
345 FullscreenRegion::Normal;345 if (w->alpha ())
346 346 flags |= FullscreenRegion::Alpha;
347 if (unredirectFS &&347
348 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&348 /*
349 fs.isCoveredBy (w->region (), type))349 * Windows with alpha channels can partially occlude windows
350 {350 * beneath them and so neither should be unredirected in that case.
351 fullscreenWindow = w;351 */
352 }352 if (unredirectFS &&
353 else353 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
354 {354 fs.isCoveredBy (w->region (), flags))
355 CompositeWindow *cw = CompositeWindow::get (w);355 {
356 if (!cw->redirected ())356 fullscreenWindow = w;
357 {357 }
358 // 1. GLWindow::release to force gw->priv->needsRebind358 else
359 gw->release ();359 {
360360 CompositeWindow *cw = CompositeWindow::get (w);
361 // 2. GLWindow::bind, which redirects the window,361 if (!cw->redirected ())
362 // rebinds the pixmap, and then rebinds the pixmap362 {
363 // to a texture.363 // 1. GLWindow::release to force gw->priv->needsRebind
364 gw->bind ();364 gw->release ();
365365
366 // 3. Your window is now redirected again with the366 // 2. GLWindow::bind, which redirects the window,
367 // latest pixmap contents.367 // rebinds the pixmap, and then rebinds the pixmap
368 }368 // to a texture.
369 }369 gw->bind ();
370
371 // 3. Your window is now redirected again with the
372 // latest pixmap contents.
373 }
370 }374 }
371 }375 }
372 }376 }
373377
=== modified file 'tests/manual/Unredirect.txt'
--- tests/manual/Unredirect.txt 2012-09-05 10:20:20 +0000
+++ tests/manual/Unredirect.txt 2012-09-06 09:57:22 +0000
@@ -59,3 +59,19 @@
59 Every time you triggered expo mode, expo mode should have become visible and59 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.60 you should see the video still playing in the expo view.
6161
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.

Subscribers

People subscribed via source and target branches