Skip to content
This repository has been archived by the owner on Feb 27, 2018. It is now read-only.

Commit

Permalink
[compiz-ubuntu] Fix flickering bug when unredirect fullscreen windows…
Browse files Browse the repository at this point in the history
… is enabled with multiple monitors
  • Loading branch information
Xiao-Long Chen committed Sep 18, 2012
1 parent 426fd16 commit 7c57cb3
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 0 deletions.
158 changes: 158 additions & 0 deletions compiz-ubuntu/0100_Fix_flickering_and_performance_problems.patch
@@ -0,0 +1,158 @@
=== modified file 'plugins/opengl/src/fsregion/fsregion.cpp'
--- plugins/opengl/src/fsregion/fsregion.cpp 2012-09-06 08:01:54 +0000
+++ plugins/opengl/src/fsregion/fsregion.cpp 2012-09-18 07:54:10 +0000
@@ -30,7 +30,8 @@

FullscreenRegion::FullscreenRegion (const CompRect &rect) :
covered (false),
- untouched (rect)
+ untouched (rect),
+ orig (untouched)
{
}

@@ -50,5 +51,14 @@
return fullscreen;
}

+bool
+FullscreenRegion::allowRedirection (const CompRegion &region)
+{
+ /* Don't allow existing unredirected windows that cover this
+ * region to be redirected again as they were probably unredirected
+ * on another monitor */
+ return region.intersects (orig);
+}
+
} // namespace opengl
} // namespace compiz

=== modified file 'plugins/opengl/src/fsregion/fsregion.h'
--- plugins/opengl/src/fsregion/fsregion.h 2012-09-06 08:01:54 +0000
+++ plugins/opengl/src/fsregion/fsregion.h 2012-09-18 08:07:49 +0000
@@ -46,10 +46,12 @@

// isCoveredBy is called for windows from TOP to BOTTOM
bool isCoveredBy (const CompRegion &region, WinFlags flags = 0);
+ bool allowRedirection (const CompRegion &region);

private:
bool covered;
CompRegion untouched;
+ CompRegion orig;
};

} // namespace opengl

=== modified file 'plugins/opengl/src/fsregion/tests/test-fsregion.cpp'
--- plugins/opengl/src/fsregion/tests/test-fsregion.cpp 2012-09-06 08:01:54 +0000
+++ plugins/opengl/src/fsregion/tests/test-fsregion.cpp 2012-09-18 08:09:02 +0000
@@ -137,4 +137,14 @@
FullscreenRegion::Desktop));
}

+TEST (OpenGLFullscreenRegion, KeepUnredirectedStateIfNotOnMonitor)
+{
+ FullscreenRegion monitor (CompRect (0, 0, 1024, 768));
+ CompRegion window (1025, 0, 1024, 768);
+ /* Eg, not covering the monitor, should be redirected */
+ EXPECT_FALSE (monitor.isCoveredBy (window));
+ /* Don't allow the redirection however, because we weren't
+ * covering the monitor at all. */
+ EXPECT_FALSE (monitor.allowRedirection (window));
+}


=== modified file 'plugins/opengl/src/paint.cpp'
--- plugins/opengl/src/paint.cpp 2012-09-06 09:55:05 +0000
+++ plugins/opengl/src/paint.cpp 2012-09-18 08:05:55 +0000
@@ -27,6 +27,7 @@

#include "privates.h"

+#include <set>
#include <stdlib.h>
#include <string.h>
#include <math.h>
@@ -245,11 +246,11 @@
CompWindow *w;
GLWindow *gw;
int windowMask, odMask;
- CompWindow *fullscreenWindow = NULL;
bool status, unredirectFS;
bool withOffset = false;
GLMatrix vTransform;
CompPoint offXY;
+ std::set<CompWindow*> unredirected;

