Merge lp:~compiz-team/compiz-core/compiz-core.fix_873384 into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 2887
Proposed branch: lp:~compiz-team/compiz-core/compiz-core.fix_873384
Merge into: lp:compiz-core/0.9.5
Diff against target: 610 lines (+147/-262)
5 files modified
plugins/composite/src/privates.h (+0/-6)
plugins/composite/src/screen.cpp (+47/-113)
plugins/place/place.xml.in (+1/-1)
src/screen.cpp (+98/-141)
src/window.cpp (+1/-1)
To merge this branch: bzr merge lp:~compiz-team/compiz-core/compiz-core.fix_873384
Reviewer Review Type Date Requested Status
Robert Carr (community) Approve
Review via email: mp+79458@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Robert Carr (robertcarr) wrote :

+1

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 2011-10-08 11:38:21 +0000
3+++ plugins/composite/src/privates.h 2011-10-15 07:11:56 +0000
4@@ -114,12 +114,6 @@
5 int frameTimeAccumulator;
6
7 CompWindowList withDestroyedWindows;
8-
9- Window cmSnOwner;
10- Atom cmSnAtom;
11- Atom netCmHandoffAtom;
12- bool netCmHandoffSupported;
13- bool mInit;
14 };
15
16 class PrivateCompositeWindow : WindowInterface
17
18=== modified file 'plugins/composite/src/screen.cpp'
19--- plugins/composite/src/screen.cpp 2011-10-08 11:38:21 +0000
20+++ plugins/composite/src/screen.cpp 2011-10-15 07:11:56 +0000
21@@ -199,7 +199,6 @@
22 priv (new PrivateCompositeScreen (this))
23 {
24 int compositeMajor, compositeMinor;
25- XSetWindowAttributes attr;
26
27 if (!XQueryExtension (s->dpy (), COMPOSITE_NAME,
28 &priv->compositeOpcode,
29@@ -249,27 +248,23 @@
30
31 priv->slowAnimations = false;
32
33- attr.override_redirect = true;
34- attr.event_mask = PropertyChangeMask;
35-
36- priv->cmSnOwner =
37- XCreateWindow (screen->dpy (), screen->root (),
38- -100, -100, 1, 1, 0,
39- CopyFromParent, CopyFromParent,
40- CopyFromParent,
41- CWOverrideRedirect | CWEventMask,
42- &attr);
43+ if (!priv->init ())
44+ {
45+ setFailed ();
46+ }
47
48 }
49
50 CompositeScreen::~CompositeScreen ()
51 {
52 priv->paintTimer.stop ();
53+
54 #ifdef USE_COW
55 if (useCow)
56 XCompositeReleaseOverlayWindow (screen->dpy (),
57 screen->root ());
58 #endif
59+
60 delete priv;
61 }
62
63@@ -294,21 +289,12 @@
64 pHnd (NULL),
65 FPSLimiterMode (CompositeFPSLimiterModeDefault),
66 frameTimeAccumulator (0),
67- withDestroyedWindows (),
68- cmSnOwner (0),
69- netCmHandoffAtom (XInternAtom (screen->dpy (), "_COMPIZ_NET_CM_HANDOFF", 0)),
70- netCmHandoffSupported (false),
71- mInit (false)
72+ withDestroyedWindows ()
73 {
74- std::ostringstream oss;
75 gettimeofday (&lastRedraw, 0);
76 // wrap outputChangeNotify
77 ScreenInterface::setHandler (screen);
78
79- oss << "_NET_WM_CM_S%d" << std::dec << screen->screenNum ();
80-
81- cmSnAtom = XInternAtom (screen->dpy (), oss.str ().c_str (), 0);
82-
83 optionSetSlowAnimationsKeyInitiate (CompositeScreen::toggleSlowAnimations);
84 }
85
86@@ -320,16 +306,21 @@
87 PrivateCompositeScreen::init ()
88 {
89 Display *dpy = screen->dpy ();
90+ Window newCmSnOwner = None;
91+ Atom cmSnAtom = 0;
92 Time cmSnTimestamp = 0;
93 XEvent event;
94+ XSetWindowAttributes attr;
95 Window currentCmSnOwner;
96- int value = 0;
97+ char buf[128];
98+
99+ sprintf (buf, "_NET_WM_CM_S%d", screen->screenNum ());
100+ cmSnAtom = XInternAtom (dpy, buf, 0);
101
102 currentCmSnOwner = XGetSelectionOwner (dpy, cmSnAtom);
103
104 if (currentCmSnOwner != None)
105 {
106- XSelectInput (screen->dpy (), currentCmSnOwner, StructureNotifyMask);
107 if (!replaceCurrentWm)
108 {
109 compLogMessage ("composite", CompLogLevelError,
110@@ -343,19 +334,28 @@
111 }
112 }
113
114- XChangeProperty (dpy, cmSnOwner, netCmHandoffAtom, XA_INTEGER, 8,
115- PropModeReplace, (unsigned char *) &value, 1);
116- XChangeProperty (dpy, cmSnOwner, Atoms::wmName, Atoms::utf8String, 8,
117+ attr.override_redirect = true;
118+ attr.event_mask = PropertyChangeMask;
119+
120+ newCmSnOwner =
121+ XCreateWindow (dpy, screen->root (),
122+ -100, -100, 1, 1, 0,
123+ CopyFromParent, CopyFromParent,
124+ CopyFromParent,
125+ CWOverrideRedirect | CWEventMask,
126+ &attr);
127+
128+ XChangeProperty (dpy, newCmSnOwner, Atoms::wmName, Atoms::utf8String, 8,
129 PropModeReplace, (unsigned char *) PACKAGE,
130 strlen (PACKAGE));
131
132- XWindowEvent (dpy, cmSnOwner, PropertyChangeMask, &event);
133+ XWindowEvent (dpy, newCmSnOwner, PropertyChangeMask, &event);
134
135 cmSnTimestamp = event.xproperty.time;
136
137- XSetSelectionOwner (dpy, cmSnAtom, cmSnOwner, cmSnTimestamp);
138+ XSetSelectionOwner (dpy, cmSnAtom, newCmSnOwner, cmSnTimestamp);
139
140- if (XGetSelectionOwner (dpy, cmSnAtom) != cmSnOwner)
141+ if (XGetSelectionOwner (dpy, cmSnAtom) != newCmSnOwner)
142 {
143 compLogMessage ("core", CompLogLevelError,
144 "Could not acquire compositing manager "
145@@ -378,20 +378,6 @@
146
147 XSendEvent (dpy, screen->root (), FALSE, StructureNotifyMask, &event);
148
149- if (netCmHandoffSupported)
150- {
151- /* Wait for old compositing manager to go away */
152- if (currentCmSnOwner != None)
153- {
154- do {
155- XWindowEvent (dpy, currentCmSnOwner, StructureNotifyMask, &event);
156- } while (event.type != DestroyNotify);
157- }
158-
159- XCompositeRedirectSubwindows (dpy, screen->root (),
160- CompositeRedirectManual);
161- }
162-
163 return true;
164 }
165
166@@ -400,46 +386,25 @@
167 CompositeScreen::registerPaintHandler (PaintHandler *pHnd)
168 {
169 Display *dpy = screen->dpy ();
170- Window currentCmSnOwner = 0;
171- int updateMode = 0;
172
173 if (priv->active)
174 return false;
175
176 CompScreen::checkForError (dpy);
177
178- /* Check if the previous compositor (if one is around)
179- * supports the _NET_CM_HANDOFF protocol, if so then
180- * we need to do an automatic redirect and paint the
181- * scene once and then tell it to go away */
182- priv->netCmHandoffSupported = false;
183- currentCmSnOwner = XGetSelectionOwner (screen->dpy (), priv->cmSnAtom);
184-
185- if (currentCmSnOwner != priv->cmSnOwner)
186- {
187- Atom type;
188- int fmt;
189- unsigned long nitems, nleft;
190- unsigned char *prop;
191-
192- if (XGetWindowProperty (screen->dpy (), currentCmSnOwner, priv->netCmHandoffAtom,
193- 0L, 8L, false, XA_INTEGER, &type, &fmt,
194- &nitems, &nleft, &prop) == Success)
195- {
196- if (type == XA_INTEGER && fmt == 8 && nitems != 0 && nleft == 0)
197- {
198- priv->netCmHandoffSupported = true;
199- }
200-
201- XFree (prop);
202- }
203- }
204-
205- priv->netCmHandoffSupported ? updateMode = CompositeRedirectAutomatic :
206- updateMode = CompositeRedirectManual;
207-
208 XCompositeRedirectSubwindows (dpy, screen->root (),
209- updateMode);
210+ CompositeRedirectManual);
211+
212+ priv->overlayWindowCount = 0;
213+
214+ if (CompScreen::checkForError (dpy))
215+ {
216+ compLogMessage ("composite", CompLogLevelError,
217+ "Another composite manager is already "
218+ "running on screen: %d", screen->screenNum ());
219+
220+ return false;
221+ }
222
223 foreach (CompWindow *w, screen->windows ())
224 {
225@@ -457,19 +422,13 @@
226 (boost::bind (&CompositeScreen::handlePaintTimeout, this),
227 priv->optimalRedrawTime);
228
229- if (priv->netCmHandoffSupported)
230- priv->paintTimer.setTimes (0, 0);
231-
232 return true;
233 }
234
235 void
236 CompositeScreen::unregisterPaintHandler ()
237 {
238- XEvent ev;
239 Display *dpy = screen->dpy ();
240- bool oldCmSupportsHandoff = false;
241- Window currentCmSnOwner = None;
242
243 foreach (CompWindow *w, screen->windows ())
244 {
245@@ -481,38 +440,14 @@
246
247 priv->overlayWindowCount = 0;
248
249+ XCompositeUnredirectSubwindows (dpy, screen->root (),
250+ CompositeRedirectManual);
251+
252 priv->pHnd = NULL;
253 priv->active = false;
254 priv->paintTimer.stop ();
255
256- Atom type;
257- int fmt;
258- unsigned long nitems, nleft;
259- unsigned char *prop;
260-
261- /* Polling like this is very ugly */
262- while (currentCmSnOwner != priv->cmSnOwner)
263- currentCmSnOwner = XGetSelectionOwner (screen->dpy (), priv->cmSnAtom);
264-
265- if (XGetWindowProperty (screen->dpy (), currentCmSnOwner, priv->netCmHandoffAtom,
266- 0L, 8L, false, XA_INTEGER, &type, &fmt,
267- &nitems, &nleft, &prop) == Success)
268- {
269- if (type == XA_INTEGER && fmt == 8 && nitems != 0 && nleft == 0)
270- {
271- oldCmSupportsHandoff = true;
272- }
273-
274- XFree (prop);
275- }
276-
277- if (oldCmSupportsHandoff)
278- {
279- XCompositeUnredirectSubwindows (dpy, screen->root (),
280- CompositeRedirectManual);
281- }
282- else
283- hideOutputWindow ();
284+ hideOutputWindow ();
285 }
286
287 bool
288@@ -666,6 +601,8 @@
289 else
290 #endif
291 output = overlay = screen->root ();
292+
293+ cScreen->hideOutputWindow ();
294 }
295
296 Window
297@@ -956,9 +893,6 @@
298 else
299 timeToNextRedraw = priv->getTimeToNextRedraw (&tv);
300
301- if (!priv->mInit)
302- priv->mInit = priv->init ();
303-
304 if (priv->idle)
305 priv->paintTimer.setTimes (timeToNextRedraw, MAXSHORT);
306 else
307
308=== modified file 'plugins/place/place.xml.in'
309--- plugins/place/place.xml.in 2010-05-13 15:50:32 +0000
310+++ plugins/place/place.xml.in 2011-10-15 07:11:56 +0000
311@@ -20,7 +20,7 @@
312 <_short>Placement Mode</_short>
313 <_long>Algorithm to use for window placement</_long>
314 <default>0</default>
315- <min>0</min>
316+ <min>2</min>
317 <max>5</max>
318 <desc>
319 <value>0</value>
320
321=== modified file 'src/screen.cpp'
322--- src/screen.cpp 2011-10-08 11:38:21 +0000
323+++ src/screen.cpp 2011-10-15 07:11:56 +0000
324@@ -4460,99 +4460,6 @@
325
326 XSendEvent (dpy, root, FALSE, StructureNotifyMask, &event);
327
328- /* Need to set a default here so that the value isn't uninitialized
329- * when loading plugins FIXME: Should find a way to initialize options
330- * first and then set this value, or better yet, tie this value directly
331- * to the option */
332- priv->vpSize.setWidth (priv->optionGetHsize ());
333- priv->vpSize.setHeight (priv->optionGetVsize ());
334-
335- for (i = 0; i < SCREEN_EDGE_NUM; i++)
336- {
337- priv->screenEdge[i].id = None;
338- priv->screenEdge[i].count = 0;
339- }
340-
341- priv->screenNum = DefaultScreen (dpy);
342- priv->colormap = DefaultColormap (dpy, priv->screenNum);
343- priv->root = root;
344-
345- priv->snContext = sn_monitor_context_new (priv->snDisplay, priv->screenNum,
346- compScreenSnEvent, this, NULL);
347-
348- priv->wmSnSelectionWindow = newWmSnOwner;
349- priv->wmSnAtom = wmSnAtom;
350- priv->wmSnTimestamp = wmSnTimestamp;
351-
352- if (!XGetWindowAttributes (dpy, priv->root, &priv->attrib))
353- return false;
354-
355- priv->workArea.setWidth (priv->attrib.width);
356- priv->workArea.setHeight (priv->attrib.height);
357-
358- priv->grabWindow = None;
359-
360- templ.visualid = XVisualIDFromVisual (priv->attrib.visual);
361-
362- visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
363- if (!nvisinfo)
364- {
365- compLogMessage ("core", CompLogLevelFatal,
366- "Couldn't get visual info for default visual");
367- return false;
368- }
369-
370- black.red = black.green = black.blue = 0;
371-
372- if (!XAllocColor (dpy, priv->colormap, &black))
373- {
374- compLogMessage ("core", CompLogLevelFatal,
375- "Couldn't allocate color");
376- XFree (visinfo);
377- return false;
378- }
379-
380- bitmap = XCreateBitmapFromData (dpy, priv->root, &data, 1, 1);
381- if (!bitmap)
382- {
383- compLogMessage ("core", CompLogLevelFatal,
384- "Couldn't create bitmap");
385- XFree (visinfo);
386- return false;
387- }
388-
389- priv->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
390- &black, &black, 0, 0);
391- if (!priv->invisibleCursor)
392- {
393- compLogMessage ("core", CompLogLevelFatal,
394- "Couldn't create invisible cursor");
395- XFree (visinfo);
396- return false;
397- }
398-
399- XFreePixmap (dpy, bitmap);
400- XFreeColors (dpy, priv->colormap, &black.pixel, 1, 0);
401-
402- XFree (visinfo);
403-
404- priv->reshape (priv->attrib.width, priv->attrib.height);
405-
406- priv->detectOutputDevices ();
407- priv->updateOutputDevices ();
408-
409- priv->getDesktopHints ();
410-
411- priv->initialized = true;
412-
413- /* TODO: Bailout properly when screenInitPlugins fails
414- * TODO: It would be nicer if this line could mean
415- * "init all the screens", but unfortunately it only inits
416- * plugins loaded on the command line screen's and then
417- * we need to call updatePlugins () to init the remaining
418- * screens from option changes */
419- assert (CompPlugin::screenInitPlugins (this));
420-
421 /* Wait for old window manager to go away */
422 if (currentWmSnOwner != None)
423 {
424@@ -4615,6 +4522,82 @@
425 return false;
426 }
427
428+ for (i = 0; i < SCREEN_EDGE_NUM; i++)
429+ {
430+ priv->screenEdge[i].id = None;
431+ priv->screenEdge[i].count = 0;
432+ }
433+
434+ priv->screenNum = DefaultScreen (dpy);
435+ priv->colormap = DefaultColormap (dpy, priv->screenNum);
436+ priv->root = root;
437+
438+ priv->snContext = sn_monitor_context_new (priv->snDisplay, priv->screenNum,
439+ compScreenSnEvent, this, NULL);
440+
441+ priv->wmSnSelectionWindow = newWmSnOwner;
442+ priv->wmSnAtom = wmSnAtom;
443+ priv->wmSnTimestamp = wmSnTimestamp;
444+
445+ if (!XGetWindowAttributes (dpy, priv->root, &priv->attrib))
446+ return false;
447+
448+ priv->workArea.setWidth (priv->attrib.width);
449+ priv->workArea.setHeight (priv->attrib.height);
450+
451+ priv->grabWindow = None;
452+
453+ templ.visualid = XVisualIDFromVisual (priv->attrib.visual);
454+
455+ visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
456+ if (!nvisinfo)
457+ {
458+ compLogMessage ("core", CompLogLevelFatal,
459+ "Couldn't get visual info for default visual");
460+ return false;
461+ }
462+
463+ black.red = black.green = black.blue = 0;
464+
465+ if (!XAllocColor (dpy, priv->colormap, &black))
466+ {
467+ compLogMessage ("core", CompLogLevelFatal,
468+ "Couldn't allocate color");
469+ XFree (visinfo);
470+ return false;
471+ }
472+
473+ bitmap = XCreateBitmapFromData (dpy, priv->root, &data, 1, 1);
474+ if (!bitmap)
475+ {
476+ compLogMessage ("core", CompLogLevelFatal,
477+ "Couldn't create bitmap");
478+ XFree (visinfo);
479+ return false;
480+ }
481+
482+ priv->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
483+ &black, &black, 0, 0);
484+ if (!priv->invisibleCursor)
485+ {
486+ compLogMessage ("core", CompLogLevelFatal,
487+ "Couldn't create invisible cursor");
488+ XFree (visinfo);
489+ return false;
490+ }
491+
492+ XFreePixmap (dpy, bitmap);
493+ XFreeColors (dpy, priv->colormap, &black.pixel, 1, 0);
494+
495+ XFree (visinfo);
496+
497+ priv->reshape (priv->attrib.width, priv->attrib.height);
498+
499+ priv->detectOutputDevices ();
500+ priv->updateOutputDevices ();
501+
502+ priv->getDesktopHints ();
503+
504 attrib.override_redirect = 1;
505 attrib.event_mask = PropertyChangeMask;
506
507@@ -4731,46 +4714,25 @@
508 focusDefaultWindow ();
509 }
510
511- /* Dispatch any queued timers */
512- while (TimeoutHandler::Default ()->timers ().begin () != TimeoutHandler::Default ()->timers ().end ())
513- {
514- if (TimeoutHandler::Default ()->timers ().front ()->minLeft () <= 0)
515- {
516- CompTimer *t = TimeoutHandler::Default ()->timers ().front ();
517- TimeoutHandler::Default ()->timers ().pop_front ();
518-
519- t->setActive (false);
520- if (t->triggerCallback ())
521- {
522- TimeoutHandler::Default ()->addTimer (t);
523- t->setActive (true);
524- }
525- }
526- else
527- break;
528- }
529-
530- if (priv->dirtyPluginList)
531- priv->updatePlugins ();
532-
533- /* Dispatch any queued timers */
534- while (TimeoutHandler::Default ()->timers ().begin () != TimeoutHandler::Default ()->timers ().end ())
535- {
536- if (TimeoutHandler::Default ()->timers ().front ()->minLeft () <= 0)
537- {
538- CompTimer *t = TimeoutHandler::Default ()->timers ().front ();
539- TimeoutHandler::Default ()->timers ().pop_front ();
540-
541- t->setActive (false);
542- if (t->triggerCallback ())
543- {
544- TimeoutHandler::Default ()->addTimer (t);
545- t->setActive (true);
546- }
547- }
548- else
549- break;
550- }
551+ /* Need to set a default here so that the value isn't uninitialized
552+ * when loading plugins FIXME: Should find a way to initialize options
553+ * first and then set this value, or better yet, tie this value directly
554+ * to the option */
555+ priv->vpSize.setWidth (priv->optionGetHsize ());
556+ priv->vpSize.setHeight (priv->optionGetVsize ());
557+
558+ priv->initialized = true;
559+
560+ /* TODO: Bailout properly when screenInitPlugins fails
561+ * TODO: It would be nicer if this line could mean
562+ * "init all the screens", but unfortunately it only inits
563+ * plugins loaded on the command line screen's and then
564+ * we need to call updatePlugins () to init the remaining
565+ * screens from option changes */
566+ assert (CompPlugin::screenInitPlugins (this));
567+
568+ /* The active plugins list might have been changed - load any
569+ * new plugins */
570
571 priv->vpSize.setWidth (priv->optionGetHsize ());
572 priv->vpSize.setHeight (priv->optionGetVsize ());
573@@ -4799,6 +4761,9 @@
574 while (!priv->windows.empty ())
575 delete priv->windows.front ();
576
577+ while ((p = CompPlugin::pop ()))
578+ CompPlugin::unload (p);
579+
580 XUngrabKey (priv->dpy, AnyKey, AnyModifier, priv->root);
581
582 priv->initialized = false;
583@@ -4822,14 +4787,6 @@
584 if (priv->snDisplay)
585 sn_display_unref (priv->snDisplay);
586
587- /* Remove our selection */
588- XSelectInput (priv->dpy, priv->root, NoEventMask);
589- XDestroyWindow (screen->dpy (), priv->wmSnSelectionWindow);
590- XSync (screen->dpy (), FALSE);
591-
592- while ((p = CompPlugin::pop ()))
593- CompPlugin::unload (p);
594-
595 XSync (priv->dpy, False);
596 XCloseDisplay (priv->dpy);
597
598
599=== modified file 'src/window.cpp'
600--- src/window.cpp 2011-10-11 09:36:19 +0000
601+++ src/window.cpp 2011-10-15 07:11:56 +0000
602@@ -6517,7 +6517,7 @@
603 priv->desktop = screen->currentDesktop ();
604
605 screen->setWindowProp (priv->id, Atoms::winDesktop,
606- priv->desktop);
607+ priv->desktop);
608 }
609 }
610 }

Subscribers

People subscribed via source and target branches