Merge lp:~vanvugt/compiz-core/blacklist into lp:compiz-core

Proposed by Daniel van Vugt
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3130
Merged at revision: 3130
Proposed branch: lp:~vanvugt/compiz-core/blacklist
Merge into: lp:compiz-core
Diff against target: 445 lines (+310/-4)
10 files modified
plugins/opengl/CMakeLists.txt (+2/-1)
plugins/opengl/opengl.xml.in (+5/-0)
plugins/opengl/src/blacklist/CMakeLists.txt (+6/-0)
plugins/opengl/src/blacklist/blacklist.cpp (+67/-0)
plugins/opengl/src/blacklist/blacklist.h (+38/-0)
plugins/opengl/src/blacklist/tests/CMakeLists.txt (+9/-0)
plugins/opengl/src/blacklist/tests/test-blacklist.cpp (+152/-0)
plugins/opengl/src/paint.cpp (+6/-0)
plugins/opengl/src/privates.h (+4/-0)
plugins/opengl/src/screen.cpp (+21/-3)
To merge this branch: bzr merge lp:~vanvugt/compiz-core/blacklist
Reviewer Review Type Date Requested Status
Sam Spilsbury Approve
Timo Jyrinki Pending
Review via email: mp+139624@code.launchpad.net

Commit message

Add a feature for blacklisting certain graphics drivers from being able to
unredirect fullscreen windows. Right now the only known broken drivers are
nouveau and intel on precise (Mesa 8.0). But the blacklist is a regex that
can be adjusted at any time.
(LP: #1089246)

Description of the change

This is almost the same as the upstream one. But it required some modification to work in the 0.9.7 tree. So needs re-approval.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

(Token approve because I missed the last one :)). Thanks for getting this in with tests.