CompWindowList pl;
CompWindowList::reverse_iterator rit;
@@ -350,32 +351,40 @@
* beneath them and so neither should be unredirected in that case.
*/
if (unredirectFS &&
- !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
- fs.isCoveredBy (w->region (), flags))
+ !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
+ fs.isCoveredBy (w->region (), flags))
{
- fullscreenWindow = w;
+ unredirected.insert (w);
}
else
{
- CompositeWindow *cw = CompositeWindow::get (w);
- if (!cw->redirected ())
- {
- // 1. GLWindow::release to force gw->priv->needsRebind
- gw->release ();
-
- // 2. GLWindow::bind, which redirects the window,
- // rebinds the pixmap, and then rebinds the pixmap
- // to a texture.
- gw->bind ();
-
- // 3. Your window is now redirected again with the
- // latest pixmap contents.
- }
+ CompositeWindow *cw = CompositeWindow::get (w);
+ if (!cw->redirected ())
+ {
+ if (fs.allowRedirection (w->region ()))
+ {
+ // 1. GLWindow::release to force gw->priv->needsRebind
+ gw->release ();
+
+ // 2. GLWindow::bind, which redirects the window,
+ // rebinds the pixmap, and then rebinds the pixmap
+ // to a texture.
+ gw->bind ();
+
+ // 3. Your window is now redirected again with the
+ // latest pixmap contents.
+ }
+ else
+ {
+ unredirected.insert (w);
+ }
+ }
}
}
}

- if (fullscreenWindow)
+ /* Unredirect any redirected fullscreen windows */
+ foreach (CompWindow *fullscreenWindow, unredirected)
CompositeWindow::get (fullscreenWindow)->unredirect ();

if (!(mask & PAINT_SCREEN_NO_BACKGROUND_MASK))
@@ -389,7 +398,7 @@
if (w->destroyed ())
continue;

- if (w == fullscreenWindow)
+ if (unredirected.find (w) != unredirected.end ())
continue;

if (!w->shaded ())

6 changes: 6 additions & 0 deletions compiz-ubuntu/PKGBUILD
Expand Up @@ -50,13 +50,15 @@ source=("https://launchpad.net/compiz/${_actual_ver%.*}/${_actual_ver}/+download
'0002_Fix_cmake_install_dir.patch'
'0003_Fix_python_install_command.patch'
'0004_Use_python2.patch'
'0100_Fix_flickering_and_performance_problems.patch'
'compiz-migrate-to-dconf.desktop')
sha512sums=('33f69faf91d203db34872202ac180152944579dde8fa8eb1603d45af043ce7eb6cdd9e096b811ad513ca8c07516d1cc1c41f4e238b8b64109141bb7284b21f8b'
'858b9aacba030f4860d452c8a7af59fa66fa3613478f61713b418be453f8e533e556737dc52d8ada18802a2eeb8a4edc8614ff6c8bc1e0d38a0f2a969e301ac2'
'cf0324a656e855ff26b624386d287ae4d90ede8f14d8eb7e613591de1dd90c7eb00ebfbb401802caa6e6e9aac99031e9ddd8a966ed23513b9e33b529f3b9519c'
'ba80a6e5c3a7b488974046f8c1b906bb178691a9224b5c8f3542e0948099e2291b8888fbd4f591eaa16f9209e7288f11e122d1673731e7f1aa7c84aa6e3207c6'
'bd7c8c0bf4cb3767c5b4b6d9c2d79e958ff9f34375a8223b509aec16b3682e219568e17378fa392f6ca4267f695835d83ef1c5db12898ea7b7cc75e1151d02b2'
'fb0b06b8d82ffe43b54b430233c1fd53649c9c28cf85a281e3e306553eb6e568efe70e0c3500399fe31bea4aedc58f4745d604ed633b5700e9173bcdba0f978a'
'd37e09bf44ddcb22f723ad254a6e6a736bac5b24e45a75d949a8bae6d0c210843bc215054926d022316b74c7bc53087cf2e13ae0403b78171caeae21b4bfd4a7'
'affbff2a8ce7d5f223ce86407ef0e80769f9df47228b7acdf25d0ac82b70b80a9b0bce4507df928b9738ef69d1dc8ab3a3622094b2e765f89d54db2b10899cc8')

build() {
Expand All @@ -73,6 +75,10 @@ build() {
# Use python 2
patch -Np1 -i "${srcdir}/0004_Use_python2.patch"

# BZR: Fix flickering and performance problems with using Unredirect
# Fullscreen Windows with multiple monitors. (LP: #1050749) (LP: #1051885)
patch -Np0 -i "${srcdir}/0100_Fix_flickering_and_performance_problems.patch"

# Apply Ubuntu patches
patch -Np1 -i "${srcdir}/${pkgname%-*}_${_ubuntu_ver}-${_ubuntu_rel}.diff" || true

Expand Down

0 comments on commit 7c57cb3

Please sign in to comment.