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
1=== modified file 'plugins/opengl/CMakeLists.txt'
2--- plugins/opengl/CMakeLists.txt 2012-11-12 06:59:31 +0000
3+++ plugins/opengl/CMakeLists.txt 2012-12-13 08:05:23 +0000
4@@ -3,8 +3,9 @@
5 include (CompizPlugin)
6
7 add_subdirectory (src/fsregion)
8+add_subdirectory (src/blacklist)
9
10 find_package (OpenGL)
11 if (OPENGL_FOUND)
12- compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} compiz_opengl_fsregion INCDIRS ${OPENGL_INCLUDE_DIR})
13+ compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} compiz_opengl_fsregion compiz_opengl_blacklist INCDIRS ${OPENGL_INCLUDE_DIR})
14 endif ()
15
16=== modified file 'plugins/opengl/opengl.xml.in'
17--- plugins/opengl/opengl.xml.in 2011-10-13 14:30:20 +0000
18+++ plugins/opengl/opengl.xml.in 2012-12-13 08:05:23 +0000
19@@ -43,6 +43,11 @@
20 <_long>If available use compression for textures converted from images</_long>
21 <default>false</default>
22 </option>
23+ <option name="unredirect_driver_blacklist" type="string">
24+ <_short>Unredirect Driver Blacklist</_short>
25+ <_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>
26+ <default>(nouveau|Intel).*Mesa 8\\.0</default>
27+ </option>
28 </options>
29 </plugin>
30 </compiz>
31
32=== added directory 'plugins/opengl/src/blacklist'
33=== added file 'plugins/opengl/src/blacklist/CMakeLists.txt'
34--- plugins/opengl/src/blacklist/CMakeLists.txt 1970-01-01 00:00:00 +0000
35+++ plugins/opengl/src/blacklist/CMakeLists.txt 2012-12-13 08:05:23 +0000
36@@ -0,0 +1,6 @@
37+if (COMPIZ_BUILD_TESTING)
38+add_subdirectory (tests)
39+endif ()
40+
41+add_library (compiz_opengl_blacklist STATIC blacklist.cpp)
42+
43
44=== added file 'plugins/opengl/src/blacklist/blacklist.cpp'
45--- plugins/opengl/src/blacklist/blacklist.cpp 1970-01-01 00:00:00 +0000
46+++ plugins/opengl/src/blacklist/blacklist.cpp 2012-12-13 08:05:23 +0000
47@@ -0,0 +1,67 @@
48+/*
49+ * Compiz opengl plugin, Blacklist feature
50+ *
51+ * Copyright (c) 2012 Canonical Ltd.
52+ * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
53+ *
54+ * Permission is hereby granted, free of charge, to any person obtaining a
55+ * copy of this software and associated documentation files (the "Software"),
56+ * to deal in the Software without restriction, including without limitation
57+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
58+ * and/or sell copies of the Software, and to permit persons to whom the
59+ * Software is furnished to do so, subject to the following conditions:
60+ *
61+ * The above copyright notice and this permission notice shall be included in
62+ * all copies or substantial portions of the Software.
63+ *
64+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
66+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
67+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
68+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
69+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
70+ * DEALINGS IN THE SOFTWARE.
71+ */
72+
73+#include "blacklist.h"
74+#include <cstdio>
75+#include <regex.h>
76+
77+namespace compiz {
78+namespace opengl {
79+
80+bool blacklisted (const char *blacklistRegex, const char *glVendor,
81+ const char *glRenderer, const char *glVersion)
82+{
83+ bool matches = false;
84+
85+ if (blacklistRegex && blacklistRegex[0])
86+ {
87+ regex_t re;
88+
89+ // Ensure the regex contains something other than spaces, or ignore.
90+ const char *p = blacklistRegex;
91+ while (*p == ' ')
92+ p++;
93+
94+ if (*p && !regcomp (&re, blacklistRegex, REG_EXTENDED))
95+ {
96+ char driver[1024];
97+
98+ snprintf (driver, sizeof driver, "%s\n%s\n%s",
99+ glVendor ? glVendor : "",
100+ glRenderer ? glRenderer : "",
101+ glVersion ? glVersion : "");
102+
103+ if (!regexec (&re, driver, 0, NULL, 0))
104+ matches = true;
105+
106+ regfree (&re);
107+ }
108+ }
109+
110+ return matches;
111+}
112+
113+} // namespace opengl
114+} // namespace compiz
115
116=== added file 'plugins/opengl/src/blacklist/blacklist.h'
117--- plugins/opengl/src/blacklist/blacklist.h 1970-01-01 00:00:00 +0000
118+++ plugins/opengl/src/blacklist/blacklist.h 2012-12-13 08:05:23 +0000
119@@ -0,0 +1,38 @@
120+/*
121+ * Compiz opengl plugin, Blacklist function
122+ *
123+ * Copyright (c) 2012 Canonical Ltd.
124+ * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
125+ *
126+ * Permission is hereby granted, free of charge, to any person obtaining a
127+ * copy of this software and associated documentation files (the "Software"),
128+ * to deal in the Software without restriction, including without limitation
129+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
130+ * and/or sell copies of the Software, and to permit persons to whom the
131+ * Software is furnished to do so, subject to the following conditions:
132+ *
133+ * The above copyright notice and this permission notice shall be included in
134+ * all copies or substantial portions of the Software.
135+ *
136+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
137+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
138+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
139+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
140+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
141+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
142+ * DEALINGS IN THE SOFTWARE.
143+ */
144+
145+#ifndef __COMPIZ_OPENGL_BLACKLIST_H
146+#define __COMPIZ_OPENGL_BLACKLIST_H
147+
148+namespace compiz {
149+namespace opengl {
150+
151+bool blacklisted (const char *blacklistRegex, const char *glVendor,
152+ const char *glRenderer, const char *glVersion);
153+
154+} // namespace opengl
155+} // namespace compiz
156+
157+#endif
158
159=== added directory 'plugins/opengl/src/blacklist/tests'
160=== added file 'plugins/opengl/src/blacklist/tests/CMakeLists.txt'
161--- plugins/opengl/src/blacklist/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
162+++ plugins/opengl/src/blacklist/tests/CMakeLists.txt 2012-12-13 08:05:23 +0000
163@@ -0,0 +1,9 @@
164+include_directories (${GTEST_INCLUDE_DIRS} ..)
165+set (exe "compiz_opengl_test_blacklist")
166+add_executable (${exe} test-blacklist.cpp)
167+target_link_libraries (${exe}
168+ compiz_opengl_blacklist
169+ ${GTEST_BOTH_LIBRARIES}
170+)
171+gtest_add_tests (compiz_opengl_test_blacklist "" ${CMAKE_CURRENT_SOURCE_DIR}/test-blacklist.cpp)
172+
173
174=== added file 'plugins/opengl/src/blacklist/tests/test-blacklist.cpp'
175--- plugins/opengl/src/blacklist/tests/test-blacklist.cpp 1970-01-01 00:00:00 +0000
176+++ plugins/opengl/src/blacklist/tests/test-blacklist.cpp 2012-12-13 08:05:23 +0000
177@@ -0,0 +1,152 @@
178+/*
179+ * Compiz opengl plugin, Backlist feature
180+ *
181+ * Copyright (c) 2012 Canonical Ltd.
182+ * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
183+ *
184+ * Permission is hereby granted, free of charge, to any person obtaining a
185+ * copy of this software and associated documentation files (the "Software"),
186+ * to deal in the Software without restriction, including without limitation
187+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
188+ * and/or sell copies of the Software, and to permit persons to whom the
189+ * Software is furnished to do so, subject to the following conditions:
190+ *
191+ * The above copyright notice and this permission notice shall be included in
192+ * all copies or substantial portions of the Software.
193+ *
194+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
195+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
196+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
197+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
198+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
199+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
200+ * DEALINGS IN THE SOFTWARE.
201+ */
202+
203+#include "gtest/gtest.h"
204+#include "blacklist.h"
205+
206+using namespace compiz::opengl;
207+
208+static const char *recommendedRegex = "(nouveau|Intel).*Mesa 8\\.0";
209+
210+TEST(DriverBlacklist, QuantalIntelIsGood)
211+{
212+ EXPECT_FALSE (blacklisted (recommendedRegex,
213+ "Intel Open Source Technology Center",
214+ "Mesa DRI Intel(R) Sandybridge Desktop",
215+ "3.0 Mesa 9.0"));
216+}
217+
218+TEST(DriverBlacklist, PreciseIntelIsBad)
219+{
220+ EXPECT_TRUE (blacklisted (recommendedRegex,
221+ "Tungsten Graphics, Inc",
222+ "Mesa DRI Intel(R) Sandybridge Desktop",
223+ "3.0 Mesa 8.0.2"));
224+}
225+
226+TEST(DriverBlacklist, QuantalNouveauIsGood)
227+{
228+ EXPECT_FALSE (blacklisted (recommendedRegex,
229+ "nouveau",
230+ "Gallium 0.4 on NV86",
231+ "3.0 Mesa 9.0-devel"));
232+}
233+
234+TEST(DriverBlacklist, PreciseNouveauIsBad)
235+{
236+ EXPECT_TRUE (blacklisted (recommendedRegex,
237+ "nouveau",
238+ "Gallium 0.4 on NVA8",
239+ "2.1 Mesa 8.0.2"));
240+}
241+
242+TEST(DriverBlacklist, FglrxIsGood)
243+{
244+ EXPECT_FALSE (blacklisted (recommendedRegex,
245+ "Advanced Micro Devices, Inc.",
246+ "ATI Radeon HD 5450",
247+ "4.2.11627 Compatibility Profile Context"));
248+}
249+
250+TEST(DriverBlacklist, NvidiaIsGood)
251+{
252+ EXPECT_FALSE (blacklisted (recommendedRegex,
253+ "NVIDIA Corporation",
254+ "Quadro 1000M/PCIe/SSE2",
255+ "4.2.0 NVIDIA 304.48"));
256+}
257+
258+TEST(DriverBlacklist, RadeonIsGood1)
259+{
260+ EXPECT_FALSE (blacklisted (recommendedRegex,
261+ "X.Org R300 Project",
262+ "Gallium 0.4 on ATI RV350",
263+ "2.1 Mesa 8.0.2"));
264+}
265+
266+TEST(DriverBlacklist, RadeonIsGood2)
267+{
268+ EXPECT_FALSE (blacklisted (recommendedRegex,
269+ "X.Org",
270+ "Gallium 0.4 on AMD CEDAR",
271+ "2.1 Mesa 8.0.3"));
272+}
273+
274+TEST(DriverBlacklist, RadeonIsGood3)
275+{
276+ EXPECT_FALSE (blacklisted (recommendedRegex,
277+ "X.Org",
278+ "Gallium 0.4 on AMD RS880",
279+ "2.1 Mesa 8.0.2"));
280+}
281+
282+TEST(DriverBlacklist, LLVMpipeIsGood)
283+{
284+ EXPECT_FALSE (blacklisted (recommendedRegex,
285+ "VMware, Inc.",
286+ "Gallium 0.4 on llvmpipe (LLVM 0x300)",
287+ "2.1 Mesa 8.0.4"));
288+}
289+
290+TEST(DriverBlacklist, UnknownIsGood)
291+{
292+ EXPECT_FALSE (blacklisted (recommendedRegex,
293+ "Acme",
294+ "Graphics Driver",
295+ "4.2 8.0 9.0 123.456"));
296+}
297+
298+TEST(DriverBlacklist, NoBlacklist)
299+{
300+ EXPECT_FALSE (blacklisted ("",
301+ "Tungsten Graphics, Inc",
302+ "Mesa DRI Intel(R) Sandybridge Desktop",
303+ "3.0 Mesa 8.0.2"));
304+ EXPECT_FALSE (blacklisted ("", "foo", "bar", "blah"));
305+ EXPECT_FALSE (blacklisted ("", "", "", ""));
306+}
307+
308+TEST(DriverBlacklist, LineContinuation)
309+{
310+ EXPECT_FALSE (blacklisted ("alpha", "beta", "gamma", "delta"));
311+ EXPECT_FALSE (blacklisted ("betagam", "beta", "gamma", "delta"));
312+ EXPECT_TRUE (blacklisted ("gamma", "beta", "gamma", "delta"));
313+ EXPECT_TRUE (blacklisted ("del", "beta", "gamma", "delta"));
314+ EXPECT_TRUE (blacklisted ("(mag|gam)", "beta", "gamma", "delta"));
315+ EXPECT_TRUE (blacklisted ("beta.*delt", "beta", "gamma", "delta"));
316+ EXPECT_FALSE (blacklisted ("beta.*felt", "beta", "gamma", "delta"));
317+
318+ EXPECT_TRUE (blacklisted ("beta\ngamma\ndelta", "beta", "gamma", "delta"));
319+}
320+
321+TEST(DriverBlacklist, StraySpaces)
322+{
323+ EXPECT_FALSE (blacklisted (" ", "Hello world", "and", "goodbye"));
324+ EXPECT_FALSE (blacklisted (" ", " ", " ", " "));
325+ EXPECT_FALSE (blacklisted (" ",
326+ "Tungsten Graphics, Inc",
327+ "Mesa DRI Intel(R) Sandybridge Desktop",
328+ "3.0 Mesa 8.0.2"));
329+}
330
331=== modified file 'plugins/opengl/src/paint.cpp'
332--- plugins/opengl/src/paint.cpp 2012-12-12 03:47:13 +0000
333+++ plugins/opengl/src/paint.cpp 2012-12-13 08:05:23 +0000
334@@ -231,6 +231,11 @@
335 CompMatch &unredirectable = CompositeScreen::get (screen)->
336 getOption ("unredirect_match")->value ().match ();
337
338+ const CompString &blacklist =
339+ getOption ("unredirect_driver_blacklist")->value ().s ();
340+
341+ bool blacklisted = driverIsBlacklisted (blacklist.c_str ());
342+
343 if (mask & PAINT_SCREEN_TRANSFORMED_MASK)
344 {
345 windowMask = PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;
346@@ -324,6 +329,7 @@
347 * beneath them and so neither should be unredirected in that case.
348 */
349 if (unredirectFS &&
350+ !blacklisted &&
351 unredirectable.evaluate (w) &&
352 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
353 !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
354
355=== modified file 'plugins/opengl/src/privates.h'
356--- plugins/opengl/src/privates.h 2012-02-08 10:54:35 +0000
357+++ plugins/opengl/src/privates.h 2012-12-13 08:05:23 +0000
358@@ -87,6 +87,8 @@
359
360 void updateView ();
361
362+ bool driverIsBlacklisted (const char *regex) const;
363+
364 public:
365
366 GLScreen *gScreen;
367@@ -127,6 +129,8 @@
368
369 Pixmap rootPixmapCopy;
370 CompSize rootPixmapSize;
371+
372+ const char *glVendor, *glRenderer, *glVersion;
373 };
374
375 class PrivateGLWindow :
376
377=== modified file 'plugins/opengl/src/screen.cpp'
378--- plugins/opengl/src/screen.cpp 2012-11-12 09:24:02 +0000
379+++ plugins/opengl/src/screen.cpp 2012-12-13 08:05:23 +0000
380@@ -26,6 +26,7 @@
381 */
382
383 #include "privates.h"
384+#include "blacklist/blacklist.h"
385
386 #include <dlfcn.h>
387 #include <math.h>
388@@ -81,6 +82,8 @@
389 unsigned int unthrottledFrames = 0;
390 }
391
392+using namespace compiz::opengl;
393+
394 CompOutput *targetOutput = NULL;
395
396 bool
397@@ -92,7 +95,6 @@
398 GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 0.0f };
399 GLfloat diffuseLight[] = { 0.9f, 0.9f, 0.9f, 0.9f };
400 GLfloat light0Position[] = { -0.5f, 0.5f, -9.0f, 1.0f };
401- const char *glRenderer;
402 CompOption::Vector o (0);
403
404 priv->ctx = glXCreateContext (dpy, visinfo, NULL, True);
405@@ -131,7 +133,14 @@
406 return false;
407 }
408
409- glRenderer = (const char *) glGetString (GL_RENDERER);
410+ const char *glVendor = (const char *) glGetString (GL_VENDOR);
411+ const char *glRenderer = (const char *) glGetString (GL_RENDERER);
412+ const char *glVersion = (const char *) glGetString (GL_VERSION);
413+
414+ priv->glVendor = glVendor;
415+ priv->glRenderer = glRenderer;
416+ priv->glVersion = glVersion;
417+
418 if (glRenderer != NULL &&
419 (strcmp (glRenderer, "Software Rasterizer") == 0 ||
420 strcmp (glRenderer, "Mesa X11") == 0))
421@@ -591,7 +600,10 @@
422 bindPixmap (),
423 hasCompositing (false),
424 rootPixmapCopy (None),
425- rootPixmapSize ()
426+ rootPixmapSize (),
427+ glVendor (NULL),
428+ glRenderer (NULL),
429+ glVersion (NULL)
430 {
431 ScreenInterface::setHandler (screen);
432 }
433@@ -1291,6 +1303,12 @@
434 }
435 }
436
437+bool
438+PrivateGLScreen::driverIsBlacklisted (const char *regex) const
439+{
440+ return blacklisted (regex, glVendor, glRenderer, glVersion);
441+}
442+
443 GLTexture::BindPixmapHandle
444 GLScreen::registerBindPixmap (GLTexture::BindPixmapProc proc)
445 {

Subscribers

People subscribed via source and target branches