review: Approve

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 2012-11-12 06:59:31 +0000
+++ plugins/opengl/CMakeLists.txt 2012-12-13 08:05:23 +0000
@@ -3,8 +3,9 @@
3include (CompizPlugin)3include (CompizPlugin)
44
5add_subdirectory (src/fsregion)5add_subdirectory (src/fsregion)
6add_subdirectory (src/blacklist)
67
7find_package (OpenGL)8find_package (OpenGL)
8if (OPENGL_FOUND)9if (OPENGL_FOUND)
9 compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} compiz_opengl_fsregion INCDIRS ${OPENGL_INCLUDE_DIR})10 compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} compiz_opengl_fsregion compiz_opengl_blacklist INCDIRS ${OPENGL_INCLUDE_DIR})
10endif ()11endif ()
1112
=== modified file 'plugins/opengl/opengl.xml.in'
--- plugins/opengl/opengl.xml.in 2011-10-13 14:30:20 +0000
+++ plugins/opengl/opengl.xml.in 2012-12-13 08:05:23 +0000
@@ -43,6 +43,11 @@
43 <_long>If available use compression for textures converted from images</_long>43 <_long>If available use compression for textures converted from images</_long>
44 <default>false</default>44 <default>false</default>
45 </option>45 </option>
46 <option name="unredirect_driver_blacklist" type="string">
47 <_short>Unredirect Driver Blacklist</_short>
48 <_long>If non-empty, specifies a POSIX (extended) regular expression to match against the OpenGL driver strings (newline separated): "GL_VENDOR\nGL_RENDERER\nGL_VERSION". If the regular expression matches a substring of that concatenation then no windows will ever be unredirected while using that particular graphics driver.</_long>
49 <default>(nouveau|Intel).*Mesa 8\\.0</default>
50 </option>
46 </options>51 </options>
47 </plugin>52 </plugin>
48</compiz>53</compiz>
4954
=== added directory 'plugins/opengl/src/blacklist'
=== added file 'plugins/opengl/src/blacklist/CMakeLists.txt'
--- plugins/opengl/src/blacklist/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/blacklist/CMakeLists.txt 2012-12-13 08:05:23 +0000
@@ -0,0 +1,6 @@
1if (COMPIZ_BUILD_TESTING)
2add_subdirectory (tests)
3endif ()
4
5add_library (compiz_opengl_blacklist STATIC blacklist.cpp)
6
07
=== added file 'plugins/opengl/src/blacklist/blacklist.cpp'
--- plugins/opengl/src/blacklist/blacklist.cpp 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/blacklist/blacklist.cpp 2012-12-13 08:05:23 +0000
@@ -0,0 +1,67 @@
1/*
2 * Compiz opengl plugin, Blacklist feature
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 "blacklist.h"
27#include <cstdio>
28#include <regex.h>
29
30namespace compiz {
31namespace opengl {
32
33bool blacklisted (const char *blacklistRegex, const char *glVendor,
34 const char *glRenderer, const char *glVersion)
35{
36 bool matches = false;
37
38 if (blacklistRegex && blacklistRegex[0])
39 {
40 regex_t re;
41
42 // Ensure the regex contains something other than spaces, or ignore.
43 const char *p = blacklistRegex;
44 while (*p == ' ')
45 p++;
46
47 if (*p && !regcomp (&re, blacklistRegex, REG_EXTENDED))
48 {
49 char driver[1024];
50
51 snprintf (driver, sizeof driver, "%s\n%s\n%s",
52 glVendor ? glVendor : "",
53 glRenderer ? glRenderer : "",
54 glVersion ? glVersion : "");
55
56 if (!regexec (&re, driver, 0, NULL, 0))
57 matches = true;
58
59 regfree (&re);
60 }
61 }
62
63 return matches;
64}
65
66} // namespace opengl
67} // namespace compiz
068
=== added file 'plugins/opengl/src/blacklist/blacklist.h'
--- plugins/opengl/src/blacklist/blacklist.h 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/blacklist/blacklist.h 2012-12-13 08:05:23 +0000
@@ -0,0 +1,38 @@
1/*
2 * Compiz opengl plugin, Blacklist function
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_BLACKLIST_H
27#define __COMPIZ_OPENGL_BLACKLIST_H
28
29namespace compiz {
30namespace opengl {
31
32bool blacklisted (const char *blacklistRegex, const char *glVendor,
33 const char *glRenderer, const char *glVersion);
34
35} // namespace opengl
36} // namespace compiz
37
38#endif
039
=== added directory 'plugins/opengl/src/blacklist/tests'
=== added file 'plugins/opengl/src/blacklist/tests/CMakeLists.txt'
--- plugins/opengl/src/blacklist/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/blacklist/tests/CMakeLists.txt 2012-12-13 08:05:23 +0000
@@ -0,0 +1,9 @@
1include_directories (${GTEST_INCLUDE_DIRS} ..)
2set (exe "compiz_opengl_test_blacklist")
3add_executable (${exe} test-blacklist.cpp)
4target_link_libraries (${exe}
5 compiz_opengl_blacklist
6 ${GTEST_BOTH_LIBRARIES}
7)
8gtest_add_tests (compiz_opengl_test_blacklist "" ${CMAKE_CURRENT_SOURCE_DIR}/test-blacklist.cpp)
9
010
=== added file 'plugins/opengl/src/blacklist/tests/test-blacklist.cpp'
--- plugins/opengl/src/blacklist/tests/test-blacklist.cpp 1970-01-01 00:00:00 +0000
+++ plugins/opengl/src/blacklist/tests/test-blacklist.cpp 2012-12-13 08:05:23 +0000
@@ -0,0 +1,152 @@
1/*
2 * Compiz opengl plugin, Backlist feature
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 "blacklist.h"
28
29using namespace compiz::opengl;
30
31static const char *recommendedRegex = "(nouveau|Intel).*Mesa 8\\.0";
32
33TEST(DriverBlacklist, QuantalIntelIsGood)
34{
35 EXPECT_FALSE (blacklisted (recommendedRegex,
36 "Intel Open Source Technology Center",
37 "Mesa DRI Intel(R) Sandybridge Desktop",
38 "3.0 Mesa 9.0"));
39}
40
41TEST(DriverBlacklist, PreciseIntelIsBad)
42{
43 EXPECT_TRUE (blacklisted (recommendedRegex,
44 "Tungsten Graphics, Inc",
45 "Mesa DRI Intel(R) Sandybridge Desktop",
46 "3.0 Mesa 8.0.2"));
47}
48
49TEST(DriverBlacklist, QuantalNouveauIsGood)
50{
51 EXPECT_FALSE (blacklisted (recommendedRegex,
52 "nouveau",
53 "Gallium 0.4 on NV86",
54 "3.0 Mesa 9.0-devel"));
55}
56
57TEST(DriverBlacklist, PreciseNouveauIsBad)
58{
59 EXPECT_TRUE (blacklisted (recommendedRegex,
60 "nouveau",
61 "Gallium 0.4 on NVA8",
62 "2.1 Mesa 8.0.2"));
63}
64
65TEST(DriverBlacklist, FglrxIsGood)
66{
67 EXPECT_FALSE (blacklisted (recommendedRegex,
68 "Advanced Micro Devices, Inc.",
69 "ATI Radeon HD 5450",
70 "4.2.11627 Compatibility Profile Context"));
71}
72
73TEST(DriverBlacklist, NvidiaIsGood)
74{
75 EXPECT_FALSE (blacklisted (recommendedRegex,
76 "NVIDIA Corporation",
77 "Quadro 1000M/PCIe/SSE2",
78 "4.2.0 NVIDIA 304.48"));
79}
80
81TEST(DriverBlacklist, RadeonIsGood1)
82{
83 EXPECT_FALSE (blacklisted (recommendedRegex,
84 "X.Org R300 Project",
85 "Gallium 0.4 on ATI RV350",
86 "2.1 Mesa 8.0.2"));
87}
88
89TEST(DriverBlacklist, RadeonIsGood2)
90{
91 EXPECT_FALSE (blacklisted (recommendedRegex,
92 "X.Org",
93 "Gallium 0.4 on AMD CEDAR",
94 "2.1 Mesa 8.0.3"));
95}
96
97TEST(DriverBlacklist, RadeonIsGood3)
98{
99 EXPECT_FALSE (blacklisted (recommendedRegex,
100 "X.Org",
101 "Gallium 0.4 on AMD RS880",
102 "2.1 Mesa 8.0.2"));
103}
104
105TEST(DriverBlacklist, LLVMpipeIsGood)
106{
107 EXPECT_FALSE (blacklisted (recommendedRegex,
108 "VMware, Inc.",
109 "Gallium 0.4 on llvmpipe (LLVM 0x300)",
110 "2.1 Mesa 8.0.4"));
111}
112
113TEST(DriverBlacklist, UnknownIsGood)
114{
115 EXPECT_FALSE (blacklisted (recommendedRegex,
116 "Acme",
117 "Graphics Driver",
118 "4.2 8.0 9.0 123.456"));
119}
120
121TEST(DriverBlacklist, NoBlacklist)
122{
123 EXPECT_FALSE (blacklisted ("",
124 "Tungsten Graphics, Inc",
125 "Mesa DRI Intel(R) Sandybridge Desktop",
126 "3.0 Mesa 8.0.2"));
127 EXPECT_FALSE (blacklisted ("", "foo", "bar", "blah"));
128 EXPECT_FALSE (blacklisted ("", "", "", ""));
129}
130
131TEST(DriverBlacklist, LineContinuation)
132{
133 EXPECT_FALSE (blacklisted ("alpha", "beta", "gamma", "delta"));
134 EXPECT_FALSE (blacklisted ("betagam", "beta", "gamma", "delta"));
135 EXPECT_TRUE (blacklisted ("gamma", "beta", "gamma", "delta"));
136 EXPECT_TRUE (blacklisted ("del", "beta", "gamma", "delta"));
137 EXPECT_TRUE (blacklisted ("(mag|gam)", "beta", "gamma", "delta"));
138 EXPECT_TRUE (blacklisted ("beta.*delt", "beta", "gamma", "delta"));
139 EXPECT_FALSE (blacklisted ("beta.*felt", "beta", "gamma", "delta"));
140
141 EXPECT_TRUE (blacklisted ("beta\ngamma\ndelta", "beta", "gamma", "delta"));
142}
143
144TEST(DriverBlacklist, StraySpaces)
145{
146 EXPECT_FALSE (blacklisted (" ", "Hello world", "and", "goodbye"));
147 EXPECT_FALSE (blacklisted (" ", " ", " ", " "));
148 EXPECT_FALSE (blacklisted (" ",
149 "Tungsten Graphics, Inc",
150 "Mesa DRI Intel(R) Sandybridge Desktop",
151 "3.0 Mesa 8.0.2"));
152}
0153
=== modified file 'plugins/opengl/src/paint.cpp'
--- plugins/opengl/src/paint.cpp 2012-12-12 03:47:13 +0000
+++ plugins/opengl/src/paint.cpp 2012-12-13 08:05:23 +0000
@@ -231,6 +231,11 @@
231 CompMatch &unredirectable = CompositeScreen::get (screen)->231 CompMatch &unredirectable = CompositeScreen::get (screen)->
232 getOption ("unredirect_match")->value ().match ();232 getOption ("unredirect_match")->value ().match ();
233233
234 const CompString &blacklist =
235 getOption ("unredirect_driver_blacklist")->value ().s ();
236
237 bool blacklisted = driverIsBlacklisted (blacklist.c_str ());
238
234 if (mask & PAINT_SCREEN_TRANSFORMED_MASK)239 if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
235 {240 {
236 windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;241 windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
@@ -324,6 +329,7 @@
324 * beneath them and so neither should be unredirected in that case.329 * beneath them and so neither should be unredirected in that case.
325 */330 */
326 if (unredirectFS &&331 if (unredirectFS &&
332 !blacklisted &&
327 unredirectable.evaluate (w) &&333 unredirectable.evaluate (w) &&
328 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&334 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
329 !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&335 !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
330336
=== modified file 'plugins/opengl/src/privates.h'
--- plugins/opengl/src/privates.h 2012-02-08 10:54:35 +0000
+++ plugins/opengl/src/privates.h 2012-12-13 08:05:23 +0000
@@ -87,6 +87,8 @@
8787
88 void updateView ();88 void updateView ();
8989
90 bool driverIsBlacklisted (const char *regex) const;
91
90 public:92 public:
9193
92 GLScreen *gScreen;94 GLScreen *gScreen;
@@ -127,6 +129,8 @@
127129
128 Pixmap rootPixmapCopy;130 Pixmap rootPixmapCopy;
129 CompSize rootPixmapSize;131 CompSize rootPixmapSize;
132
133 const char *glVendor, *glRenderer, *glVersion;
130};134};
131135
132class PrivateGLWindow :136class PrivateGLWindow :
133137
=== modified file 'plugins/opengl/src/screen.cpp'
--- plugins/opengl/src/screen.cpp 2012-11-12 09:24:02 +0000
+++ plugins/opengl/src/screen.cpp 2012-12-13 08:05:23 +0000
@@ -26,6 +26,7 @@
26 */26 */
2727
28#include "privates.h"28#include "privates.h"
29#include "blacklist/blacklist.h"
2930
30#include <dlfcn.h>31#include <dlfcn.h>
31#include <math.h>32#include <math.h>
@@ -81,6 +82,8 @@
81 unsigned int unthrottledFrames = 0;82 unsigned int unthrottledFrames = 0;
82}83}
8384
85using namespace compiz::opengl;
86
84CompOutput *targetOutput = NULL;87CompOutput *targetOutput = NULL;
8588
86bool89bool
@@ -92,7 +95,6 @@
92 GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 0.0f };95 GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 0.0f };
93 GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f };96 GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f };
94 GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f };97 GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f };
95 const char *glRenderer;
96 CompOption::Vector o (0);98 CompOption::Vector o (0);
9799
98 priv->ctx = glXCreateContext (dpy, visinfo, NULL, True);100 priv->ctx = glXCreateContext (dpy, visinfo, NULL, True);
@@ -131,7 +133,14 @@
131 return false;133 return false;
132 }134 }
133135
134 glRenderer = (const char *) glGetString (GL_RENDERER);136 const char *glVendor = (const char *) glGetString (GL_VENDOR);
137 const char *glRenderer = (const char *) glGetString (GL_RENDERER);
138 const char *glVersion = (const char *) glGetString (GL_VERSION);
139
140 priv->glVendor = glVendor;
141 priv->glRenderer = glRenderer;
142 priv->glVersion = glVersion;
143
135 if (glRenderer != NULL &&144 if (glRenderer != NULL &&
136 (strcmp (glRenderer, "Software Rasterizer") == 0 ||145 (strcmp (glRenderer, "Software Rasterizer") == 0 ||
137 strcmp (glRenderer, "Mesa X11") == 0))146 strcmp (glRenderer, "Mesa X11") == 0))
@@ -591,7 +600,10 @@
591 bindPixmap (),600 bindPixmap (),
592 hasCompositing (false),601 hasCompositing (false),
593 rootPixmapCopy (None),602 rootPixmapCopy (None),
594 rootPixmapSize ()603 rootPixmapSize (),
604 glVendor (NULL),
605 glRenderer (NULL),
606 glVersion (NULL)
595{607{
596 ScreenInterface::setHandler (screen);608 ScreenInterface::setHandler (screen);
597}609}
@@ -1291,6 +1303,12 @@
1291 }1303 }
1292}1304}
12931305
1306bool
1307PrivateGLScreen::driverIsBlacklisted (const char *regex) const
1308{
1309 return blacklisted (regex, glVendor, glRenderer, glVersion);
1310}
1311
1294GLTexture::BindPixmapHandle1312GLTexture::BindPixmapHandle
1295GLScreen::registerBindPixmap (GLTexture::BindPixmapProc proc)1313GLScreen::registerBindPixmap (GLTexture::BindPixmapProc proc)
1296{1314{

Subscribers

People subscribed via source and target branches