Merge lp:~vanvugt/compiz-core/fix-composite-init-fail into lp:compiz-core

Proposed by Daniel van Vugt
Status: Merged
Approved by: Alan Griffiths
Approved revision: 3070
Merged at revision: 3070
Proposed branch: lp:~vanvugt/compiz-core/fix-composite-init-fail
Merge into: lp:compiz-core
Diff against target: 99 lines (+13/-31)
2 files modified
plugins/composite/src/privates.h (+3/-0)
plugins/composite/src/screen.cpp (+10/-31)
To merge this branch: bzr merge lp:~vanvugt/compiz-core/fix-composite-init-fail
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
Sam Spilsbury Approve
Review via email: mp+99506@code.launchpad.net

Description of the change

Fixed: Composite would fail to initialize even when it was the only
composite window manage running. This was because it leaked its handles
and in the unusual cases where plugin load failures cause other plugins to
unload/reload, composite would fail to init the second time.
(LP: #963465) (LP: #963264) (LP: #833729)

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

That's fine.

The XSetSelectionOwner call is probably unnecessary as the protocol does this implicitly. But it doesn't hurt. Bonus points for making a class to wrap the selection atom.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/composite/src/privates.h'
2--- plugins/composite/src/privates.h 2012-02-08 10:54:35 +0000
3+++ plugins/composite/src/privates.h 2012-03-27 12:21:44 +0000
4@@ -103,6 +103,9 @@
5 CompositeFPSLimiterMode FPSLimiterMode;
6
7 CompWindowList withDestroyedWindows;
8+
9+ Atom cmSnAtom;
10+ Window newCmSnOwner;
11 };
12
13 class PrivateCompositeWindow : WindowInterface
14
15=== modified file 'plugins/composite/src/screen.cpp'
16--- plugins/composite/src/screen.cpp 2012-03-23 09:30:55 +0000
17+++ plugins/composite/src/screen.cpp 2012-03-27 12:21:44 +0000
18@@ -45,9 +45,6 @@
19
20 #include <core/timer.h>
21
22-#include <cstdlib>
23-#include <cstdio>
24-
25 CompWindow *lastDamagedWindow = 0;
26
27 void
28@@ -198,26 +195,6 @@
29 return priv->damageEvent;
30 }
31
32-/* TODO - remove these macros, also <cstdio> and <cstdlib> above.
33- *
34- * We're seeing errors in code that tries to use composite after
35- * it fails to initialise.
36- *
37- * I agree in advance that this macro subverting setFailed() is a
38- * horrible hack. But making the client code either handle errors,
39- * or exception neutral, is a LOT of work.
40- *
41- * This could give us some more immediate feedback on the causes
42- * of failure and a better solution.
43- * Alan Griffiths
44- */
45-#define ARG_STRINGIZE(x) ARG_STRINGIZE_(x)
46-#define ARG_STRINGIZE_(x) #x
47-#define setFailed()\
48-do { \
49- std::fputs("error CompositeScreen::CompositeScreen - line " ARG_STRINGIZE(__LINE__) "\n", stderr);\
50- std::exit(EXIT_FAILURE);\
51-} while (false)
52
53 CompositeScreen::CompositeScreen (CompScreen *s) :
54 PluginClassHandler<CompositeScreen, CompScreen, COMPIZ_COMPOSITE_ABI> (s),
55@@ -280,11 +257,6 @@
56
57 }
58
59-#undef ARG_STRINGIZE
60-#undef ARG_STRINGIZE_
61-#undef setFailed
62-
63-
64 CompositeScreen::~CompositeScreen ()
65 {
66 priv->paintTimer.stop ();
67@@ -310,7 +282,9 @@
68 slowAnimations (false),
69 pHnd (NULL),
70 FPSLimiterMode (CompositeFPSLimiterModeDefault),
71- withDestroyedWindows ()
72+ withDestroyedWindows (),
73+ cmSnAtom (0),
74+ newCmSnOwner (None)
75 {
76 gettimeofday (&lastRedraw, 0);
77 // wrap outputChangeNotify
78@@ -321,14 +295,19 @@
79
80 PrivateCompositeScreen::~PrivateCompositeScreen ()
81 {
82+ Display *dpy = screen->dpy ();
83+
84+ if (cmSnAtom)
85+ XSetSelectionOwner (dpy, cmSnAtom, None, CurrentTime);
86+
87+ if (newCmSnOwner != None)
88+ XDestroyWindow (dpy, newCmSnOwner);
89 }
90
91 bool
92 PrivateCompositeScreen::init ()
93 {
94 Display *dpy = screen->dpy ();
95- Window newCmSnOwner = None;
96- Atom cmSnAtom = 0;
97 Time cmSnTimestamp = 0;
98 XEvent event;
99 XSetWindowAttributes attr;

Subscribers

People subscribed via source and target branches