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

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 2886
Proposed branch: lp:~compiz-team/compiz-core/compiz-core.fix_873389
Merge into: lp:compiz-core/0.9.5
Diff against target: 621 lines (+157/-263)
5 files modified
plugins/composite/src/privates.h (+0/-6)
plugins/composite/src/screen.cpp (+47/-113)
src/main.cpp (+11/-2)
src/screen.cpp (+98/-141)
src/window.cpp (+1/-1)
To merge this branch: bzr merge lp:~compiz-team/compiz-core/compiz-core.fix_873389
Reviewer Review Type Date Requested Status
Robert Carr (community) Approve
Review via email: mp+79457@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:07:10 +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:07:10 +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 'src/main.cpp'
309--- src/main.cpp 2011-09-19 12:54:22 +0000
310+++ src/main.cpp 2011-10-15 07:07:10 +0000
311@@ -234,8 +234,17 @@
312 screen->priv)));
313 }
314
315- if (!disableSm)
316- CompSession::init (clientId);
317+ if (!disableSm)
318+ {
319+ if (clientId == NULL)
320+ {
321+ char *desktop_autostart_id = getenv ("DESKTOP_AUTOSTART_ID");
322+ if (desktop_autostart_id != NULL)
323+ clientId = strdup (desktop_autostart_id);
324+ unsetenv ("DESKTOP_AUTOSTART_ID");
325+ }
326+ CompSession::init (clientId);
327+ }
328
329 return true;
330 }
331
332=== modified file 'src/screen.cpp'
333--- src/screen.cpp 2011-10-08 11:38:21 +0000
334+++ src/screen.cpp 2011-10-15 07:07:10 +0000
335@@ -4460,99 +4460,6 @@
336
337 XSendEvent (dpy, root, FALSE, StructureNotifyMask, &event);
338
339- /* Need to set a default here so that the value isn't uninitialized
340- * when loading plugins FIXME: Should find a way to initialize options
341- * first and then set this value, or better yet, tie this value directly
342- * to the option */
343- priv->vpSize.setWidth (priv->optionGetHsize ());
344- priv->vpSize.setHeight (priv->optionGetVsize ());
345-
346- for (i = 0; i < SCREEN_EDGE_NUM; i++)
347- {
348- priv->screenEdge[i].id = None;
349- priv->screenEdge[i].count = 0;
350- }
351-
352- priv->screenNum = DefaultScreen (dpy);
353- priv->colormap = DefaultColormap (dpy, priv->screenNum);
354- priv->root = root;
355-
356- priv->snContext = sn_monitor_context_new (priv->snDisplay, priv->screenNum,
357- compScreenSnEvent, this, NULL);
358-
359- priv->wmSnSelectionWindow = newWmSnOwner;
360- priv->wmSnAtom = wmSnAtom;
361- priv->wmSnTimestamp = wmSnTimestamp;
362-
363- if (!XGetWindowAttributes (dpy, priv->root, &priv->attrib))
364- return false;
365-
366- priv->workArea.setWidth (priv->attrib.width);
367- priv->workArea.setHeight (priv->attrib.height);
368-
369- priv->grabWindow = None;
370-
371- templ.visualid = XVisualIDFromVisual (priv->attrib.visual);
372-
373- visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
374- if (!nvisinfo)
375- {
376- compLogMessage ("core", CompLogLevelFatal,
377- "Couldn't get visual info for default visual");
378- return false;
379- }
380-
381- black.red = black.green = black.blue = 0;
382-
383- if (!XAllocColor (dpy, priv->colormap, &black))
384- {
385- compLogMessage ("core", CompLogLevelFatal,
386- "Couldn't allocate color");
387- XFree (visinfo);
388- return false;
389- }
390-
391- bitmap = XCreateBitmapFromData (dpy, priv->root, &data, 1, 1);
392- if (!bitmap)
393- {
394- compLogMessage ("core", CompLogLevelFatal,
395- "Couldn't create bitmap");
396- XFree (visinfo);
397- return false;
398- }
399-
400- priv->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
401- &black, &black, 0, 0);
402- if (!priv->invisibleCursor)
403- {
404- compLogMessage ("core", CompLogLevelFatal,
405- "Couldn't create invisible cursor");
406- XFree (visinfo);
407- return false;
408- }
409-
410- XFreePixmap (dpy, bitmap);
411- XFreeColors (dpy, priv->colormap, &black.pixel, 1, 0);
412-
413- XFree (visinfo);
414-
415- priv->reshape (priv->attrib.width, priv->attrib.height);
416-
417- priv->detectOutputDevices ();
418- priv->updateOutputDevices ();
419-
420- priv->getDesktopHints ();
421-
422- priv->initialized = true;
423-
424- /* TODO: Bailout properly when screenInitPlugins fails
425- * TODO: It would be nicer if this line could mean
426- * "init all the screens", but unfortunately it only inits
427- * plugins loaded on the command line screen's and then
428- * we need to call updatePlugins () to init the remaining
429- * screens from option changes */
430- assert (CompPlugin::screenInitPlugins (this));
431-
432 /* Wait for old window manager to go away */
433 if (currentWmSnOwner != None)
434 {
435@@ -4615,6 +4522,82 @@
436 return false;
437 }
438
439+ for (i = 0; i < SCREEN_EDGE_NUM; i++)
440+ {
441+ priv->screenEdge[i].id = None;
442+ priv->screenEdge[i].count = 0;
443+ }
444+
445+ priv->screenNum = DefaultScreen (dpy);
446+ priv->colormap = DefaultColormap (dpy, priv->screenNum);
447+ priv->root = root;
448+
449+ priv->snContext = sn_monitor_context_new (priv->snDisplay, priv->screenNum,
450+ compScreenSnEvent, this, NULL);
451+
452+ priv->wmSnSelectionWindow = newWmSnOwner;
453+ priv->wmSnAtom = wmSnAtom;
454+ priv->wmSnTimestamp = wmSnTimestamp;
455+
456+ if (!XGetWindowAttributes (dpy, priv->root, &priv->attrib))
457+ return false;
458+
459+ priv->workArea.setWidth (priv->attrib.width);
460+ priv->workArea.setHeight (priv->attrib.height);
461+
462+ priv->grabWindow = None;
463+
464+ templ.visualid = XVisualIDFromVisual (priv->attrib.visual);
465+
466+ visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
467+ if (!nvisinfo)
468+ {
469+ compLogMessage ("core", CompLogLevelFatal,
470+ "Couldn't get visual info for default visual");
471+ return false;
472+ }
473+
474+ black.red = black.green = black.blue = 0;
475+
476+ if (!XAllocColor (dpy, priv->colormap, &black))
477+ {
478+ compLogMessage ("core", CompLogLevelFatal,
479+ "Couldn't allocate color");
480+ XFree (visinfo);
481+ return false;
482+ }
483+
484+ bitmap = XCreateBitmapFromData (dpy, priv->root, &data, 1, 1);
485+ if (!bitmap)
486+ {
487+ compLogMessage ("core", CompLogLevelFatal,
488+ "Couldn't create bitmap");
489+ XFree (visinfo);
490+ return false;
491+ }
492+
493+ priv->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
494+ &black, &black, 0, 0);
495+ if (!priv->invisibleCursor)
496+ {
497+ compLogMessage ("core", CompLogLevelFatal,
498+ "Couldn't create invisible cursor");
499+ XFree (visinfo);
500+ return false;
501+ }
502+
503+ XFreePixmap (dpy, bitmap);
504+ XFreeColors (dpy, priv->colormap, &black.pixel, 1, 0);
505+
506+ XFree (visinfo);
507+
508+ priv->reshape (priv->attrib.width, priv->attrib.height);
509+
510+ priv->detectOutputDevices ();
511+ priv->updateOutputDevices ();
512+
513+ priv->getDesktopHints ();
514+
515 attrib.override_redirect = 1;
516 attrib.event_mask = PropertyChangeMask;
517
518@@ -4731,46 +4714,25 @@
519 focusDefaultWindow ();
520 }
521
522- /* Dispatch any queued timers */
523- while (TimeoutHandler::Default ()->timers ().begin () != TimeoutHandler::Default ()->timers ().end ())
524- {
525- if (TimeoutHandler::Default ()->timers ().front ()->minLeft () <= 0)
526- {
527- CompTimer *t = TimeoutHandler::Default ()->timers ().front ();
528- TimeoutHandler::Default ()->timers ().pop_front ();
529-
530- t->setActive (false);
531- if (t->triggerCallback ())
532- {
533- TimeoutHandler::Default ()->addTimer (t);
534- t->setActive (true);
535- }
536- }
537- else
538- break;
539- }
540-
541- if (priv->dirtyPluginList)
542- priv->updatePlugins ();
543-
544- /* Dispatch any queued timers */
545- while (TimeoutHandler::Default ()->timers ().begin () != TimeoutHandler::Default ()->timers ().end ())
546- {
547- if (TimeoutHandler::Default ()->timers ().front ()->minLeft () <= 0)
548- {
549- CompTimer *t = TimeoutHandler::Default ()->timers ().front ();
550- TimeoutHandler::Default ()->timers ().pop_front ();
551-
552- t->setActive (false);
553- if (t->triggerCallback ())
554- {
555- TimeoutHandler::Default ()->addTimer (t);
556- t->setActive (true);
557- }
558- }
559- else
560- break;
561- }
562+ /* Need to set a default here so that the value isn't uninitialized
563+ * when loading plugins FIXME: Should find a way to initialize options
564+ * first and then set this value, or better yet, tie this value directly
565+ * to the option */
566+ priv->vpSize.setWidth (priv->optionGetHsize ());
567+ priv->vpSize.setHeight (priv->optionGetVsize ());
568+
569+ priv->initialized = true;
570+
571+ /* TODO: Bailout properly when screenInitPlugins fails
572+ * TODO: It would be nicer if this line could mean
573+ * "init all the screens", but unfortunately it only inits
574+ * plugins loaded on the command line screen's and then
575+ * we need to call updatePlugins () to init the remaining
576+ * screens from option changes */
577+ assert (CompPlugin::screenInitPlugins (this));
578+
579+ /* The active plugins list might have been changed - load any
580+ * new plugins */
581
582 priv->vpSize.setWidth (priv->optionGetHsize ());
583 priv->vpSize.setHeight (priv->optionGetVsize ());
584@@ -4799,6 +4761,9 @@
585 while (!priv->windows.empty ())
586 delete priv->windows.front ();
587
588+ while ((p = CompPlugin::pop ()))
589+ CompPlugin::unload (p);
590+
591 XUngrabKey (priv->dpy, AnyKey, AnyModifier, priv->root);
592
593 priv->initialized = false;
594@@ -4822,14 +4787,6 @@
595 if (priv->snDisplay)
596 sn_display_unref (priv->snDisplay);
597
598- /* Remove our selection */
599- XSelectInput (priv->dpy, priv->root, NoEventMask);
600- XDestroyWindow (screen->dpy (), priv->wmSnSelectionWindow);
601- XSync (screen->dpy (), FALSE);
602-
603- while ((p = CompPlugin::pop ()))
604- CompPlugin::unload (p);
605-
606 XSync (priv->dpy, False);
607 XCloseDisplay (priv->dpy);
608
609
610=== modified file 'src/window.cpp'
611--- src/window.cpp 2011-10-11 09:36:19 +0000
612+++ src/window.cpp 2011-10-15 07:07:10 +0000
613@@ -6517,7 +6517,7 @@
614 priv->desktop = screen->currentDesktop ();
615
616 screen->setWindowProp (priv->id, Atoms::winDesktop,
617- priv->desktop);
618+ priv->desktop);
619 }
620 }
621 }

Subscribers

People subscribed via source and target branches