Merge lp:~mc-return/compiz/compiz.merge-src-screen.cpp-improvements into lp:compiz/0.9.11

Proposed by MC Return
Status: Work in progress
Proposed branch: lp:~mc-return/compiz/compiz.merge-src-screen.cpp-improvements
Merge into: lp:compiz/0.9.11
Diff against target: 3829 lines (+791/-770)
1 file modified
src/screen.cpp (+791/-770)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-src-screen.cpp-improvements
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+176727@code.launchpad.net

Commit message

src/screen.cpp, cleanup:

Merged if condition checks.
Declaration and assignment of variables in one line.
Declaration of variables outside of loops.
Use pre- instead of postfix in- and decrement.
if (something == 0) == if (!something).
Removed redundant brackets.
Added and removed newlines.
Added default case, if missing (just a style issue).
Fixed indentation.
Added TODOs.

src/screen.cpp, other improvements:

Do not assign values to variables, that are never used -
(int i = 0; for example).
int dSize = nDesktop * 2 + nDesktop * 2 + nDesktop * 4 + 1; ==
int dSize = nDesktop * 8 + 1;.

src/screen.cpp, other fixes:

Initialize multiple non-static class member variables (escapeKeyCode,
returnKeyCode, wmSnTimestamp) and fields (attrib) that are not
initialized in the PrivateScreen::PrivateScreen (CompScreen *, compiz::
private_screen::WindowManager &) constructor nor in any functions that it
calls.
(LP: #1101639)

Also initialize the class members xSync, xRandr, xShape, viewPort,
orphanData, outputDevices, colormap, screenNum, fullscreenOutput,
screenEdge, workArea, xkbEvent, xineramaExtension, displayString_,
region, pingTimer, edgeDelaySettings and pluginManager in the same ctor.

Initialize the non-static class member "grabbed" in the EventManager::
EventManager () ctor.
(LP: #1101590)

Description of the change

quilting needs to be adjusted...

dh_quilt_patch
Applying patch ubuntu_super_p.patch
patching file src/screen.cpp
Hunk #1 FAILED at 3253.
1 out of 1 hunk FAILED -- rejects in file src/screen.cpp
Patch ubuntu_super_p.patch does not apply (enforce with -f)
dh_quilt_patch: quilt --quiltrc /dev/null push -a || test $? = 2 returned exit code 1

Still WIP.

To post a comment you must log in.

Unmerged revisions

3758. By MC Return

Merged latest lp:compiz

3757. By MC Return

Initialize multiple non-static class member variables (escapeKeyCode,
returnKeyCode, wmSnTimestamp) and fields (attrib) that are not
initialized in the PrivateScreen::PrivateScreen (CompScreen *, compiz::
private_screen::WindowManager &) constructor nor in any functions that it
calls (LP: #1101639)

Also initialize the class members xSync, xRandr, xShape, viewPort,
orphanData, outputDevices, colormap, screenNum, fullscreenOutput,
screenEdge, workArea, xkbEvent, xineramaExtension, displayString_,
region, pingTimer, edgeDelaySettings and pluginManager in the same ctor

3756. By MC Return

Initialize the non-static class member "grabbed" in the EventManager::
EventManager () ctor
(LP: #1101590)

3755. By MC Return

Fixed minor style ssues

3754. By MC Return

src/screen.cpp, massive cleanup
(please see main commit message for details)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/screen.cpp'
2--- src/screen.cpp 2013-05-13 13:27:30 +0000
3+++ src/screen.cpp 2013-07-24 16:11:44 +0000
4@@ -67,12 +67,12 @@
5
6 CompOutput *targetOutput;
7
8-int lastPointerX = 0;
9-int lastPointerY = 0;
10+int lastPointerX = 0;
11+int lastPointerY = 0;
12 unsigned int lastPointerMods = 0;
13-int pointerX = 0;
14-int pointerY = 0;
15-unsigned int pointerMods = 0;
16+int pointerX = 0;
17+int pointerY = 0;
18+unsigned int pointerMods = 0;
19
20 namespace
21 {
22@@ -85,18 +85,17 @@
23 #define MwmHintsDecorations (1L << 1)
24 static const unsigned short PropMotifWmHintElements = 3;
25
26-typedef struct {
27+typedef struct
28+{
29 unsigned long flags;
30 unsigned long functions;
31 unsigned long decorations;
32 } MwmHints;
33
34 namespace cps = compiz::private_screen;
35-namespace ca = compiz::actions;
36-
37-
38-
39-CompScreen *screen;
40+namespace ca = compiz::actions;
41+
42+CompScreen *screen;
43 ModifierHandler *modHandler;
44
45 PluginClassStorage::Indices screenPluginClassIndices (0);
46@@ -112,9 +111,9 @@
47 privateScreen.setWindowState (state, id);
48 }
49
50-void CompScreenImpl::addToDestroyedWindows(CompWindow * cw)
51+void CompScreenImpl::addToDestroyedWindows (CompWindow * cw)
52 {
53- windowManager.addToDestroyedWindows(cw);
54+ windowManager.addToDestroyedWindows (cw);
55 }
56
57 void CompScreenImpl::processEvents () { privateScreen.processEvents (); }
58@@ -146,10 +145,12 @@
59 case SIGTERM:
60 mainloop->quit ();
61 break;
62+
63 case SIGHUP:
64 restartSignal = true;
65 mainloop->quit ();
66 break;
67+
68 default:
69 break;
70 }
71@@ -160,11 +161,11 @@
72 void
73 CompScreenImpl::eventLoop ()
74 {
75- privateScreen.eventManager.startEventLoop (dpy());
76+ privateScreen.eventManager.startEventLoop (dpy ());
77 }
78
79 void
80-cps::EventManager::startEventLoop(Display* dpy)
81+cps::EventManager::startEventLoop (Display *dpy)
82 {
83 source = CompEventSource::create ();
84 timeout = CompTimeoutSource::create (ctx);
85@@ -173,13 +174,13 @@
86
87 XFlush (dpy);
88
89- mainloop->run();
90+ mainloop->run ();
91 }
92
93 CompFileWatchHandle
94 CompScreenImpl::addFileWatch (const char *path,
95- int mask,
96- FileWatchCallBack callBack)
97+ int mask,
98+ FileWatchCallBack callBack)
99 {
100 CompFileWatch *fileWatch = privateScreen.eventManager.addFileWatch (path, mask, callBack);
101
102@@ -192,17 +193,17 @@
103 }
104
105 CompFileWatch*
106-cps::EventManager::addFileWatch (
107- const char *path,
108- int mask,
109- FileWatchCallBack callBack)
110+cps::EventManager::addFileWatch (const char *path,
111+ int mask,
112+ FileWatchCallBack callBack)
113 {
114 CompFileWatch *fw = new CompFileWatch ();
115+
116 if (!fw)
117 return 0;
118
119- fw->path = path;
120- fw->mask = mask;
121+ fw->path = path;
122+ fw->mask = mask;
123 fw->callBack = callBack;
124 fw->handle = lastFileWatchHandle++;
125
126@@ -237,7 +238,7 @@
127 if (it == fileWatch.end ())
128 return 0;
129
130- CompFileWatch* w = (*it);
131+ CompFileWatch *w = (*it);
132 fileWatch.erase (it);
133
134 return w;
135@@ -255,7 +256,7 @@
136 return fileWatch;
137 }
138
139-CompWatchFd::CompWatchFd (int fd,
140+CompWatchFd::CompWatchFd (int fd,
141 Glib::IOCondition events,
142 FdWatchCallBack callback) :
143 Glib::IOSource (fd, events),
144@@ -282,29 +283,33 @@
145
146 CompWatchFdHandle
147 CompScreenImpl::addWatchFd (int fd,
148- short int events,
149- FdWatchCallBack callBack)
150+ short int events,
151+ FdWatchCallBack callBack)
152 {
153 return privateScreen.eventManager.addWatchFd (fd, events, callBack);
154 }
155
156 CompWatchFdHandle
157 cps::EventManager::addWatchFd (int fd,
158- short int events,
159- FdWatchCallBack callBack)
160+ short int events,
161+ FdWatchCallBack callBack)
162 {
163 Glib::IOCondition gEvents;
164-
165+
166 memset (&gEvents, 0, sizeof (Glib::IOCondition));
167
168 if (events & POLLIN)
169 gEvents |= Glib::IO_IN;
170+
171 if (events & POLLOUT)
172 gEvents |= Glib::IO_OUT;
173+
174 if (events & POLLPRI)
175 gEvents |= Glib::IO_PRI;
176+
177 if (events & POLLERR)
178 gEvents |= Glib::IO_ERR;
179+
180 if (events & POLLHUP)
181 gEvents |= Glib::IO_HUP;
182
183@@ -314,7 +319,8 @@
184
185 if (!watchFd)
186 return 0;
187- watchFd->mHandle = lastWatchFdHandle++;
188+
189+ watchFd->mHandle = ++lastWatchFdHandle;
190
191 if (lastWatchFdHandle == MAXSHORT)
192 lastWatchFdHandle = 1;
193@@ -334,19 +340,16 @@
194 cps::EventManager::removeWatchFd (CompWatchFdHandle handle)
195 {
196 std::list<CompWatchFd * >::iterator it;
197- CompWatchFd * w;
198
199- for (it = watchFds.begin();
200+ for (it = watchFds.begin ();
201 it != watchFds.end (); ++it)
202- {
203 if ((*it)->mHandle == handle)
204 break;
205- }
206
207 if (it == watchFds.end ())
208 return;
209
210- w = (*it);
211+ CompWatchFd *w = (*it);
212
213 if (w->mExecuting)
214 {
215@@ -383,14 +386,19 @@
216
217 if (events & Glib::IO_IN)
218 revents |= POLLIN;
219+
220 if (events & Glib::IO_OUT)
221 revents |= POLLOUT;
222+
223 if (events & Glib::IO_PRI)
224 revents |= POLLPRI;
225+
226 if (events & Glib::IO_ERR)
227 revents |= POLLERR;
228+
229 if (events & Glib::IO_HUP)
230 revents |= POLLHUP;
231+
232 if (events & Glib::IO_NVAL)
233 return false;
234
235@@ -405,9 +413,9 @@
236 //screen->priv->watchFds.remove (this);
237 return false;
238 }
239-
240+
241 return true;
242-}
243+}
244
245 void
246 CompScreenImpl::eraseValue (CompString key)
247@@ -444,18 +452,18 @@
248 const char *name,
249 CompOption::Value &value)
250 {
251- WRAPABLE_HND_FUNCTN_RETURN (bool, setOptionForPlugin,
252- plugin, name, value)
253+ WRAPABLE_HND_FUNCTN_RETURN (bool, setOptionForPlugin, plugin, name, value)
254
255 return _setOptionForPlugin(plugin, name, value);
256 }
257
258 bool
259 CompScreenImpl::_setOptionForPlugin (const char *plugin,
260- const char *name,
261- CompOption::Value &value)
262+ const char *name,
263+ CompOption::Value &value)
264 {
265 CompPlugin *p = CompPlugin::find (plugin);
266+
267 if (p)
268 return p->vTable->setOption (name, value);
269
270@@ -472,7 +480,7 @@
271
272 void
273 CompScreenImpl::_sessionEvent (CompSession::Event event,
274- CompOption::Vector &arguments)
275+ CompOption::Vector &arguments)
276 {
277 }
278
279@@ -515,7 +523,7 @@
280 char str[128];
281 #endif
282
283- errors++;
284+ ++errors;
285
286 #ifdef DEBUG
287 XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "", str, 128);
288@@ -529,8 +537,10 @@
289
290 snprintf (str, 128, "%d", e->request_code);
291 XGetErrorDatabaseText (dpy, "XRequest", str, "", str, 128);
292+
293 if (strcmp (str, ""))
294 fprintf (stderr, " (%s)", str);
295+
296 fprintf (stderr, "\n ");
297
298 XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "%d", str, 128);
299@@ -550,11 +560,9 @@
300 int
301 CompScreen::checkForError (Display *dpy)
302 {
303- int e;
304-
305 XSync (dpy, false);
306
307- e = errors;
308+ int e = errors;
309 errors = 0;
310
311 return e;
312@@ -639,7 +647,7 @@
313 void
314 PrivateScreen::setAudibleBell (bool audible)
315 {
316- if (xkbEvent.isEnabled())
317+ if (xkbEvent.isEnabled ())
318 XkbChangeEnabledControls (dpy,
319 XkbUseCoreKbd,
320 XkbAudibleBellMask,
321@@ -649,22 +657,23 @@
322 bool
323 CompScreenImpl::handlePingTimeout ()
324 {
325- return Ping::handlePingTimeout(
326- windowManager.begin(),
327- windowManager.end(),
328- privateScreen.dpy);
329+ return Ping::handlePingTimeout (windowManager.begin (),
330+ windowManager.end (),
331+ privateScreen.dpy);
332 }
333
334 bool
335-cps::Ping::handlePingTimeout (WindowManager::iterator begin, WindowManager::iterator end, Display* dpy)
336+cps::Ping::handlePingTimeout (WindowManager::iterator begin,
337+ WindowManager::iterator end,
338+ Display *dpy)
339 {
340- XEvent ev;
341- int ping = lastPing_ + 1;
342+ XEvent ev;
343+ int ping = lastPing_ + 1;
344
345- ev.type = ClientMessage;
346- ev.xclient.window = 0;
347+ ev.type = ClientMessage;
348+ ev.xclient.window = 0;
349 ev.xclient.message_type = Atoms::wmProtocols;
350- ev.xclient.format = 32;
351+ ev.xclient.format = 32;
352 ev.xclient.data.l[0] = Atoms::wmPing;
353 ev.xclient.data.l[1] = ping;
354 ev.xclient.data.l[2] = 0;
355@@ -674,6 +683,7 @@
356 for (WindowManager::iterator i = begin; i != end; ++i)
357 {
358 CompWindow* const w(*i);
359+
360 if (w->priv->handlePingTimeout (lastPing_))
361 {
362 ev.xclient.window = w->id ();
363@@ -696,7 +706,7 @@
364
365 bool
366 CompScreenImpl::setOption (const CompString &name,
367- CompOption::Value &value)
368+ CompOption::Value &value)
369 {
370 return privateScreen.setOption (name, value);
371 }
372@@ -709,48 +719,54 @@
373
374 bool rv = CoreOptions::setOption (name, value);
375
376- if (!rv)
377+ if (!rv ||
378+ !CompOption::findOption (getOptions (), name, &index))
379 return false;
380
381- if (!CompOption::findOption (getOptions (), name, &index))
382- return false;
383-
384- switch (index) {
385+ switch (index)
386+ {
387 case CoreOptions::ActivePlugins:
388 pluginManager.setDirtyPluginList ();
389 break;
390+
391 case CoreOptions::PingDelay:
392 pingTimer.setTimes (optionGetPingDelay (),
393 optionGetPingDelay () + 500);
394 break;
395+
396 case CoreOptions::AudibleBell:
397 setAudibleBell (optionGetAudibleBell ());
398 break;
399+
400 case CoreOptions::DetectOutputs:
401 if (optionGetDetectOutputs ())
402 detectOutputDevices (*this);
403 break;
404+
405 case CoreOptions::Hsize:
406 case CoreOptions::Vsize:
407-
408- if (optionGetHsize () * screen->width () > MAXSHORT)
409- return false;
410- if (optionGetVsize () * screen->height () > MAXSHORT)
411+ if (optionGetHsize () * screen->width () > MAXSHORT ||
412+ optionGetVsize () * screen->height () > MAXSHORT)
413 return false;
414
415 setVirtualScreenSize (optionGetHsize (), optionGetVsize ());
416 break;
417+
418 case CoreOptions::NumberOfDesktops:
419 setNumberOfDesktops (optionGetNumberOfDesktops ());
420 break;
421+
422 case CoreOptions::DefaultIcon:
423 return screen->updateDefaultIcon ();
424 break;
425+
426 case CoreOptions::Outputs:
427 if (optionGetDetectOutputs ())
428 return false;
429+
430 updateOutputDevices (*this);
431 break;
432+
433 default:
434 break;
435 }
436@@ -763,6 +779,7 @@
437 {
438 if (!XEventsQueued (dpy, QueuedAlready))
439 return false;
440+
441 XNextEvent (dpy, &ev);
442
443 /* Skip to the last MotionNotify
444@@ -770,6 +787,7 @@
445 if (ev.type == MotionNotify)
446 {
447 XEvent peekEvent;
448+
449 while (XPending (dpy))
450 {
451 XPeekEvent (dpy, &peekEvent);
452@@ -790,9 +808,7 @@
453 StackDebugger *dbg = StackDebugger::Default ();
454
455 if (StackDebugger::Default ())
456- {
457 return dbg->getNextEvent (ev);
458- }
459 else
460 return getNextXEvent (ev);
461 }
462@@ -804,77 +820,83 @@
463
464 if (pluginManager.isDirtyPluginList ())
465 {
466- eventManager.resetPossibleTap();
467- pluginManager.updatePlugins (screen, optionGetActivePlugins());
468+ eventManager.resetPossibleTap ();
469+ pluginManager.updatePlugins (screen, optionGetActivePlugins ());
470 }
471
472- windowManager.validateServerWindows();
473+ windowManager.validateServerWindows ();
474
475 if (dbg)
476 {
477 dbg->windowsChanged (false);
478 dbg->serverWindowsChanged (false);
479- dbg->loadStack (windowManager.getServerWindows());
480+ dbg->loadStack (windowManager.getServerWindows ());
481 }
482
483- windowManager.invalidateServerWindows();
484+ windowManager.invalidateServerWindows ();
485
486 XEvent event;
487
488 while (getNextEvent (event))
489 {
490- switch (event.type) {
491- case ButtonPress:
492- case ButtonRelease:
493- pointerX = event.xbutton.x_root;
494- pointerY = event.xbutton.y_root;
495- pointerMods = event.xbutton.state;
496- break;
497- case KeyPress:
498- case KeyRelease:
499- pointerX = event.xkey.x_root;
500- pointerY = event.xkey.y_root;
501- pointerMods = event.xkey.state;
502- break;
503- case MotionNotify:
504-
505- pointerX = event.xmotion.x_root;
506- pointerY = event.xmotion.y_root;
507- pointerMods = event.xmotion.state;
508- break;
509- case EnterNotify:
510- case LeaveNotify:
511- pointerX = event.xcrossing.x_root;
512- pointerY = event.xcrossing.y_root;
513- pointerMods = event.xcrossing.state;
514- break;
515- case ClientMessage:
516- if (event.xclient.message_type == Atoms::xdndPosition)
517- {
518- pointerX = event.xclient.data.l[2] >> 16;
519- pointerY = event.xclient.data.l[2] & 0xffff;
520- /* FIXME: Xdnd provides us no way of getting the pointer mods
521- * without doing XQueryPointer, which is a round-trip */
522- pointerMods = 0;
523- }
524- else if (event.xclient.message_type == Atoms::wmMoveResize)
525- {
526- int i;
527- Window child, root;
528- /* _NET_WM_MOVERESIZE is most often sent by clients who provide
529- * a special "grab space" on a window for the user to initiate
530- * adjustment by the window manager. Since we don't have a
531- * passive grab on Button1 for active and raised windows, we
532- * need to update the pointer buffer here */
533-
534- XQueryPointer (screen->dpy (), screen->root (),
535- &root, &child, &pointerX, &pointerY,
536- &i, &i, &pointerMods);
537- }
538- break;
539- default:
540- break;
541- }
542+ switch (event.type)
543+ {
544+ case ButtonPress:
545+ case ButtonRelease:
546+ pointerX = event.xbutton.x_root;
547+ pointerY = event.xbutton.y_root;
548+ pointerMods = event.xbutton.state;
549+ break;
550+
551+ case KeyPress:
552+ case KeyRelease:
553+ pointerX = event.xkey.x_root;
554+ pointerY = event.xkey.y_root;
555+ pointerMods = event.xkey.state;
556+ break;
557+
558+ case MotionNotify:
559+ pointerX = event.xmotion.x_root;
560+ pointerY = event.xmotion.y_root;
561+ pointerMods = event.xmotion.state;
562+ break;
563+
564+ case EnterNotify:
565+ case LeaveNotify:
566+ pointerX = event.xcrossing.x_root;
567+ pointerY = event.xcrossing.y_root;
568+ pointerMods = event.xcrossing.state;
569+ break;
570+
571+ case ClientMessage:
572+ if (event.xclient.message_type == Atoms::xdndPosition)
573+ {
574+ pointerX = event.xclient.data.l[2] >> 16;
575+ pointerY = event.xclient.data.l[2] & 0xffff;
576+ /* FIXME: Xdnd provides us no way of getting the pointer mods
577+ * without doing XQueryPointer, which is a round-trip */
578+ pointerMods = 0;
579+ }
580+ else if (event.xclient.message_type == Atoms::wmMoveResize)
581+ {
582+ int i;
583+ Window child, root;
584+ /* _NET_WM_MOVERESIZE is most often sent by clients who provide
585+ * a special "grab space" on a window for the user to initiate
586+ * adjustment by the window manager. Since we don't have a
587+ * passive grab on Button1 for active and raised windows, we
588+ * need to update the pointer buffer here */
589+
590+ XQueryPointer (screen->dpy (), screen->root (),
591+ &root, &child, &pointerX, &pointerY,
592+ &i, &i, &pointerMods);
593+ }
594+
595+ break;
596+
597+ default:
598+ break;
599+ }
600
601 sn_display_process_event (snDisplay, &event);
602
603@@ -895,20 +917,23 @@
604 if (dbg)
605 {
606 if (dbg->windowsChanged () &&
607- dbg->cmpStack (windowManager.getWindows(), windowManager.getServerWindows()))
608+ dbg->cmpStack (windowManager.getWindows (),
609+ windowManager.getServerWindows ()))
610 {
611 compLogMessage ("core", CompLogLevelDebug, "stacks are out of sync");
612+
613 if (dbg->timedOut ())
614 compLogMessage ("core", CompLogLevelDebug, "however, this may be a false positive");
615 }
616
617- if (dbg->serverWindowsChanged () && dbg->checkSanity (windowManager.getWindows()))
618+ if (dbg->serverWindowsChanged () &&
619+ dbg->checkSanity (windowManager.getWindows ()))
620 compLogMessage ("core", CompLogLevelDebug, "windows are stacked incorrectly");
621 }
622 }
623
624 void
625-cps::WindowManager::validateServerWindows()
626+cps::WindowManager::validateServerWindows ()
627 {
628 /* Restacks recently processed, ensure that
629 * plugins use the stack last received from
630@@ -927,30 +952,32 @@
631 }
632
633 void
634-cps::WindowManager::invalidateServerWindows()
635+cps::WindowManager::invalidateServerWindows ()
636 {
637 stackIsFresh = false;
638 }
639
640 void
641-cps::WindowManager::clearFullscreenHints() const
642+cps::WindowManager::clearFullscreenHints () const
643 {
644 /* clear out fullscreen monitor hints of all windows as
645 suggested on monitor layout changes in EWMH */
646- for (iterator i = windows.begin(); i != windows.end(); ++i)
647+ for (iterator i = windows.begin (); i != windows.end (); ++i)
648 {
649- CompWindow* const w(*i);
650+ CompWindow* const w (*i);
651+
652 if (w->priv->fullscreenMonitorsSet)
653 w->priv->setFullscreenMonitors (NULL);
654 }
655 }
656
657 void
658-cps::WindowManager::showOrHideForDesktop(unsigned int desktop) const
659+cps::WindowManager::showOrHideForDesktop (unsigned int desktop) const
660 {
661 for (iterator i = windows.begin(); i != windows.end(); ++i)
662 {
663- CompWindow* const w(*i);
664+ CompWindow* const w (*i);
665+
666 if (w->desktop () == 0xffffffff)
667 continue;
668
669@@ -962,22 +989,24 @@
670 }
671
672 void
673-cps::WindowManager::setWindowActiveness(cps::History& history) const
674+cps::WindowManager::setWindowActiveness (cps::History &history) const
675 {
676- for (iterator i = windows.begin(); i != windows.end(); ++i)
677+ for (iterator i = windows.begin (); i != windows.end (); ++i)
678 {
679 CompWindow* const w(*i);
680+
681 if (w->isViewable ())
682 w->priv->activeNum = history.nextActiveNum ();
683 }
684 }
685
686 void
687-cps::WindowManager::setNumberOfDesktops(unsigned int desktops) const
688+cps::WindowManager::setNumberOfDesktops (unsigned int desktops) const
689 {
690- for (iterator i = windows.begin(); i != windows.end(); ++i)
691+ for (iterator i = windows.begin (); i != windows.end (); ++i)
692 {
693 CompWindow* const w(*i);
694+
695 if (w->desktop () == 0xffffffff)
696 continue;
697
698@@ -987,9 +1016,9 @@
699 }
700
701 void
702-cps::WindowManager::updateWindowSizes() const
703+cps::WindowManager::updateWindowSizes () const
704 {
705- for (iterator i = windows.begin(); i != windows.end(); ++i)
706+ for (iterator i = windows.begin (); i != windows.end (); ++i)
707 {
708 CompWindow* const w(*i);
709 w->priv->updateSize ();
710@@ -1003,7 +1032,7 @@
711 CompOption::Value::Vector result;
712
713 /* Must have core as first plugin */
714- result.push_back("core");
715+ result.push_back ("core");
716
717 /* Add initial plugins */
718 foreach(CompString & p, initialPlugins)
719@@ -1018,21 +1047,21 @@
720 }
721
722 /* Add plugins not in the initial list */
723- foreach(CompOption::Value const& opt, extraPluginsRequested)
724+ foreach (CompOption::Value const &opt, extraPluginsRequested)
725 {
726- if (opt.s() == "core")
727+ if (opt.s () == "core")
728 continue;
729
730- if (blacklist.find (opt.s()) != blacklist.end ())
731+ if (blacklist.find (opt.s ()) != blacklist.end ())
732 continue;
733
734 typedef std::list<CompString>::iterator iterator;
735 bool skip = false;
736
737- for (iterator it = initialPlugins.begin(); it != initialPlugins.end();
738- ++it)
739+ for (iterator it = initialPlugins.begin ();
740+ it != initialPlugins.end (); ++it)
741 {
742- if ((*it) == opt.s())
743+ if ((*it) == opt.s ())
744 {
745 skip = true;
746 break;
747@@ -1040,70 +1069,70 @@
748 }
749
750 if (!skip)
751- {
752- result.push_back(opt.s());
753- }
754+ result.push_back(opt.s ());
755 }
756+
757 return result;
758 }
759
760-
761 void
762-cps::PluginManager::updatePlugins (CompScreen* screen, CompOption::Value::Vector const& extraPluginsRequested)
763+cps::PluginManager::updatePlugins (CompScreen *screen,
764+ CompOption::Value::Vector const &extraPluginsRequested)
765 {
766 dirtyPluginList = false;
767
768- CompOption::Value::Vector const desiredPlugins(mergedPluginList(extraPluginsRequested));
769+ CompOption::Value::Vector const desiredPlugins (mergedPluginList (extraPluginsRequested));
770
771 unsigned int pluginIndex;
772+
773 for (pluginIndex = 1;
774 pluginIndex < plugin.list ().size () && pluginIndex < desiredPlugins.size ();
775- pluginIndex++)
776- {
777+ ++pluginIndex)
778 if (plugin.list ().at (pluginIndex).s () != desiredPlugins.at (pluginIndex).s ())
779 break;
780- }
781
782 unsigned int desireIndex = pluginIndex;
783
784 // We have pluginIndex pointing at first difference (or end).
785 // Now pop plugins off stack to this point, but keep track that they are loaded
786 CompPlugin::List alreadyLoaded;
787- if (const unsigned int nPop = plugin.list().size() - pluginIndex)
788+
789+ if (const unsigned int nPop = plugin.list ().size () - pluginIndex)
790 {
791- for (pluginIndex = 0; pluginIndex < nPop; pluginIndex++)
792+ for (pluginIndex = 0; pluginIndex < nPop; ++pluginIndex)
793 {
794- alreadyLoaded.push_back(CompPlugin::pop());
795- plugin.list().pop_back();
796+ alreadyLoaded.push_back(CompPlugin::pop ());
797+ plugin.list ().pop_back ();
798 }
799 }
800
801+ CompPlugin *p;
802+ bool failedPush;
803+
804 // Now work forward through requested plugins
805- for (; desireIndex < desiredPlugins.size(); desireIndex++)
806+ for (; desireIndex < desiredPlugins.size (); ++desireIndex)
807 {
808- CompPlugin *p = NULL;
809- bool failedPush = false;
810+ p = NULL;
811+ failedPush = false;
812
813 // If already loaded, just try to push it...
814- foreach(CompPlugin * pp, alreadyLoaded)
815+ foreach (CompPlugin *pp, alreadyLoaded)
816 {
817- if (desiredPlugins[desireIndex].s() == pp->vTable->name())
818+ if (desiredPlugins[desireIndex].s () == pp->vTable->name ())
819 {
820 if (CompPlugin::push (pp))
821 {
822 p = pp;
823- alreadyLoaded.erase(
824- std::find(alreadyLoaded.begin(),
825- alreadyLoaded.end(), pp));
826+ alreadyLoaded.erase (std::find (alreadyLoaded.begin (),
827+ alreadyLoaded.end (), pp));
828 break;
829 }
830 else
831 {
832- alreadyLoaded.erase(
833- std::find(alreadyLoaded.begin(),
834- alreadyLoaded.end(), pp));
835+ alreadyLoaded.erase (std::find (alreadyLoaded.begin (),
836+ alreadyLoaded.end (), pp));
837 blacklist.insert (desiredPlugins[desireIndex].s ());
838- CompPlugin::unload(pp);
839+ CompPlugin::unload (pp);
840 p = NULL;
841 failedPush = true;
842 break;
843@@ -1114,25 +1143,23 @@
844 // ...otherwise, try to load and push
845 if (p == 0 && !failedPush)
846 {
847- p = CompPlugin::load(desiredPlugins[desireIndex].s ().c_str ());
848+ p = CompPlugin::load (desiredPlugins[desireIndex].s ().c_str ());
849
850 if (p)
851 {
852- if (!CompPlugin::push(p))
853+ if (!CompPlugin::push (p))
854 {
855 blacklist.insert (desiredPlugins[desireIndex].s ());
856- CompPlugin::unload(p);
857+ CompPlugin::unload (p);
858 p = 0;
859 }
860 }
861 else
862- {
863 blacklist.insert (desiredPlugins[desireIndex].s ());
864- }
865 }
866
867 if (p)
868- plugin.list().push_back(p->vTable->name());
869+ plugin.list ().push_back(p->vTable->name ());
870 }
871
872 // Any plugins that are loaded, but were not re-initialized can be unloaded.
873@@ -1151,8 +1178,7 @@
874 Atom target,
875 Atom property)
876 {
877-
878-static const unsigned short N_TARGETS = 4;
879+ static const unsigned short N_TARGETS = 4;
880
881 Atom conversionTargets[N_TARGETS];
882
883@@ -1192,7 +1218,7 @@
884 PrivateScreen::handleSelectionRequest (XEvent *event)
885 {
886 if (wmSnSelectionWindow != event->xselectionrequest.owner ||
887- wmSnAtom != event->xselectionrequest.selection)
888+ wmSnAtom != event->xselectionrequest.selection)
889 return;
890
891 XSelectionEvent reply;
892@@ -1209,8 +1235,8 @@
893 {
894 if (event->xselectionrequest.property != None)
895 {
896- Atom type, *adata;
897- int i, format;
898+ Atom type;
899+ int format;
900 unsigned long num, rest;
901 unsigned char *data;
902
903@@ -1227,8 +1253,9 @@
904 * but since we have 4 possible targets, we will hardly ever
905 * meet multiple requests with a length > 8
906 */
907- adata = (Atom *) data;
908- i = 0;
909+ Atom *adata = (Atom *) data;
910+ int i = 0;
911+
912 while (i < (int) num)
913 {
914 if (!convertProperty (dpy, wmSnTimestamp,
915@@ -1276,23 +1303,23 @@
916 eventManager.quit ();
917 }
918
919-static const std::string IMAGEDIR("images");
920-static const std::string HOMECOMPIZDIR(".compiz-1");
921+static const std::string IMAGEDIR = "images";
922+static const std::string HOMECOMPIZDIR = ".compiz-1";
923
924 bool
925 CompScreenImpl::readImageFromFile (CompString &name,
926- CompString &pname,
927- CompSize &size,
928- void *&data)
929+ CompString &pname,
930+ CompSize &size,
931+ void *&data)
932 {
933- bool status;
934 int stride;
935+ bool status = fileToImage (name, size, stride, data);
936
937- status = fileToImage (name, size, stride, data);
938 if (!status)
939 {
940 char *home = getenv ("HOME");
941 CompString path;
942+
943 if (home)
944 {
945 path = home;
946@@ -1326,9 +1353,9 @@
947
948 bool
949 CompScreenImpl::writeImageToFile (CompString &path,
950- const char *format,
951- CompSize &size,
952- void *data)
953+ const char *format,
954+ CompSize &size,
955+ void *data)
956 {
957 CompString formatString (format);
958 return imageToFile (path, formatString, size, size.width () * 4, data);
959@@ -1337,21 +1364,22 @@
960 Window
961 PrivateScreen::getActiveWindow (Window root)
962 {
963- Atom actual;
964- int result, format;
965+ Atom actual;
966+ int format;
967 unsigned long n, left;
968 unsigned char *data;
969 Window w = None;
970
971- result = XGetWindowProperty (dpy, root,
972- Atoms::winActive, 0L, 1L, false,
973- XA_WINDOW, &actual, &format,
974- &n, &left, &data);
975+ int result = XGetWindowProperty (dpy, root,
976+ Atoms::winActive, 0L, 1L, false,
977+ XA_WINDOW, &actual, &format,
978+ &n, &left, &data);
979
980 if (result == Success && data)
981 {
982 if (n)
983 memcpy (&w, data, sizeof (Window));
984+
985 XFree (data);
986 }
987
988@@ -1370,9 +1398,9 @@
989
990 bool
991 CompScreenImpl::_fileToImage (CompString &name,
992- CompSize &size,
993- int &stride,
994- void *&data)
995+ CompSize &size,
996+ int &stride,
997+ void *&data)
998 {
999 return false;
1000 }
1001@@ -1384,17 +1412,17 @@
1002 int stride,
1003 void *data)
1004 {
1005- WRAPABLE_HND_FUNCTN_RETURN (bool, imageToFile, path, format, size,
1006- stride, data);
1007+ WRAPABLE_HND_FUNCTN_RETURN (bool, imageToFile, path, format,
1008+ size, stride, data);
1009 return _imageToFile (path, format, size, stride, data);
1010 }
1011
1012 bool
1013 CompScreenImpl::_imageToFile (CompString &path,
1014- CompString &format,
1015- CompSize &size,
1016- int stride,
1017- void *data)
1018+ CompString &format,
1019+ CompSize &size,
1020+ int stride,
1021+ void *data)
1022 {
1023 return false;
1024 }
1025@@ -1410,8 +1438,8 @@
1026
1027 void
1028 CompScreenImpl::_logMessage (const char *componentName,
1029- CompLogLevel level,
1030- const char *message)
1031+ CompLogLevel level,
1032+ const char *message)
1033 {
1034 ::logMessage (componentName, level, message);
1035 }
1036@@ -1419,21 +1447,22 @@
1037 int
1038 cps::XWindowInfo::getWmState (Window id)
1039 {
1040- Atom actual;
1041- int result, format;
1042+ Atom actual;
1043+ int format;
1044 unsigned long n, left;
1045 unsigned char *data;
1046 unsigned long state = NormalState;
1047
1048- result = XGetWindowProperty (dpy, id,
1049- Atoms::wmState, 0L, 2L, false,
1050- Atoms::wmState, &actual, &format,
1051- &n, &left, &data);
1052+ int result = XGetWindowProperty (dpy, id,
1053+ Atoms::wmState, 0L, 2L, false,
1054+ Atoms::wmState, &actual, &format,
1055+ &n, &left, &data);
1056
1057 if (result == Success && data)
1058 {
1059 if (n)
1060 memcpy (&state, data, sizeof (unsigned long));
1061+
1062 XFree ((void *) data);
1063 }
1064
1065@@ -1441,7 +1470,8 @@
1066 }
1067
1068 void
1069-cps::XWindowInfo::setWmState (int state, Window id) const
1070+cps::XWindowInfo::setWmState (int state,
1071+ Window id) const
1072 {
1073 unsigned long data[2];
1074
1075@@ -1520,16 +1550,16 @@
1076 unsigned int
1077 cps::XWindowInfo::getWindowState (Window id)
1078 {
1079- Atom actual;
1080- int result, format;
1081+ Atom actual;
1082+ int format;
1083 unsigned long n, left;
1084 unsigned char *data;
1085 unsigned int state = 0;
1086
1087- result = XGetWindowProperty (dpy, id,
1088- Atoms::winState,
1089- 0L, 1024L, false, XA_ATOM, &actual, &format,
1090- &n, &left, &data);
1091+ int result = XGetWindowProperty (dpy, id,
1092+ Atoms::winState,
1093+ 0L, 1024L, false, XA_ATOM, &actual,
1094+ &format, &n, &left, &data);
1095
1096 if (result == Success && data)
1097 {
1098@@ -1545,9 +1575,10 @@
1099 }
1100
1101 unsigned int
1102-compiz::window::fillStateData (unsigned int state, Atom *data)
1103+compiz::window::fillStateData (unsigned int state,
1104+ Atom *data)
1105 {
1106- int i = 0;
1107+ int i = 0;
1108
1109 if (state & CompWindowStateModalMask)
1110 data[i++] = Atoms::winStateModal;
1111@@ -1582,34 +1613,35 @@
1112 }
1113
1114 void
1115-PrivateScreen::setWindowState (unsigned int state, Window id)
1116+PrivateScreen::setWindowState (unsigned int state,
1117+ Window id)
1118 {
1119- int i = 0;
1120 Atom data[32];
1121
1122- i = compiz::window::fillStateData (state, data);
1123+ int i = compiz::window::fillStateData (state, data);
1124 XChangeProperty (dpy, id, Atoms::winState,
1125- XA_ATOM, 32, PropModeReplace,
1126- (unsigned char *) data, i);
1127+ XA_ATOM, 32, PropModeReplace,
1128+ (unsigned char *) data, i);
1129 }
1130
1131 unsigned int
1132 cps::XWindowInfo::getWindowType (Window id)
1133 {
1134- Atom actual, a = None;
1135- int result, format;
1136+ Atom actual, a = None;
1137+ int format;
1138 unsigned long n, left;
1139 unsigned char *data;
1140
1141- result = XGetWindowProperty (dpy , id,
1142- Atoms::winType,
1143- 0L, 1L, false, XA_ATOM, &actual, &format,
1144- &n, &left, &data);
1145+ int result = XGetWindowProperty (dpy , id,
1146+ Atoms::winType,
1147+ 0L, 1L, false, XA_ATOM, &actual,
1148+ &format, &n, &left, &data);
1149
1150 if (result == Success && data)
1151 {
1152 if (n)
1153 memcpy (&a, data, sizeof (Atom));
1154+
1155 XFree ((void *) data);
1156 }
1157
1158@@ -1650,21 +1682,21 @@
1159
1160 void
1161 cps::XWindowInfo::getMwmHints (Window id,
1162- unsigned int *func,
1163- unsigned int *decor) const
1164+ unsigned int *func,
1165+ unsigned int *decor) const
1166 {
1167- Atom actual;
1168- int result, format;
1169+ Atom actual;
1170+ int format;
1171 unsigned long n, left;
1172 unsigned char *data;
1173
1174 *func = MwmFuncAll;
1175 *decor = MwmDecorAll;
1176
1177- result = XGetWindowProperty (dpy, id,
1178- Atoms::mwmHints,
1179- 0L, 20L, false, Atoms::mwmHints,
1180- &actual, &format, &n, &left, &data);
1181+ int result = XGetWindowProperty (dpy, id,
1182+ Atoms::mwmHints,
1183+ 0L, 20L, false, Atoms::mwmHints,
1184+ &actual, &format, &n, &left, &data);
1185
1186 if (result == Success && data)
1187 {
1188@@ -1692,7 +1724,7 @@
1189
1190 if (XGetWMProtocols (dpy, id, &protocol, &count))
1191 {
1192- for (int i = 0; i < count; i++)
1193+ for (int i = 0; i < count; ++i)
1194 {
1195 if (protocol[i] == Atoms::wmDeleteWindow)
1196 protocols |= CompWindowProtocolDeleteMask;
1197@@ -1712,18 +1744,18 @@
1198
1199 unsigned int
1200 CompScreenImpl::getWindowProp (Window id,
1201- Atom property,
1202- unsigned int defaultValue)
1203+ Atom property,
1204+ unsigned int defaultValue)
1205 {
1206- Atom actual;
1207- int result, format;
1208+ Atom actual;
1209+ int format;
1210 unsigned long n, left;
1211 unsigned char *data;
1212 unsigned int retval = defaultValue;
1213
1214- result = XGetWindowProperty (privateScreen.dpy, id, property,
1215- 0L, 1L, false, XA_CARDINAL, &actual, &format,
1216- &n, &left, &data);
1217+ int result = XGetWindowProperty (privateScreen.dpy, id, property,
1218+ 0L, 1L, false, XA_CARDINAL, &actual, &format,
1219+ &n, &left, &data);
1220
1221 if (result == Success && data)
1222 {
1223@@ -1742,8 +1774,8 @@
1224
1225 void
1226 CompScreenImpl::setWindowProp (Window id,
1227- Atom property,
1228- unsigned int value)
1229+ Atom property,
1230+ unsigned int value)
1231 {
1232 unsigned long data = value;
1233
1234@@ -1757,15 +1789,15 @@
1235 Atom property,
1236 unsigned short *returnValue)
1237 {
1238- Atom actual;
1239- int result, format;
1240+ Atom actual;
1241+ int format;
1242 unsigned long n, left;
1243 unsigned char *data;
1244 bool retval = false;
1245
1246- result = XGetWindowProperty (dpy, id, property,
1247- 0L, 1L, false, XA_CARDINAL, &actual, &format,
1248- &n, &left, &data);
1249+ int result = XGetWindowProperty (dpy, id, property,
1250+ 0L, 1L, false, XA_CARDINAL, &actual,
1251+ &format, &n, &left, &data);
1252
1253 if (result == Success && data)
1254 {
1255@@ -1786,8 +1818,8 @@
1256
1257 unsigned short
1258 CompScreenImpl::getWindowProp32 (Window id,
1259- Atom property,
1260- unsigned short defaultValue)
1261+ Atom property,
1262+ unsigned short defaultValue)
1263 {
1264 unsigned short result;
1265
1266@@ -1799,12 +1831,10 @@
1267
1268 void
1269 CompScreenImpl::setWindowProp32 (Window id,
1270- Atom property,
1271- unsigned short value)
1272+ Atom property,
1273+ unsigned short value)
1274 {
1275- CARD32 value32;
1276-
1277- value32 = value << 16 | value;
1278+ CARD32 value32 = value << 16 | value;
1279
1280 XChangeProperty (privateScreen.dpy, id, property,
1281 XA_CARDINAL, 32, PropModeReplace,
1282@@ -1875,40 +1905,39 @@
1283 void
1284 PrivateScreen::setDesktopHints ()
1285 {
1286- unsigned long *data;
1287-
1288- int dSize = nDesktop * 2 + nDesktop * 2 + nDesktop * 4 + 1;
1289-
1290- data = (unsigned long *) malloc (sizeof (unsigned long) * dSize);
1291+ int dSize = nDesktop * 8 + 1;
1292+
1293+ unsigned long *data = (unsigned long *) malloc (sizeof (unsigned long) * dSize);
1294+
1295 if (!data)
1296 return;
1297
1298- unsigned int i;
1299+ unsigned int i;
1300 int offset = 0;
1301 int hintSize = nDesktop * 2;
1302
1303- for (i = 0; i < nDesktop; i++)
1304+ for (i = 0; i < nDesktop; ++i)
1305 {
1306 data[offset + i * 2 + 0] = viewPort.vp.x () * screen->width ();
1307 data[offset + i * 2 + 1] = viewPort.vp.y () * screen->height ();
1308 }
1309
1310 if (!desktopHintEqual (data, dSize, offset, hintSize))
1311- XChangeProperty (dpy, rootWindow(),
1312+ XChangeProperty (dpy, rootWindow (),
1313 Atoms::desktopViewport,
1314 XA_CARDINAL, 32, PropModeReplace,
1315 (unsigned char *) &data[offset], hintSize);
1316
1317 offset += hintSize;
1318
1319- for (i = 0; i < nDesktop; i++)
1320+ for (i = 0; i < nDesktop; ++i)
1321 {
1322- data[offset + i * 2 + 0] = screen->width () * viewPort.vpSize.width ();
1323+ data[offset + i * 2 + 0] = screen->width () * viewPort.vpSize.width ();
1324 data[offset + i * 2 + 1] = screen->height () * viewPort.vpSize.height ();
1325 }
1326
1327 if (!desktopHintEqual (data, dSize, offset, hintSize))
1328- XChangeProperty (dpy, rootWindow(),
1329+ XChangeProperty (dpy, rootWindow (),
1330 Atoms::desktopGeometry,
1331 XA_CARDINAL, 32, PropModeReplace,
1332 (unsigned char *) &data[offset], hintSize);
1333@@ -1916,7 +1945,7 @@
1334 offset += hintSize;
1335 hintSize = nDesktop * 4;
1336
1337- for (i = 0; i < nDesktop; i++)
1338+ for (i = 0; i < nDesktop; ++i)
1339 {
1340 data[offset + i * 4 + 0] = workArea.x ();
1341 data[offset + i * 4 + 1] = workArea.y ();
1342@@ -1925,7 +1954,7 @@
1343 }
1344
1345 if (!desktopHintEqual (data, dSize, offset, hintSize))
1346- XChangeProperty (dpy, rootWindow(),
1347+ XChangeProperty (dpy, rootWindow (),
1348 Atoms::workarea,
1349 XA_CARDINAL, 32, PropModeReplace,
1350 (unsigned char *) &data[offset], hintSize);
1351@@ -1936,7 +1965,7 @@
1352 hintSize = 1;
1353
1354 if (!desktopHintEqual (data, dSize, offset, hintSize))
1355- XChangeProperty (dpy, rootWindow(),
1356+ XChangeProperty (dpy, rootWindow (),
1357 Atoms::numberOfDesktops,
1358 XA_CARDINAL, 32, PropModeReplace,
1359 (unsigned char *) &data[offset], hintSize);
1360@@ -1949,14 +1978,15 @@
1361 }
1362
1363 void
1364-PrivateScreen::setVirtualScreenSize (int newh, int newv)
1365+PrivateScreen::setVirtualScreenSize (int newh,
1366+ int newv)
1367 {
1368 /* if newh or newv is being reduced */
1369 if (newh < screen->vpSize ().width () ||
1370 newv < screen->vpSize ().height ())
1371 {
1372- int tx = 0;
1373- int ty = 0;
1374+ int tx = 0;
1375+ int ty = 0;
1376
1377 if (screen->vp ().x () >= newh)
1378 tx = screen->vp ().x () - (newh - 1);
1379@@ -1966,12 +1996,16 @@
1380 if (tx != 0 || ty != 0)
1381 screen->moveViewport (tx, ty, TRUE);
1382
1383+ int moveX, moveY;
1384+ int vpX; /* x index of a window's vp */
1385+ int vpY; /* y index of a window's vp */
1386+
1387 /* Move windows that were in one of the deleted viewports into the
1388 closest viewport */
1389 foreach (CompWindow *w, screen->windows ())
1390 {
1391- int moveX = 0;
1392- int moveY = 0;
1393+ moveX = 0;
1394+ moveY = 0;
1395
1396 if (w->onAllViewports ())
1397 continue;
1398@@ -1981,9 +2015,8 @@
1399 vertical index range */
1400 if (newh < screen->vpSize ().width ())
1401 {
1402- int vpX; /* x index of a window's vp */
1403-
1404 vpX = w->serverX () / screen->width ();
1405+
1406 if (w->serverX () < 0)
1407 vpX -= 1;
1408
1409@@ -1993,11 +2026,11 @@
1410 if (vpX >= newh)
1411 moveX = ((newh - 1) - vpX) * screen->width ();
1412 }
1413+
1414 if (newv < screen->vpSize ().height ())
1415 {
1416- int vpY; /* y index of a window's vp */
1417-
1418 vpY = w->serverY () / screen->height ();
1419+
1420 if (w->serverY () < 0)
1421 vpY -= 1;
1422
1423@@ -2032,7 +2065,7 @@
1424 {
1425 outputDevices.updateOutputDevices(coreOptions, screen);
1426
1427- windowManager.clearFullscreenHints();
1428+ windowManager.clearFullscreenHints ();
1429
1430 screen->updateWorkarea ();
1431
1432@@ -2040,7 +2073,7 @@
1433 }
1434
1435 void
1436-PrivateScreen::detectOutputDevices (CoreOptions& coreOptions)
1437+PrivateScreen::detectOutputDevices (CoreOptions &coreOptions)
1438 {
1439 if (coreOptions.optionGetDetectOutputs ())
1440 {
1441@@ -2050,11 +2083,10 @@
1442 if (!screenInfo.empty ())
1443 {
1444 CompOption::Value::Vector l;
1445+
1446 foreach (XineramaScreenInfo xi, screenInfo)
1447- {
1448 l.push_back (compPrintf ("%dx%d+%d+%d", xi.width, xi.height,
1449 xi.x_org, xi.y_org));
1450- }
1451
1452 value.set (CompOption::TypeString, l);
1453 }
1454@@ -2071,12 +2103,9 @@
1455 coreOptions.getOptions()[CoreOptions::DetectOutputs].value ().set (true);
1456 }
1457 else
1458- {
1459 updateOutputDevices (coreOptions);
1460- }
1461 }
1462
1463-
1464 void
1465 cps::StartupSequenceImpl::updateStartupFeedback ()
1466 {
1467@@ -2089,13 +2118,14 @@
1468 }
1469 }
1470
1471+/* TODO: Investigate this magic number timeout, can it be reduced ? */
1472 static const unsigned int STARTUP_TIMEOUT_DELAY = 15000;
1473
1474 bool
1475 cps::StartupSequence::handleStartupSequenceTimeout ()
1476 {
1477- struct timeval now, active;
1478- double elapsed;
1479+ struct timeval now, active;
1480+ double elapsed;
1481
1482 gettimeofday (&now, NULL);
1483
1484@@ -2116,11 +2146,11 @@
1485 }
1486
1487 void
1488-cps::StartupSequence::addSequence (SnStartupSequence *sequence, CompPoint const& vp)
1489+cps::StartupSequence::addSequence (SnStartupSequence *sequence,
1490+ CompPoint const &vp)
1491 {
1492- CompStartupSequence *s;
1493+ CompStartupSequence *s = new CompStartupSequence ();
1494
1495- s = new CompStartupSequence ();
1496 if (!s)
1497 return;
1498
1499@@ -2188,35 +2218,41 @@
1500
1501 void
1502 PrivateScreen::compScreenSnEvent (SnMonitorEvent *event,
1503- void *userData)
1504+ void *userData)
1505 {
1506- PrivateScreen *self = (PrivateScreen *) userData;
1507- SnStartupSequence *sequence;
1508-
1509- sequence = sn_monitor_event_get_startup_sequence (event);
1510-
1511- switch (sn_monitor_event_get_type (event)) {
1512- case SN_MONITOR_EVENT_INITIATED:
1513- self->startupSequence.addSequence (sequence, self->viewPort.vp);
1514- break;
1515- case SN_MONITOR_EVENT_COMPLETED:
1516- self->startupSequence.removeSequence (sequence);
1517- break;
1518- case SN_MONITOR_EVENT_CHANGED:
1519- case SN_MONITOR_EVENT_CANCELED:
1520- break;
1521+ PrivateScreen *self = (PrivateScreen *) userData;
1522+ SnStartupSequence *sequence = sn_monitor_event_get_startup_sequence (event);
1523+
1524+ switch (sn_monitor_event_get_type (event))
1525+ {
1526+ case SN_MONITOR_EVENT_INITIATED:
1527+ self->startupSequence.addSequence (sequence, self->viewPort.vp);
1528+ break;
1529+
1530+ case SN_MONITOR_EVENT_COMPLETED:
1531+ self->startupSequence.removeSequence (sequence);
1532+ break;
1533+
1534+ case SN_MONITOR_EVENT_CHANGED:
1535+ case SN_MONITOR_EVENT_CANCELED:
1536+ break;
1537+
1538+ default:
1539+ break;
1540 }
1541 }
1542
1543 void
1544 PrivateScreen::updateScreenEdges ()
1545 {
1546- struct screenEdgeGeometry {
1547+ struct screenEdgeGeometry
1548+ {
1549 int xw, x0;
1550 int yh, y0;
1551 int ww, w0;
1552 int hh, h0;
1553- } geometry[SCREEN_EDGE_NUM] = {
1554+ } geometry[SCREEN_EDGE_NUM] =
1555+ {
1556 { 0, -1, 0, 2, 0, 2, 1, -4 }, /* left */
1557 { 1, -1, 0, 2, 0, 2, 1, -4 }, /* right */
1558 { 0, 2, 0, -1, 1, -4, 0, 2 }, /* top */
1559@@ -2227,8 +2263,7 @@
1560 { 1, -1, 1, -1, 0, 2, 0, 2 } /* bottom-right */
1561 };
1562
1563- for (int i = 0; i < SCREEN_EDGE_NUM; i++)
1564- {
1565+ for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
1566 if (screenEdge[i].id)
1567 XMoveResizeWindow (dpy, screenEdge[i].id,
1568 geometry[i].xw * screen->width () +
1569@@ -2239,11 +2274,11 @@
1570 geometry[i].w0,
1571 geometry[i].hh * screen->height () +
1572 geometry[i].h0);
1573- }
1574 }
1575
1576 void
1577-PrivateScreen::reshape (int w, int h)
1578+PrivateScreen::reshape (int w,
1579+ int h)
1580 {
1581 updateScreenInfo ();
1582
1583@@ -2271,12 +2306,12 @@
1584 reshape (ce->width, ce->height);
1585
1586 detectOutputDevices (*this);
1587-
1588 updateOutputDevices (*this);
1589 }
1590
1591 void
1592-cps::EventManager::setSupportingWmCheck (Display* dpy, Window root)
1593+cps::EventManager::setSupportingWmCheck (Display* dpy,
1594+ Window root)
1595 {
1596 XChangeProperty (dpy, grabWindow,
1597 Atoms::supportingWmCheck,
1598@@ -2286,13 +2321,15 @@
1599 XChangeProperty (dpy, grabWindow, Atoms::wmName,
1600 Atoms::utf8String, 8, PropModeReplace,
1601 (unsigned char *) PACKAGE, strlen (PACKAGE));
1602+
1603 XChangeProperty (dpy, grabWindow, Atoms::winState,
1604 XA_ATOM, 32, PropModeReplace,
1605- (unsigned char *) &Atoms::winStateSkipTaskbar,
1606- 1);
1607+ (unsigned char *) &Atoms::winStateSkipTaskbar, 1);
1608+
1609 XChangeProperty (dpy, grabWindow, Atoms::winState,
1610 XA_ATOM, 32, PropModeAppend,
1611 (unsigned char *) &Atoms::winStateSkipPager, 1);
1612+
1613 XChangeProperty (dpy, grabWindow, Atoms::winState,
1614 XA_ATOM, 32, PropModeAppend,
1615 (unsigned char *) &Atoms::winStateHidden, 1);
1616@@ -2354,6 +2391,7 @@
1617 atoms.push_back (Atoms::workarea);
1618
1619 atoms.push_back (Atoms::wmName);
1620+ // TODO: Why is this below commented out ?
1621 /*
1622 atoms.push_back (Atoms::wmVisibleName);
1623 */
1624@@ -2361,6 +2399,7 @@
1625 atoms.push_back (Atoms::wmStrut);
1626 atoms.push_back (Atoms::wmStrutPartial);
1627
1628+ // TODO: Why is this below commented out ?
1629 /*
1630 atoms.push_back (Atoms::wmPid);
1631 */
1632@@ -2387,7 +2426,7 @@
1633 atoms.push_back (Atoms::winOpacity);
1634 atoms.push_back (Atoms::winBrightness);
1635
1636-/* FIXME */
1637+/* TODO: FIXME */
1638 #if 0
1639 if (canDoSaturated)
1640 {
1641@@ -2435,14 +2474,14 @@
1642 PrivateScreen::getDesktopHints (unsigned int showingDesktopMask)
1643 {
1644 unsigned long data[2];
1645- Atom actual;
1646- int result, format;
1647+ Atom actual;
1648+ int result, format;
1649 unsigned long n, left;
1650 unsigned char *propData;
1651
1652 if (useDesktopHints)
1653 {
1654- result = XGetWindowProperty (dpy, rootWindow(),
1655+ result = XGetWindowProperty (dpy, rootWindow (),
1656 Atoms::numberOfDesktops,
1657 0L, 1L, false, XA_CARDINAL, &actual,
1658 &format, &n, &left, &propData);
1659@@ -2452,6 +2491,7 @@
1660 if (n)
1661 {
1662 memcpy (data, propData, sizeof (unsigned long));
1663+
1664 if (data[0] > 0 && data[0] < 0xffffffff)
1665 nDesktop = data[0];
1666 }
1667@@ -2459,7 +2499,7 @@
1668 XFree (propData);
1669 }
1670
1671- result = XGetWindowProperty (dpy, rootWindow(),
1672+ result = XGetWindowProperty (dpy, rootWindow (),
1673 Atoms::desktopViewport, 0L, 2L,
1674 false, XA_CARDINAL, &actual, &format,
1675 &n, &left, &propData);
1676@@ -2482,7 +2522,7 @@
1677 XFree (propData);
1678 }
1679
1680- result = XGetWindowProperty (dpy, rootWindow(),
1681+ result = XGetWindowProperty (dpy, rootWindow (),
1682 Atoms::currentDesktop,
1683 0L, 1L, false, XA_CARDINAL, &actual,
1684 &format, &n, &left, &propData);
1685@@ -2492,6 +2532,7 @@
1686 if (n)
1687 {
1688 memcpy (data, propData, sizeof (unsigned long));
1689+
1690 if (data[0] < nDesktop)
1691 currentDesktop = data[0];
1692 }
1693@@ -2500,7 +2541,7 @@
1694 }
1695 }
1696
1697- result = XGetWindowProperty (dpy, rootWindow(),
1698+ result = XGetWindowProperty (dpy, rootWindow (),
1699 Atoms::showingDesktop,
1700 0L, 1L, false, XA_CARDINAL, &actual, &format,
1701 &n, &left, &propData);
1702@@ -2510,6 +2551,7 @@
1703 if (n)
1704 {
1705 memcpy (data, propData, sizeof (unsigned long));
1706+
1707 if (data[0])
1708 screen->enterShowDesktopMode ();
1709 }
1710@@ -2519,13 +2561,13 @@
1711
1712 data[0] = currentDesktop;
1713
1714- XChangeProperty (dpy, rootWindow(), Atoms::currentDesktop,
1715+ XChangeProperty (dpy, rootWindow (), Atoms::currentDesktop,
1716 XA_CARDINAL, 32, PropModeReplace,
1717 (unsigned char *) data, 1);
1718
1719 data[0] = showingDesktopMask ? true : false;
1720
1721- XChangeProperty (dpy, rootWindow(), Atoms::showingDesktop,
1722+ XChangeProperty (dpy, rootWindow (), Atoms::showingDesktop,
1723 XA_CARDINAL, 32, PropModeReplace,
1724 (unsigned char *) data, 1);
1725 }
1726@@ -2537,29 +2579,31 @@
1727 _enterShowDesktopMode ();
1728 }
1729
1730-unsigned int CompScreenImpl::showingDesktopMask() const
1731+unsigned int CompScreenImpl::showingDesktopMask () const
1732 {
1733 return showingDesktopMask_;
1734 }
1735
1736-bool CompScreenImpl::grabsEmpty() const
1737+bool CompScreenImpl::grabsEmpty () const
1738 {
1739- return privateScreen.eventManager.grabsEmpty();
1740+ return privateScreen.eventManager.grabsEmpty ();
1741 }
1742
1743 void
1744 CompScreenImpl::_enterShowDesktopMode ()
1745 {
1746- unsigned long data = 1;
1747- int count = 0;
1748- bool st = privateScreen.optionGetHideSkipTaskbarWindows ();
1749+ unsigned long data = 1;
1750+ int count = 0;
1751+ bool st = privateScreen.optionGetHideSkipTaskbarWindows ();
1752
1753 showingDesktopMask_ = ~(CompWindowTypeDesktopMask |
1754 CompWindowTypeDockMask);
1755
1756- for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)
1757+ for (cps::WindowManager::iterator i = windowManager.begin ();
1758+ i != windowManager.end (); ++i)
1759 {
1760 CompWindow* const w(*i);
1761+
1762 if ((showingDesktopMask_ & w->wmType ()) &&
1763 (!(w->state () & CompWindowStateSkipTaskbarMask) || st))
1764 {
1765@@ -2573,7 +2617,7 @@
1766 }
1767
1768 if (w->inShowDesktopMode ())
1769- count++;
1770+ ++count;
1771 }
1772
1773 if (!count)
1774@@ -2610,9 +2654,10 @@
1775 window->priv->show ();
1776
1777 /* return if some other window is still in show desktop mode */
1778- for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)
1779+ for (cps::WindowManager::iterator i = windowManager.begin (); i != windowManager.end (); ++i)
1780 {
1781 CompWindow* const w(*i);
1782+
1783 if (w->inShowDesktopMode ())
1784 return;
1785 }
1786@@ -2622,9 +2667,10 @@
1787 {
1788 showingDesktopMask_ = 0;
1789
1790- for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)
1791+ for (cps::WindowManager::iterator i = windowManager.begin (); i != windowManager.end (); ++i)
1792 {
1793 CompWindow* const w(*i);
1794+
1795 if (!w->inShowDesktopMode ())
1796 continue;
1797
1798@@ -2638,7 +2684,7 @@
1799 focusDefaultWindow ();
1800 }
1801
1802- XChangeProperty (privateScreen.dpy, privateScreen.rootWindow(),
1803+ XChangeProperty (privateScreen.dpy, privateScreen.rootWindow (),
1804 Atoms::showingDesktop,
1805 XA_CARDINAL, 32, PropModeReplace,
1806 (unsigned char *) &data, 1);
1807@@ -2676,11 +2722,11 @@
1808 /* huh, we didn't find d->below ... perhaps it's out of date;
1809 try grabbing it through the server */
1810
1811- status = XQueryPointer (dpy (), privateScreen.rootWindow(), &rootReturn,
1812+ status = XQueryPointer (dpy (), privateScreen.rootWindow (), &rootReturn,
1813 &childReturn, &dummyInt, &dummyInt,
1814 &dummyInt, &dummyInt, &dummyUInt);
1815
1816- if (status && rootReturn == privateScreen.rootWindow())
1817+ if (status && rootReturn == privateScreen.rootWindow ())
1818 {
1819 w = findTopLevelWindow (childReturn);
1820
1821@@ -2697,8 +2743,8 @@
1822 if (!focus)
1823 {
1824 /* Traverse down the stack */
1825- for (cps::WindowManager::reverse_iterator rit = windowManager.rbegin();
1826- rit != windowManager.rend(); ++rit)
1827+ for (cps::WindowManager::reverse_iterator rit = windowManager.rbegin ();
1828+ rit != windowManager.rend (); ++rit)
1829 {
1830 w = (*rit);
1831
1832@@ -2745,8 +2791,8 @@
1833 }
1834 else
1835 {
1836- XSetInputFocus (privateScreen.dpy, privateScreen.rootWindow(), RevertToPointerRoot,
1837- CurrentTime);
1838+ XSetInputFocus (privateScreen.dpy, privateScreen.rootWindow (),
1839+ RevertToPointerRoot, CurrentTime);
1840 }
1841 }
1842
1843@@ -2760,26 +2806,23 @@
1844 cps::WindowManager::findWindow (Window id) const
1845 {
1846 if (lastFoundWindow && lastFoundWindow->id () == id)
1847- {
1848 return lastFoundWindow;
1849- }
1850 else
1851 {
1852- CompWindow::Map::const_iterator it = windowsMap.find (id);
1853+ CompWindow::Map::const_iterator it = windowsMap.find (id);
1854
1855- if (it != windowsMap.end ())
1856- return (lastFoundWindow = it->second);
1857+ if (it != windowsMap.end ())
1858+ return (lastFoundWindow = it->second);
1859 }
1860
1861 return 0;
1862 }
1863
1864 CompWindow *
1865-CompScreenImpl::findTopLevelWindow (Window id, bool override_redirect)
1866+CompScreenImpl::findTopLevelWindow (Window id,
1867+ bool override_redirect)
1868 {
1869- CompWindow *w;
1870-
1871- w = findWindow (id);
1872+ CompWindow *w = findWindow (id);
1873
1874 if (w)
1875 {
1876@@ -2792,6 +2835,7 @@
1877 for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)
1878 {
1879 CompWindow* const w(*i);
1880+
1881 if (w->priv->serverFrame == id)
1882 {
1883 if (w->overrideRedirect () && !override_redirect)
1884@@ -2805,7 +2849,8 @@
1885 }
1886
1887 void
1888-CompScreenImpl::insertWindow (CompWindow *w, Window aboveId)
1889+CompScreenImpl::insertWindow (CompWindow *w,
1890+ Window aboveId)
1891 {
1892 windowManager.insertWindow (w, aboveId);
1893 }
1894@@ -2817,7 +2862,7 @@
1895 if (dbg)
1896 dbg->windowsChanged (true);
1897
1898- invalidateServerWindows();
1899+ invalidateServerWindows ();
1900
1901 w->prev = NULL;
1902 w->next = NULL;
1903@@ -2829,9 +2874,9 @@
1904 windows.front ()->prev = w;
1905 w->next = windows.front ();
1906 }
1907+
1908 windows.push_front (w);
1909-
1910- addWindowToMap(w);
1911+ addWindowToMap (w);
1912
1913 return;
1914 }
1915@@ -2842,9 +2887,8 @@
1916 {
1917 if ((*it)->id () == aboveId ||
1918 ((*it)->priv->frame && (*it)->priv->frame == aboveId))
1919- {
1920 break;
1921- }
1922+
1923 ++it;
1924 }
1925
1926@@ -2863,16 +2907,15 @@
1927 (*it)->next = w;
1928
1929 if (w->next)
1930- {
1931 w->next->prev = w;
1932- }
1933
1934 windows.insert (++it, w);
1935- addWindowToMap(w);
1936+ addWindowToMap (w);
1937 }
1938
1939 void
1940-CompScreenImpl::insertServerWindow (CompWindow *w, Window aboveId)
1941+CompScreenImpl::insertServerWindow (CompWindow *w,
1942+ Window aboveId)
1943 {
1944 windowManager.insertServerWindow(w, aboveId);
1945 }
1946@@ -2895,6 +2938,7 @@
1947 serverWindows.front ()->serverPrev = w;
1948 w->serverNext = serverWindows.front ();
1949 }
1950+
1951 serverWindows.push_front (w);
1952
1953 return;
1954@@ -2906,9 +2950,8 @@
1955 {
1956 if ((*it)->priv->serverId == aboveId ||
1957 ((*it)->priv->serverFrame && (*it)->priv->serverFrame == aboveId))
1958- {
1959 break;
1960- }
1961+
1962 ++it;
1963 }
1964
1965@@ -2927,9 +2970,7 @@
1966 (*it)->serverNext = w;
1967
1968 if (w->serverNext)
1969- {
1970 w->serverNext->serverPrev = w;
1971- }
1972
1973 serverWindows.insert (++it, w);
1974 }
1975@@ -2938,7 +2979,7 @@
1976 cps::WindowManager::eraseWindowFromMap (Window id)
1977 {
1978 if (id != 1)
1979- windowsMap.erase (id);
1980+ windowsMap.erase (id);
1981 }
1982
1983 void
1984@@ -2948,17 +2989,16 @@
1985 }
1986
1987 void
1988-cps::WindowManager::unhookWindow(CompWindow* w)
1989+cps::WindowManager::unhookWindow (CompWindow* w)
1990 {
1991 StackDebugger *dbg = StackDebugger::Default ();
1992
1993 if (dbg)
1994 dbg->windowsChanged (true);
1995
1996- CompWindowList::iterator it =
1997- std::find (windows.begin(), windows.end(), w);
1998+ CompWindowList::iterator it = std::find (windows.begin (), windows.end (), w);
1999
2000- if (it == windows.end())
2001+ if (it == windows.end ())
2002 {
2003 compLogMessage ("core", CompLogLevelWarn, "a broken plugin tried to remove a window twice, we won't allow that!");
2004 return;
2005@@ -2976,7 +3016,7 @@
2006 w->next = NULL;
2007 w->prev = NULL;
2008
2009- removeFromFindWindowCache(w);
2010+ removeFromFindWindowCache (w);
2011 }
2012
2013 void
2014@@ -3029,25 +3069,26 @@
2015 #define POINTER_GRAB_MASK (ButtonReleaseMask | \
2016 ButtonPressMask | \
2017 PointerMotionMask)
2018+
2019 CompScreenImpl::GrabHandle
2020-CompScreenImpl::pushGrab (Cursor cursor, const char *name)
2021+CompScreenImpl::pushGrab (Cursor cursor,
2022+ const char *name)
2023 {
2024 if (privateScreen.eventManager.grabsEmpty ())
2025 {
2026- int status;
2027-
2028- status = XGrabPointer (privateScreen.dpy, privateScreen.eventManager.getGrabWindow(), true,
2029- POINTER_GRAB_MASK,
2030- GrabModeAsync, GrabModeAsync,
2031- privateScreen.rootWindow(), cursor,
2032- CurrentTime);
2033+ int status = XGrabPointer (privateScreen.dpy, privateScreen.eventManager.getGrabWindow (),
2034+ true, POINTER_GRAB_MASK,
2035+ GrabModeAsync, GrabModeAsync,
2036+ privateScreen.rootWindow (), cursor,
2037+ CurrentTime);
2038
2039 if (status == GrabSuccess)
2040 {
2041 status = XGrabKeyboard (privateScreen.dpy,
2042- privateScreen.eventManager.getGrabWindow(), true,
2043+ privateScreen.eventManager.getGrabWindow (), true,
2044 GrabModeAsync, GrabModeAsync,
2045 CurrentTime);
2046+
2047 if (status != GrabSuccess)
2048 {
2049 XUngrabPointer (privateScreen.dpy, CurrentTime);
2050@@ -3058,10 +3099,8 @@
2051 return NULL;
2052 }
2053 else
2054- {
2055 XChangeActivePointerGrab (privateScreen.dpy, POINTER_GRAB_MASK,
2056 cursor, CurrentTime);
2057- }
2058
2059 cps::Grab *grab = new cps::Grab (cursor, name);
2060 privateScreen.eventManager.grabsPush (grab);
2061@@ -3070,7 +3109,8 @@
2062 }
2063
2064 void
2065-CompScreenImpl::updateGrab (CompScreen::GrabHandle handle, Cursor cursor)
2066+CompScreenImpl::updateGrab (CompScreen::GrabHandle handle,
2067+ Cursor cursor)
2068 {
2069 if (!handle)
2070 return;
2071@@ -3083,12 +3123,12 @@
2072
2073 void
2074 CompScreenImpl::removeGrab (CompScreen::GrabHandle handle,
2075- CompPoint *restorePointer)
2076+ CompPoint *restorePointer)
2077 {
2078 if (!handle)
2079 return;
2080
2081- privateScreen.eventManager.grabsRemove(handle);
2082+ privateScreen.eventManager.grabsRemove (handle);
2083
2084 if (!privateScreen.eventManager.grabsEmpty ())
2085 {
2086@@ -3109,7 +3149,7 @@
2087 }
2088
2089 void
2090-cps::GrabList::grabsRemove(Grab* handle)
2091+cps::GrabList::grabsRemove (Grab *handle)
2092 {
2093 GrabIterator it = std::find (grabsBegin (), grabsEnd (), handle);
2094
2095@@ -3125,18 +3165,21 @@
2096 plugins listed, returns false otherwise. */
2097
2098 bool
2099-CompScreenImpl::otherGrabExist (const char *first, ...)
2100+CompScreenImpl::otherGrabExist (const char *first,
2101+ ...)
2102 {
2103 va_list ap;
2104 const char *name;
2105
2106 std::list<cps::Grab *>::iterator it;
2107
2108- for (it = privateScreen.eventManager.grabsBegin (); it != privateScreen.eventManager.grabsEnd (); ++it)
2109+ for (it = privateScreen.eventManager.grabsBegin ();
2110+ it != privateScreen.eventManager.grabsEnd (); ++it)
2111 {
2112 va_start (ap, first);
2113
2114 name = first;
2115+
2116 while (name)
2117 {
2118 if (strcmp (name, (*it)->name) == 0)
2119@@ -3164,23 +3207,22 @@
2120 cps::GrabList::grabExist (const char *grab)
2121 {
2122 foreach (cps::Grab* g, grabs)
2123- {
2124 if (strcmp (g->name, grab) == 0)
2125 return true;
2126- }
2127+
2128 return false;
2129 }
2130
2131 bool
2132 CompScreenImpl::grabbed ()
2133 {
2134- return privateScreen.eventManager.isGrabbed();
2135+ return privateScreen.eventManager.isGrabbed ();
2136 }
2137
2138 void
2139 cps::GrabManager::grabUngrabOneKey (unsigned int modifiers,
2140- int keycode,
2141- bool grab)
2142+ int keycode,
2143+ bool grab)
2144 {
2145 if (grab)
2146 {
2147@@ -3188,62 +3230,51 @@
2148 * Always grab the keyboard Sync-ronously. This is so that we can
2149 * choose to ReplayKeyboard in alwaysHandleEvent if need be.
2150 */
2151- XGrabKey (screen->dpy(),
2152+ XGrabKey (screen->dpy (),
2153 keycode,
2154 modifiers,
2155- screen->root(),
2156+ screen->root (),
2157 true,
2158 GrabModeAsync,
2159 GrabModeSync);
2160 }
2161 else
2162 {
2163- XUngrabKey (screen->dpy(),
2164+ XUngrabKey (screen->dpy (),
2165 keycode,
2166 modifiers,
2167- screen->root());
2168+ screen->root ());
2169 }
2170 }
2171
2172 bool
2173 cps::GrabManager::grabUngrabKeys (unsigned int modifiers,
2174- int keycode,
2175- bool grab)
2176+ int keycode,
2177+ bool grab)
2178 {
2179- int mod, k;
2180- unsigned int ignore;
2181-
2182- CompScreen::checkForError (screen->dpy());
2183-
2184- for (ignore = 0; ignore <= modHandler->ignoredModMask (); ignore++)
2185+ int mod, k;
2186+ int minCode, maxCode;
2187+ unsigned int ignore;
2188+
2189+ CompScreen::checkForError (screen->dpy ());
2190+
2191+ for (ignore = 0; ignore <= modHandler->ignoredModMask (); ++ignore)
2192 {
2193 if (ignore & ~modHandler->ignoredModMask ())
2194 continue;
2195
2196 if (keycode != 0)
2197- {
2198 grabUngrabOneKey (modifiers | ignore, keycode, grab);
2199- }
2200 else
2201 {
2202- for (mod = 0; mod < 8; mod++)
2203- {
2204+ for (mod = 0; mod < 8; ++mod)
2205 if (modifiers & (1 << mod))
2206- {
2207 for (k = mod * modHandler->modMap ()->max_keypermod;
2208- k < (mod + 1) * modHandler->modMap ()->max_keypermod;
2209- k++)
2210- {
2211+ k < (mod + 1) * modHandler->modMap ()->max_keypermod; ++k)
2212 if (modHandler->modMap ()->modifiermap[k])
2213- {
2214- grabUngrabOneKey ((modifiers & ~(1 << mod)) |
2215- ignore,
2216+ grabUngrabOneKey ((modifiers & ~(1 << mod)) | ignore,
2217 modHandler->modMap ()->modifiermap[k],
2218 grab);
2219- }
2220- }
2221- }
2222- }
2223
2224 /*
2225 * keycode == 0, so this is a modifier-only keybinding.
2226@@ -3255,15 +3286,15 @@
2227 * keys, and know to cancel the tap if <modifier>+k is pressed.
2228 */
2229 if (!(currentState & CompAction::StateIgnoreTap))
2230- {
2231- int minCode, maxCode;
2232- XDisplayKeycodes (screen->dpy(), &minCode, &maxCode);
2233- for (k = minCode; k <= maxCode; k++)
2234- grabUngrabOneKey (modifiers | ignore, k, grab);
2235- }
2236+ {
2237+ XDisplayKeycodes (screen->dpy (), &minCode, &maxCode);
2238+
2239+ for (k = minCode; k <= maxCode; ++k)
2240+ grabUngrabOneKey (modifiers | ignore, k, grab);
2241+ }
2242 }
2243
2244- if (CompScreen::checkForError (screen->dpy()))
2245+ if (CompScreen::checkForError (screen->dpy ()))
2246 return false;
2247 }
2248
2249@@ -3273,29 +3304,22 @@
2250 bool
2251 cps::GrabManager::addPassiveKeyGrab (CompAction::KeyBinding &key)
2252 {
2253- KeyGrab newKeyGrab;
2254- unsigned int mask;
2255- std::list<KeyGrab>::iterator it;
2256-
2257- mask = modHandler->virtualToRealModMask (key.modifiers ());
2258-
2259- for (it = keyGrabs.begin (); it != keyGrabs.end (); ++it)
2260+ KeyGrab newKeyGrab;
2261+ unsigned int mask = modHandler->virtualToRealModMask (key.modifiers ());
2262+
2263+ for (std::list<KeyGrab>::iterator it = keyGrabs.begin (); it != keyGrabs.end (); ++it)
2264 {
2265 if (key.keycode () == (*it).keycode &&
2266 mask == (*it).modifiers)
2267 {
2268- (*it).count++;
2269+ ++(*it).count;
2270 return true;
2271 }
2272 }
2273
2274-
2275-
2276- if (!(mask & CompNoMask))
2277- {
2278- if (!grabUngrabKeys (mask, key.keycode (), true))
2279- return false;
2280- }
2281+ if (!(mask & CompNoMask) &&
2282+ !grabUngrabKeys (mask, key.keycode (), true))
2283+ return false;
2284
2285 newKeyGrab.keycode = key.keycode ();
2286 newKeyGrab.modifiers = mask;
2287@@ -3309,17 +3333,16 @@
2288 void
2289 cps::GrabManager::removePassiveKeyGrab (CompAction::KeyBinding &key)
2290 {
2291- unsigned int mask;
2292- std::list<KeyGrab>::iterator it;
2293-
2294- mask = modHandler->virtualToRealModMask (key.modifiers ());
2295-
2296- for (it = keyGrabs.begin (); it != keyGrabs.end (); ++it)
2297+ unsigned int mask = modHandler->virtualToRealModMask (key.modifiers ());
2298+
2299+ for (std::list<KeyGrab>::iterator it = keyGrabs.begin ();
2300+ it != keyGrabs.end (); ++it)
2301 {
2302 if (key.keycode () == (*it).keycode &&
2303 mask == (*it).modifiers)
2304 {
2305- (*it).count--;
2306+ --(*it).count;
2307+
2308 if ((*it).count)
2309 return;
2310
2311@@ -3342,32 +3365,27 @@
2312 void
2313 cps::GrabManager::updatePassiveKeyGrabs ()
2314 {
2315- std::list<cps::KeyGrab>::iterator it;
2316-
2317- XUngrabKey (screen->dpy(), AnyKey, AnyModifier, screen->root());
2318-
2319- for (it = keyGrabs.begin (); it != keyGrabs.end (); ++it)
2320- {
2321+ XUngrabKey (screen->dpy (), AnyKey, AnyModifier, screen->root ());
2322+
2323+ for (std::list<cps::KeyGrab>::iterator it = keyGrabs.begin ();
2324+ it != keyGrabs.end (); ++it)
2325 if (!((*it).modifiers & CompNoMask))
2326- {
2327 grabUngrabKeys ((*it).modifiers,
2328 (*it).keycode, true);
2329- }
2330- }
2331 }
2332
2333 bool
2334 cps::GrabManager::addPassiveButtonGrab (CompAction::ButtonBinding &button)
2335 {
2336- ButtonGrab newButtonGrab;
2337- std::list<ButtonGrab>::iterator it;
2338+ ButtonGrab newButtonGrab;
2339
2340- for (it = buttonGrabs.begin (); it != buttonGrabs.end (); ++it)
2341+ for (std::list<ButtonGrab>::iterator it = buttonGrabs.begin ();
2342+ it != buttonGrabs.end (); ++it)
2343 {
2344 if (button.button () == (*it).button &&
2345 button.modifiers () == (*it).modifiers)
2346 {
2347- (*it).count++;
2348+ ++(*it).count;
2349 return true;
2350 }
2351 }
2352@@ -3395,18 +3413,17 @@
2353 continue;
2354
2355 for (unsigned int ignore = 0;
2356- ignore <= modHandler->ignoredModMask (); ignore++)
2357+ ignore <= modHandler->ignoredModMask (); ++ignore)
2358 {
2359 if (ignore & ~modHandler->ignoredModMask ())
2360 continue;
2361
2362- XGrabButton (screen->dpy(),
2363+ XGrabButton (screen->dpy (),
2364 bind.button,
2365 mods | ignore,
2366 serverFrame,
2367 false,
2368- ButtonPressMask | ButtonReleaseMask |
2369- ButtonMotionMask,
2370+ ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
2371 GrabModeSync,
2372 GrabModeAsync,
2373 None,
2374@@ -3418,14 +3435,14 @@
2375 void
2376 cps::GrabManager::removePassiveButtonGrab (CompAction::ButtonBinding &button)
2377 {
2378- std::list<ButtonGrab>::iterator it;
2379-
2380- for (it = buttonGrabs.begin (); it != buttonGrabs.end (); ++it)
2381+ for (std::list<ButtonGrab>::iterator it = buttonGrabs.begin ();
2382+ it != buttonGrabs.end (); ++it)
2383 {
2384 if (button.button () == (*it).button &&
2385 button.modifiers () == (*it).modifiers)
2386 {
2387- (*it).count--;
2388+ --(*it).count;
2389+
2390 if ((*it).count)
2391 return;
2392
2393@@ -3447,37 +3464,30 @@
2394 CompScreenImpl::addAction (CompAction *action)
2395 {
2396 assert (privateScreen.initialized);
2397- if (!privateScreen.initialized)
2398- return false;
2399-
2400- if (action->active ())
2401- return false;
2402-
2403- grabManager.setCurrentState(action->state());
2404-
2405- if (action->type () & CompAction::BindingTypeKey)
2406- {
2407- if (!grabManager.addPassiveKeyGrab (action->key ()))
2408- return false;
2409- }
2410-
2411- if (action->type () & CompAction::BindingTypeButton)
2412- {
2413- if (!grabManager.addPassiveButtonGrab (action->button ()))
2414- {
2415- if (action->type () & CompAction::BindingTypeKey)
2416- grabManager.removePassiveKeyGrab (action->key ());
2417-
2418- return false;
2419- }
2420+
2421+ if (!privateScreen.initialized ||
2422+ action->active ())
2423+ return false;
2424+
2425+ grabManager.setCurrentState(action->state ());
2426+
2427+ if (action->type () & CompAction::BindingTypeKey &&
2428+ !grabManager.addPassiveKeyGrab (action->key ()))
2429+ return false;
2430+
2431+ if (action->type () & CompAction::BindingTypeButton &&
2432+ !grabManager.addPassiveButtonGrab (action->button ()))
2433+ {
2434+ if (action->type () & CompAction::BindingTypeKey)
2435+ grabManager.removePassiveKeyGrab (action->key ());
2436+
2437+ return false;
2438 }
2439
2440 if (action->edgeMask ())
2441- {
2442- for (int i = 0; i < SCREEN_EDGE_NUM; i++)
2443+ for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
2444 if (action->edgeMask () & (1 << i))
2445 privateScreen.enableEdge (i);
2446- }
2447
2448 ca::setActionActiveState (*action, true);
2449
2450@@ -3491,7 +3501,7 @@
2451 !action->active ())
2452 return;
2453
2454- grabManager.setCurrentState(action->state());
2455+ grabManager.setCurrentState(action->state ());
2456
2457 if (action->type () & CompAction::BindingTypeKey)
2458 grabManager.removePassiveKeyGrab (action->key ());
2459@@ -3500,11 +3510,9 @@
2460 grabManager.removePassiveButtonGrab (action->button ());
2461
2462 if (action->edgeMask ())
2463- {
2464- for (int i = 0; i < SCREEN_EDGE_NUM; i++)
2465+ for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
2466 if (action->edgeMask () & (1 << i))
2467 privateScreen.disableEdge (i);
2468- }
2469
2470 ca::setActionActiveState (*action, false);
2471 }
2472@@ -3512,14 +3520,14 @@
2473 void
2474 CompScreenImpl::updateWorkarea ()
2475 {
2476- CompRect workArea;
2477- CompRegion allWorkArea = CompRegion ();
2478- bool workAreaChanged = false;
2479- privateScreen.outputDevices.computeWorkAreas(
2480- workArea,
2481- workAreaChanged,
2482- allWorkArea,
2483- windowManager.getWindows());
2484+ CompRect workArea;
2485+ CompRegion allWorkArea = CompRegion ();
2486+ bool workAreaChanged = false;
2487+
2488+ privateScreen.outputDevices.computeWorkAreas (workArea,
2489+ workAreaChanged,
2490+ allWorkArea,
2491+ windowManager.getWindows ());
2492
2493 workArea = allWorkArea.boundingRect ();
2494
2495@@ -3535,7 +3543,7 @@
2496 {
2497 /* as work area changed, update all maximized windows on this
2498 screen to snap to the new work area */
2499- windowManager.updateWindowSizes();
2500+ windowManager.updateWindowSizes ();
2501 }
2502 }
2503
2504@@ -3545,17 +3553,10 @@
2505 /* windows with client id less than 2 have been destroyed and only exists
2506 because some plugin keeps a reference to them. they should not be in
2507 client lists */
2508- if (w->id () < 2)
2509- return false;
2510-
2511- if (w->overrideRedirect ())
2512- return false;
2513-
2514- if (!w->isViewable ())
2515- {
2516- if (!(w->state () & CompWindowStateHiddenMask))
2517- return false;
2518- }
2519+ if (w->id () < 2 ||
2520+ w->overrideRedirect () ||
2521+ (!w->isViewable () && !(w->state () & CompWindowStateHiddenMask)))
2522+ return false;
2523
2524 return true;
2525 }
2526@@ -3565,9 +3566,7 @@
2527 int *n)
2528 {
2529 if (isClientListWindow (w))
2530- {
2531 *n = *n + 1;
2532- }
2533 }
2534
2535 static bool
2536@@ -3578,15 +3577,15 @@
2537 }
2538
2539 void
2540-cps::WindowManager::updateClientList (PrivateScreen& ps)
2541+cps::WindowManager::updateClientList (PrivateScreen &ps)
2542 {
2543- bool updateClientList = false;
2544- bool updateClientListStacking = false;
2545- int n = 0;
2546+ bool updateClientList = false;
2547+ bool updateClientListStacking = false;
2548+ int n = 0;
2549
2550 screen->forEachWindow (boost::bind (countClientListWindow, _1, &n));
2551
2552- if (n == 0)
2553+ if (!n)
2554 {
2555 if ((unsigned int) n != clientList.size ())
2556 {
2557@@ -3595,14 +3594,14 @@
2558 clientIdList.clear ();
2559 clientIdListStacking.clear ();
2560
2561- XChangeProperty (ps.dpy, ps.rootWindow(),
2562+ XChangeProperty (ps.dpy, ps.rootWindow (),
2563 Atoms::clientList,
2564 XA_WINDOW, 32, PropModeReplace,
2565- (unsigned char *) &ps.eventManager.getGrabWindow(), 1);
2566- XChangeProperty (ps.dpy, ps.rootWindow(),
2567+ (unsigned char *) &ps.eventManager.getGrabWindow (), 1);
2568+ XChangeProperty (ps.dpy, ps.rootWindow (),
2569 Atoms::clientListStacking,
2570 XA_WINDOW, 32, PropModeReplace,
2571- (unsigned char *) &ps.eventManager.getGrabWindow(), 1);
2572+ (unsigned char *) &ps.eventManager.getGrabWindow (), 1);
2573 }
2574
2575 return;
2576@@ -3618,9 +3617,10 @@
2577
2578 clientListStacking.clear ();
2579
2580- for (iterator i = begin(); i != end(); ++i)
2581+ for (iterator i = begin (); i != end (); ++i)
2582 {
2583 CompWindow* const w(*i);
2584+
2585 if (isClientListWindow (w))
2586 clientListStacking.push_back (w);
2587 }
2588@@ -3633,61 +3633,57 @@
2589 compareMappingOrder);
2590
2591 /* make sure client id lists are up-to-date */
2592- for (int i = 0; i < n; i++)
2593+ for (int i = 0; i < n; ++i)
2594 {
2595 if (!updateClientList &&
2596 clientIdList[i] != clientList[i]->id ())
2597- {
2598 updateClientList = true;
2599- }
2600
2601 clientIdList[i] = clientList[i]->id ();
2602 }
2603- for (int i = 0; i < n; i++)
2604+ for (int i = 0; i < n; ++i)
2605 {
2606 if (!updateClientListStacking &&
2607 clientIdListStacking[i] != clientListStacking[i]->id ())
2608- {
2609 updateClientListStacking = true;
2610- }
2611
2612 clientIdListStacking[i] = clientListStacking[i]->id ();
2613 }
2614
2615 if (updateClientList)
2616- XChangeProperty (ps.dpy, ps.rootWindow(),
2617+ XChangeProperty (ps.dpy, ps.rootWindow (),
2618 Atoms::clientList,
2619 XA_WINDOW, 32, PropModeReplace,
2620 (unsigned char *) &clientIdList.at (0), n);
2621
2622 if (updateClientListStacking)
2623- XChangeProperty (ps.dpy, ps.rootWindow(),
2624+ XChangeProperty (ps.dpy, ps.rootWindow (),
2625 Atoms::clientListStacking,
2626 XA_WINDOW, 32, PropModeReplace,
2627- (unsigned char *) &clientIdListStacking.at (0),
2628- n);
2629+ (unsigned char *) &clientIdListStacking.at (0), n);
2630 }
2631
2632 const CompWindowVector &
2633 CompScreenImpl::clientList (bool stackingOrder)
2634 {
2635- return stackingOrder ? windowManager.getClientListStacking() : windowManager.getClientList();
2636+ return stackingOrder ? windowManager.getClientListStacking () :
2637+ windowManager.getClientList ();
2638 }
2639
2640 void
2641 CompScreenImpl::toolkitAction (Atom toolkitAction,
2642- Time eventTime,
2643- Window window,
2644- long data0,
2645- long data1,
2646- long data2)
2647+ Time eventTime,
2648+ Window window,
2649+ long data0,
2650+ long data1,
2651+ long data2)
2652 {
2653 XEvent ev;
2654
2655- ev.type = ClientMessage;
2656- ev.xclient.window = window;
2657+ ev.type = ClientMessage;
2658+ ev.xclient.window = window;
2659 ev.xclient.message_type = Atoms::toolkitAction;
2660- ev.xclient.format = 32;
2661+ ev.xclient.format = 32;
2662 ev.xclient.data.l[0] = toolkitAction;
2663 ev.xclient.data.l[1] = eventTime;
2664 ev.xclient.data.l[2] = data0;
2665@@ -3697,7 +3693,7 @@
2666 XUngrabPointer (privateScreen.dpy, CurrentTime);
2667 XUngrabKeyboard (privateScreen.dpy, CurrentTime);
2668
2669- XSendEvent (privateScreen.dpy, privateScreen.rootWindow(), false,
2670+ XSendEvent (privateScreen.dpy, privateScreen.rootWindow (), false,
2671 StructureNotifyMask, &ev);
2672 }
2673
2674@@ -3709,23 +3705,21 @@
2675
2676 if (fork () == 0)
2677 {
2678- size_t pos;
2679- CompString env (privateScreen.displayString ());
2680+ CompString env (privateScreen.displayString ());
2681
2682 setsid ();
2683
2684- pos = env.find (':');
2685+ size_t pos = env.find (':');
2686+
2687 if (pos != std::string::npos)
2688 {
2689- size_t pointPos = env.find ('.', pos);
2690+ size_t pointPos = env.find ('.', pos);
2691
2692 if (pointPos != std::string::npos)
2693- {
2694 env.erase (pointPos);
2695- }
2696 else
2697 {
2698- unsigned int displayNum = atoi (env.substr (pos + 1).c_str ());
2699+ unsigned int displayNum = atoi (env.substr (pos + 1).c_str ());
2700 env.erase (pos);
2701 env.append (compPrintf (":%i", displayNum));
2702 }
2703@@ -3740,7 +3734,9 @@
2704 }
2705
2706 void
2707-CompScreenImpl::moveViewport (int tx, int ty, bool sync)
2708+CompScreenImpl::moveViewport (int tx,
2709+ int ty,
2710+ bool sync)
2711 {
2712 CompPoint pnt;
2713
2714@@ -3761,11 +3757,14 @@
2715 tx *= -width ();
2716 ty *= -height ();
2717
2718- for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i)
2719+ unsigned int valueMask;
2720+
2721+ for (cps::WindowManager::iterator i = windowManager.begin ();
2722+ i != windowManager.end (); ++i)
2723 {
2724- CompWindow* const w(*i);
2725- unsigned int valueMask = CWX | CWY;
2726- XWindowChanges xwc= XWINDOWCHANGES_INIT;
2727+ CompWindow* const w (*i);
2728+ valueMask = CWX | CWY;
2729+ XWindowChanges xwc = XWINDOWCHANGES_INIT;
2730
2731 if (w->onAllViewports ())
2732 continue;
2733@@ -3786,18 +3785,15 @@
2734
2735 if (sync)
2736 {
2737- CompWindow *w;
2738-
2739 privateScreen.setDesktopHints ();
2740
2741 setCurrentActiveWindowHistory (privateScreen.viewPort.vp.x (), privateScreen.viewPort.vp.y ());
2742
2743- w = findWindow (privateScreen.orphanData.activeWindow);
2744+ CompWindow *w = findWindow (privateScreen.orphanData.activeWindow);
2745+
2746 if (w)
2747 {
2748- CompPoint dvp;
2749-
2750- dvp = w->defaultViewport ();
2751+ CompPoint dvp = w->defaultViewport ();
2752
2753 /* add window to current history if it's default viewport is
2754 still the current one. */
2755@@ -3823,7 +3819,8 @@
2756 void
2757 cps::WindowManager::removeGroup (CompGroup *group)
2758 {
2759- group->refCnt--;
2760+ --group->refCnt;
2761+
2762 if (group->refCnt)
2763 return;
2764
2765@@ -3831,9 +3828,7 @@
2766 std::find (groups.begin (), groups.end (), group);
2767
2768 if (it != groups.end ())
2769- {
2770 groups.erase (it);
2771- }
2772
2773 delete group;
2774 }
2775@@ -3849,16 +3844,16 @@
2776 }
2777
2778 void
2779-cps::StartupSequence::applyStartupProperties (CompScreen* screen, CompWindow *window)
2780+cps::StartupSequence::applyStartupProperties (CompScreen *screen,
2781+ CompWindow *window)
2782 {
2783 CompStartupSequence *s = NULL;
2784 const char *startupId = window->startupId ();
2785
2786 if (!startupId)
2787 {
2788- CompWindow *leader;
2789+ CompWindow *leader = screen->findWindow (window->clientLeader ());
2790
2791- leader = screen->findWindow (window->clientLeader ());
2792 if (leader)
2793 startupId = leader->startupId ();
2794
2795@@ -3868,9 +3863,8 @@
2796
2797 foreach (CompStartupSequence *ss, startupSequences)
2798 {
2799- const char *id;
2800+ const char *id = sn_startup_sequence_get_id (ss->sequence);
2801
2802- id = sn_startup_sequence_get_id (ss->sequence);
2803 if (strcmp (id, startupId) == 0)
2804 {
2805 s = ss;
2806@@ -3892,7 +3886,7 @@
2807 xev.xclient.format = 32;
2808
2809 xev.xclient.message_type = Atoms::winActive;
2810- xev.xclient.window = id;
2811+ xev.xclient.window = id;
2812
2813 xev.xclient.data.l[0] = ClientTypePager;
2814 xev.xclient.data.l[1] = 0;
2815@@ -3900,7 +3894,7 @@
2816 xev.xclient.data.l[3] = 0;
2817 xev.xclient.data.l[4] = 0;
2818
2819- XSendEvent (privateScreen.dpy, privateScreen.rootWindow(), false,
2820+ XSendEvent (privateScreen.dpy, privateScreen.rootWindow (), false,
2821 SubstructureRedirectMask | SubstructureNotifyMask, &xev);
2822 }
2823
2824@@ -3912,7 +3906,8 @@
2825 void
2826 PrivateScreen::enableEdge (int edge)
2827 {
2828- screenEdge[edge].count++;
2829+ ++screenEdge[edge].count;
2830+
2831 if (screenEdge[edge].count == 1)
2832 XMapRaised (dpy, screenEdge[edge].id);
2833 }
2834@@ -3920,13 +3915,14 @@
2835 void
2836 PrivateScreen::disableEdge (int edge)
2837 {
2838- screenEdge[edge].count--;
2839+ --screenEdge[edge].count;
2840+
2841 if (screenEdge[edge].count == 0)
2842 XUnmapWindow (dpy, screenEdge[edge].id);
2843 }
2844
2845 CompWindow *
2846-cps::WindowManager::getTopWindow() const
2847+cps::WindowManager::getTopWindow () const
2848 {
2849 /* return first window that has not been destroyed */
2850 if (!windows.empty ())
2851@@ -3951,7 +3947,8 @@
2852 }
2853
2854 int
2855-CompScreenImpl::outputDeviceForPoint (int x, int y)
2856+CompScreenImpl::outputDeviceForPoint (int x,
2857+ int y)
2858 {
2859 CompWindow::Geometry geom (x, y, 1, 1, 0);
2860
2861@@ -3992,7 +3989,7 @@
2862
2863 unsigned long data = desktop;
2864
2865- XChangeProperty (dpy, rootWindow(), Atoms::currentDesktop,
2866+ XChangeProperty (dpy, rootWindow (), Atoms::currentDesktop,
2867 XA_CARDINAL, 32, PropModeReplace,
2868 (unsigned char *) &data, 1);
2869 }
2870@@ -4024,6 +4021,11 @@
2871 * XXX: It is possible for this function to return a negative viewport, which
2872 * definitely feels wrong, however it seems that some plugins depend on this behaviour
2873 * so they need to be fixed first
2874+ *
2875+ * TODO: This function is responsible for several problems as the viewport containing
2876+ * the center of the window is not always the correct one.
2877+ * A example for this buggy behaviour is that a window maximizes offscreen, if
2878+ * it's center is offscreen !
2879 */
2880 void
2881 compiz::private_screen::viewports::viewportForGeometry (const CompWindow::Geometry &gm,
2882@@ -4032,30 +4034,31 @@
2883 const CompSize & screenSize)
2884 {
2885 CompRect rect (gm);
2886- int offset;
2887
2888- const CompPoint &vp = viewports->getCurrentViewport ();
2889- const CompSize &vpSize = viewports->viewportDimensions ();
2890+ const CompPoint &vp = viewports->getCurrentViewport ();
2891+ const CompSize &vpSize = viewports->viewportDimensions ();
2892
2893 rect.setWidth (gm.widthIncBorders ());
2894 rect.setHeight (gm.heightIncBorders ());
2895
2896- offset = rect.centerX () < 0 ? -1 : 0;
2897- viewport.setX (vp.x () + ((rect.centerX () / screenSize.width ()) + offset) % vpSize.width ());
2898+ int offset = rect.centerX () < 0 ? -1 : 0;
2899+ viewport.setX (vp.x () + ((rect.centerX () / screenSize.width ()) + offset) %
2900+ vpSize.width ());
2901
2902 offset = rect.centerY () < 0 ? -1 : 0;
2903- viewport.setY (vp.y () + ((rect.centerY () / screenSize.height ()) + offset ) % vpSize.height ());
2904+ viewport.setY (vp.y () + ((rect.centerY () / screenSize.height ()) + offset ) %
2905+ vpSize.height ());
2906 }
2907
2908 void
2909-CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm,
2910- CompPoint& viewport)
2911+CompScreenImpl::viewportForGeometry (const CompWindow::Geometry &gm,
2912+ CompPoint &viewport)
2913 {
2914 compiz::private_screen::viewports::viewportForGeometry (gm, viewport, &privateScreen.viewPort, *this);
2915 }
2916
2917 int
2918-CompScreenImpl::outputDeviceForGeometry (const CompWindow::Geometry& gm)
2919+CompScreenImpl::outputDeviceForGeometry (const CompWindow::Geometry &gm)
2920 {
2921 return privateScreen.outputDevices.outputDeviceForGeometry (gm, privateScreen.optionGetOverlappingOutputs (), this);
2922 }
2923@@ -4094,11 +4097,12 @@
2924 }
2925
2926 void
2927-cps::History::setCurrentActiveWindowHistory (int x, int y)
2928+cps::History::setCurrentActiveWindowHistory (int x,
2929+ int y)
2930 {
2931 int i, min = 0;
2932
2933- for (i = 0; i < ACTIVE_WINDOW_HISTORY_NUM; i++)
2934+ for (i = 0; i < ACTIVE_WINDOW_HISTORY_NUM; ++i)
2935 {
2936 if (history[i].x == x && history[i].y == y)
2937 {
2938@@ -4107,7 +4111,7 @@
2939 }
2940 }
2941
2942- for (i = 1; i < ACTIVE_WINDOW_HISTORY_NUM; i++)
2943+ for (i = 1; i < ACTIVE_WINDOW_HISTORY_NUM; ++i)
2944 if (history[i].activeNum < history[min].activeNum)
2945 min = i;
2946
2947@@ -4124,10 +4128,10 @@
2948 cps::History::addToCurrentActiveWindowHistory (Window id)
2949 {
2950 CompActiveWindowHistory *history = &this->history[currentHistory_];
2951- Window tmp, next = id;
2952+ Window tmp, next = id;
2953
2954 /* walk and move history */
2955- for (int i = 0; i < ACTIVE_WINDOW_HISTORY_SIZE; i++)
2956+ for (int i = 0; i < ACTIVE_WINDOW_HISTORY_SIZE; ++i)
2957 {
2958 tmp = history->id[i];
2959 history->id[i] = next;
2960@@ -4161,7 +4165,7 @@
2961 Window
2962 CompScreenImpl::root ()
2963 {
2964- return privateScreen.rootWindow();
2965+ return privateScreen.rootWindow ();
2966 }
2967
2968 int
2969@@ -4171,10 +4175,11 @@
2970 }
2971
2972 void
2973-PrivateScreen::identifyEdgeWindow(Window id)
2974+PrivateScreen::identifyEdgeWindow (Window id)
2975 {
2976 edgeWindow = 0;
2977- for (unsigned int i = 0; i < SCREEN_EDGE_NUM; i++)
2978+
2979+ for (unsigned int i = 0; i < SCREEN_EDGE_NUM; ++i)
2980 {
2981 if (id == screenEdge[i].id)
2982 {
2983@@ -4186,9 +4191,9 @@
2984
2985 void
2986 CompScreenImpl::warpPointer (int dx,
2987- int dy)
2988+ int dy)
2989 {
2990- XEvent event;
2991+ XEvent event;
2992
2993 pointerX += dx;
2994 pointerY += dy;
2995@@ -4204,7 +4209,7 @@
2996 pointerY = 0;
2997
2998 XWarpPointer (privateScreen.dpy,
2999- None, privateScreen.rootWindow(),
3000+ None, privateScreen.rootWindow (),
3001 0, 0, 0, 0,
3002 pointerX, pointerY);
3003
3004@@ -4228,17 +4233,11 @@
3005 EnterWindowMask |
3006 PointerMotionMask,
3007 &event))
3008- {
3009- if (event.type == EnterNotify)
3010- {
3011- if (event.xcrossing.mode != NotifyGrab ||
3012- event.xcrossing.mode != NotifyUngrab ||
3013- event.xcrossing.mode != NotifyInferior)
3014- {
3015- privateScreen.identifyEdgeWindow(event.xcrossing.window);
3016- }
3017- }
3018- }
3019+ if (event.type == EnterNotify &&
3020+ (event.xcrossing.mode != NotifyGrab ||
3021+ event.xcrossing.mode != NotifyUngrab ||
3022+ event.xcrossing.mode != NotifyInferior))
3023+ privateScreen.identifyEdgeWindow(event.xcrossing.window);
3024
3025 if (!inHandleEvent)
3026 {
3027@@ -4250,22 +4249,21 @@
3028 CompWindowList &
3029 CompScreenImpl::windows ()
3030 {
3031- return windowManager.getWindows();
3032+ return windowManager.getWindows ();
3033 }
3034
3035 CompWindowList &
3036 CompScreenImpl::serverWindows ()
3037 {
3038- return windowManager.getServerWindows();
3039+ return windowManager.getServerWindows ();
3040 }
3041
3042 CompWindowList &
3043 CompScreenImpl::destroyedWindows ()
3044 {
3045- return windowManager.getDestroyedWindows();
3046+ return windowManager.getDestroyedWindows ();
3047 }
3048
3049-
3050 Time
3051 CompScreenImpl::getCurrentTime ()
3052 {
3053@@ -4379,7 +4377,7 @@
3054 }
3055 }
3056
3057- pendingDestroys--;
3058+ --pendingDestroys;
3059 }
3060 }
3061
3062@@ -4401,7 +4399,6 @@
3063 return privateScreen.fullscreenOutput;
3064 }
3065
3066-
3067 XWindowAttributes
3068 CompScreenImpl::attrib ()
3069 {
3070@@ -4426,27 +4423,28 @@
3071 }
3072
3073 CompScreenImpl::CompScreenImpl () :
3074- cps::XWindowInfo(privateScreen.dpy),
3075- below(),
3076- autoRaiseTimer_(),
3077- autoRaiseWindow_(0),
3078- defaultIcon_(0),
3079+ cps::XWindowInfo (privateScreen.dpy),
3080+ below (),
3081+ autoRaiseTimer_ (),
3082+ autoRaiseWindow_ (0),
3083+ defaultIcon_ (0),
3084 grabManager (this),
3085 eventHandled (false),
3086- privateScreen(this, windowManager),
3087- showingDesktopMask_(0)
3088+ privateScreen (this, windowManager),
3089+ showingDesktopMask_ (0)
3090 {
3091 ValueHolder::SetDefault (&valueHolder);
3092
3093 CompPrivate p;
3094 CompOption::Value::Vector vList;
3095
3096- privateScreen.setPingTimerCallback(
3097+ privateScreen.setPingTimerCallback (
3098 boost::bind (&CompScreenImpl::handlePingTimeout, this));
3099
3100 screenInitalized = true;
3101
3102- CompPlugin* corePlugin = CompPlugin::load ("core");
3103+ CompPlugin *corePlugin = CompPlugin::load ("core");
3104+
3105 if (!corePlugin)
3106 {
3107 compLogMessage ("core", CompLogLevelFatal,
3108@@ -4470,22 +4468,22 @@
3109 }
3110
3111 void
3112-PrivateScreen::setPlugins(CompOption::Value::Vector const& vList)
3113+PrivateScreen::setPlugins (CompOption::Value::Vector const &vList)
3114 {
3115 pluginManager.setPlugins(vList);
3116 }
3117
3118 void
3119-PrivateScreen::initPlugins()
3120+PrivateScreen::initPlugins ()
3121 {
3122 pluginManager.setDirtyPluginList ();
3123- pluginManager.updatePlugins (screen, optionGetActivePlugins());
3124+ pluginManager.updatePlugins (screen, optionGetActivePlugins ());
3125 }
3126
3127 bool
3128 CompScreenImpl::init (const char *name)
3129 {
3130- privateScreen.eventManager.init();
3131+ privateScreen.eventManager.init ();
3132
3133 if (privateScreen.initDisplay(name, *this, showingDesktopMask_))
3134 {
3135@@ -4502,10 +4500,8 @@
3136 privateScreen.optionSetMinimizeWindowKeyInitiate (CompScreenImpl::minimizeWin);
3137 privateScreen.optionSetMinimizeWindowButtonInitiate (CompScreenImpl::minimizeWin);
3138 privateScreen.optionSetMaximizeWindowKeyInitiate (CompScreenImpl::maximizeWin);
3139- privateScreen.optionSetMaximizeWindowHorizontallyKeyInitiate (
3140- CompScreenImpl::maximizeWinHorizontally);
3141- privateScreen.optionSetMaximizeWindowVerticallyKeyInitiate (
3142- CompScreenImpl::maximizeWinVertically);
3143+ privateScreen.optionSetMaximizeWindowHorizontallyKeyInitiate (CompScreenImpl::maximizeWinHorizontally);
3144+ privateScreen.optionSetMaximizeWindowVerticallyKeyInitiate (CompScreenImpl::maximizeWinVertically);
3145
3146 privateScreen.optionSetWindowMenuKeyInitiate (CompScreenImpl::windowMenu);
3147 privateScreen.optionSetWindowMenuButtonInitiate (CompScreenImpl::windowMenu);
3148@@ -4523,34 +4519,33 @@
3149
3150 privateScreen.optionSetToggleWindowShadedKeyInitiate (CompScreenImpl::shadeWin);
3151
3152- privateScreen.initPlugins();
3153+ privateScreen.initPlugins ();
3154
3155 if (debugOutput)
3156 {
3157- StackDebugger::SetDefault (
3158- new StackDebugger (
3159- dpy (),
3160- root (),
3161- &privateScreen));
3162+ StackDebugger::SetDefault (new StackDebugger (dpy (),
3163+ root (),
3164+ &privateScreen));
3165 }
3166
3167 return true;
3168 }
3169+
3170 return false;
3171 }
3172
3173 void
3174 cps::EventManager::init ()
3175 {
3176- ctx = Glib::MainContext::get_default ();
3177- mainloop = Glib::MainLoop::create (ctx, false);
3178- sighupSource = CompSignalSource::create (SIGHUP, boost::bind (&EventManager::handleSignal, this, _1));
3179- sigintSource = CompSignalSource::create (SIGINT, boost::bind (&EventManager::handleSignal, this, _1));
3180+ ctx = Glib::MainContext::get_default ();
3181+ mainloop = Glib::MainLoop::create (ctx, false);
3182+ sighupSource = CompSignalSource::create (SIGHUP, boost::bind (&EventManager::handleSignal, this, _1));
3183+ sigintSource = CompSignalSource::create (SIGINT, boost::bind (&EventManager::handleSignal, this, _1));
3184 sigtermSource = CompSignalSource::create (SIGTERM, boost::bind (&EventManager::handleSignal, this, _1));
3185 }
3186
3187 bool
3188-CompScreenImpl::displayInitialised() const
3189+CompScreenImpl::displayInitialised () const
3190 {
3191 return privateScreen.initialized;
3192 }
3193@@ -4568,31 +4563,31 @@
3194 }
3195
3196 void
3197-CompScreenImpl::updateClientList()
3198+CompScreenImpl::updateClientList ()
3199 {
3200 privateScreen.updateClientList ();
3201 }
3202
3203 CompWindow *
3204-CompScreenImpl::getTopWindow() const
3205+CompScreenImpl::getTopWindow () const
3206 {
3207- return windowManager.getTopWindow();
3208+ return windowManager.getTopWindow ();
3209 }
3210
3211 CompWindow *
3212 CompScreenImpl::getTopServerWindow () const
3213 {
3214- return windowManager.getTopServerWindow();
3215+ return windowManager.getTopServerWindow ();
3216 }
3217
3218-CoreOptions&
3219-CompScreenImpl::getCoreOptions()
3220+CoreOptions &
3221+CompScreenImpl::getCoreOptions ()
3222 {
3223 return privateScreen;
3224 }
3225
3226 Colormap
3227-CompScreenImpl::colormap() const
3228+CompScreenImpl::colormap () const
3229 {
3230 return privateScreen.colormap;
3231 }
3232@@ -4600,11 +4595,11 @@
3233 void
3234 CompScreenImpl::setCurrentDesktop (unsigned int desktop)
3235 {
3236- privateScreen.setCurrentDesktop(desktop);
3237+ privateScreen.setCurrentDesktop (desktop);
3238 }
3239
3240 Window
3241-CompScreenImpl::activeWindow() const
3242+CompScreenImpl::activeWindow () const
3243 {
3244 return privateScreen.orphanData.activeWindow;
3245 }
3246@@ -4612,70 +4607,73 @@
3247 void
3248 CompScreenImpl::updatePassiveButtonGrabs(Window serverFrame)
3249 {
3250- grabManager.updatePassiveButtonGrabs(serverFrame);
3251+ grabManager.updatePassiveButtonGrabs (serverFrame);
3252 }
3253
3254 bool
3255-CompScreenImpl::grabWindowIsNot(Window w) const
3256+CompScreenImpl::grabWindowIsNot (Window w) const
3257 {
3258- return privateScreen.eventManager.notGrabWindow(w);
3259+ return privateScreen.eventManager.notGrabWindow (w);
3260 }
3261
3262 void
3263-CompScreenImpl::incrementPendingDestroys()
3264+CompScreenImpl::incrementPendingDestroys ()
3265 {
3266- windowManager.incrementPendingDestroys();
3267+ windowManager.incrementPendingDestroys ();
3268 }
3269
3270-cps::DesktopWindowCount::DesktopWindowCount() :
3271+cps::DesktopWindowCount::DesktopWindowCount () :
3272 count(0)
3273 {
3274 }
3275
3276 void
3277-cps::DesktopWindowCount::incrementDesktopWindowCount()
3278+cps::DesktopWindowCount::incrementDesktopWindowCount ()
3279 {
3280- count++;
3281+ ++count;
3282 }
3283 void
3284-cps::DesktopWindowCount::decrementDesktopWindowCount()
3285+cps::DesktopWindowCount::decrementDesktopWindowCount ()
3286 {
3287- count--;
3288+ --count;
3289 }
3290
3291-cps::MapNum::MapNum() :
3292+cps::MapNum::MapNum () :
3293 mapNum (1)
3294 {
3295 }
3296
3297 unsigned int
3298-cps::MapNum::nextMapNum()
3299+cps::MapNum::nextMapNum ()
3300 {
3301 return mapNum++;
3302 }
3303
3304 void
3305-CompScreenImpl::setNextActiveWindow(Window id)
3306+CompScreenImpl::setNextActiveWindow (Window id)
3307 {
3308 privateScreen.orphanData.nextActiveWindow = id;
3309 }
3310+
3311 Window
3312-CompScreenImpl::getNextActiveWindow() const
3313+CompScreenImpl::getNextActiveWindow () const
3314 {
3315 return privateScreen.orphanData.nextActiveWindow;
3316 }
3317
3318 namespace
3319 {
3320-void sendStartupMessageToClients (Display *dpy, bool success)
3321+void
3322+sendStartupMessageToClients (Display *dpy,
3323+ bool success)
3324 {
3325 /* Send a client message indicating that our startup is complete if
3326 * we were asked to do so */
3327 if (sendStartupMessage)
3328 {
3329- Atom startupMessageAtom = XInternAtom (dpy,
3330- "_COMPIZ_TESTING_STARTUP",
3331- FALSE);
3332+ Atom startupMessageAtom = XInternAtom (dpy,
3333+ "_COMPIZ_TESTING_STARTUP",
3334+ FALSE);
3335 XEvent startupMessageEvent;
3336 Window root = DefaultRootWindow (dpy);
3337
3338@@ -4699,11 +4697,13 @@
3339 }
3340 }
3341
3342-
3343 bool
3344-PrivateScreen::initDisplay (const char *name, cps::History& history, unsigned int showingDesktopMask)
3345+PrivateScreen::initDisplay (const char *name,
3346+ cps::History &history,
3347+ unsigned int showingDesktopMask)
3348 {
3349 dpy = XOpenDisplay (name);
3350+
3351 if (!dpy)
3352 {
3353 compLogMessage ("core", CompLogLevelFatal,
3354@@ -4723,13 +4723,14 @@
3355 XSetErrorHandler (errorHandler);
3356
3357 snDisplay = sn_display_new (dpy, NULL, NULL);
3358+
3359 if (!snDisplay)
3360 return true;
3361
3362 if (!xSync.init<XSyncQueryExtension> (dpy))
3363 {
3364 compLogMessage ("core", CompLogLevelFatal,
3365- "No sync extension");
3366+ "No sync extension");
3367 sendStartupMessageToClients (dpy, false);
3368 return false;
3369 }
3370@@ -4738,23 +4739,20 @@
3371 xShape.init<XShapeQueryExtension> (dpy);
3372
3373 xkbEvent.init<XkbQueryExtension> (dpy);
3374+
3375 if (xkbEvent.isEnabled ())
3376- {
3377 XkbSelectEvents (dpy, XkbUseCoreKbd,
3378 XkbBellNotifyMask | XkbStateNotifyMask,
3379 XkbAllEventsMask);
3380- }
3381 else
3382- {
3383 compLogMessage ("core", CompLogLevelFatal,
3384 "No XKB extension");
3385- }
3386-
3387- int xineramaError;
3388- int xineramaEvent;
3389+
3390+ int xineramaError, xineramaEvent;
3391+
3392 xineramaExtension = XineramaQueryExtension (dpy,
3393- &xineramaEvent,
3394- &xineramaError);
3395+ &xineramaEvent,
3396+ &xineramaError);
3397
3398 updateScreenInfo ();
3399
3400@@ -4765,9 +4763,8 @@
3401
3402 Window root_tmp = XRootWindow (dpy, DefaultScreen (dpy));
3403
3404-
3405 /* Don't select for SubstructureRedirectMask or
3406- * SubstructureNotifyMask yet since we need to
3407+ * SubstructureNotifyMask yet, since we need to
3408 * act in complete synchronization here when
3409 * doing the initial window init in order to ensure
3410 * that windows don't receive invalid stack positions
3411@@ -4787,11 +4784,11 @@
3412
3413 /* We need to register for EnterWindowMask |
3414 * ButtonPressMask | FocusChangeMask on other
3415- * root windows as well because focus happens
3416+ * root windows as well, because focus happens
3417 * on a display level and we need to check
3418- * if the screen we are running on lost focus */
3419+ * if the screen, we are running on, lost focus */
3420
3421- for (int i = 0; i <= ScreenCount (dpy) - 1; i++)
3422+ for (int i = 0; i <= ScreenCount (dpy) - 1; ++i)
3423 {
3424 Window rt = XRootWindow (dpy, i);
3425
3426@@ -4803,7 +4800,7 @@
3427 SubstructureNotifyMask);
3428 }
3429
3430- for (int i = 0; i < SCREEN_EDGE_NUM; i++)
3431+ for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
3432 {
3433 screenEdge[i].id = None;
3434 screenEdge[i].count = 0;
3435@@ -4816,17 +4813,18 @@
3436 snContext = sn_monitor_context_new (snDisplay, screenNum,
3437 compScreenSnEvent, this, NULL);
3438
3439- if (!XGetWindowAttributes (dpy, rootWindow(), &attrib))
3440+ if (!XGetWindowAttributes (dpy, rootWindow (), &attrib))
3441 return false;
3442
3443 workArea.setWidth (attrib.width);
3444 workArea.setHeight (attrib.height);
3445
3446- XVisualInfo templ;
3447+ XVisualInfo templ;
3448 templ.visualid = XVisualIDFromVisual (attrib.visual);
3449
3450- int nvisinfo;
3451- XVisualInfo* visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
3452+ int nvisinfo;
3453+ XVisualInfo *visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
3454+
3455 if (!nvisinfo)
3456 {
3457 compLogMessage ("core", CompLogLevelFatal,
3458@@ -4835,7 +4833,7 @@
3459 return false;
3460 }
3461
3462- XColor black;
3463+ XColor black;
3464 black.red = black.green = black.blue = 0;
3465
3466 if (!XAllocColor (dpy, colormap, &black))
3467@@ -4847,8 +4845,9 @@
3468 return false;
3469 }
3470
3471- static char data = 0;
3472- Pixmap bitmap = XCreateBitmapFromData (dpy, rootWindow(), &data, 1, 1);
3473+ static char data = 0;
3474+ Pixmap bitmap = XCreateBitmapFromData (dpy, rootWindow (), &data, 1, 1);
3475+
3476 if (!bitmap)
3477 {
3478 compLogMessage ("core", CompLogLevelFatal,
3479@@ -4859,7 +4858,7 @@
3480 }
3481
3482 invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
3483- &black, &black, 0, 0);
3484+ &black, &black, 0, 0);
3485 if (!invisibleCursor)
3486 {
3487 compLogMessage ("core", CompLogLevelFatal,
3488@@ -4960,12 +4959,12 @@
3489 /* Wait for old window manager to go away */
3490 if (currentWmSnOwner != None)
3491 {
3492- do {
3493+ do
3494+ {
3495 XWindowEvent (dpy, currentWmSnOwner, StructureNotifyMask, &event);
3496 } while (event.type != DestroyNotify);
3497 }
3498
3499-
3500 /* Server grab from here, we are creating windows */
3501
3502 XGrabServer (dpy);
3503@@ -4975,13 +4974,13 @@
3504 attrib.override_redirect = 1;
3505 attrib.event_mask = PropertyChangeMask;
3506
3507- eventManager.createGrabWindow(dpy, rootWindow(), &attrib);
3508+ eventManager.createGrabWindow(dpy, rootWindow (), &attrib);
3509
3510- for (int i = 0; i < SCREEN_EDGE_NUM; i++)
3511+ for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
3512 {
3513 long xdndVersion = 3;
3514
3515- screenEdge[i].id = XCreateWindow (dpy, rootWindow(),
3516+ screenEdge[i].id = XCreateWindow (dpy, rootWindow (),
3517 -100, -100, 1, 1, 0,
3518 CopyFromParent, InputOnly,
3519 CopyFromParent,
3520@@ -5006,7 +5005,7 @@
3521
3522 updateScreenEdges ();
3523
3524- eventManager.setSupportingWmCheck (dpy, rootWindow());
3525+ eventManager.setSupportingWmCheck (dpy, rootWindow ());
3526 screen->updateSupportedWmHints ();
3527
3528 XIGetClientPointer (dpy, None, &clientPointerDeviceId);
3529@@ -5021,7 +5020,7 @@
3530
3531 /* We should get DestroyNotify events for any windows that were
3532 * destroyed while initializing windows here now */
3533- XSelectInput (dpy, rootWindow(), attrib.your_event_mask |
3534+ XSelectInput (dpy, rootWindow (), attrib.your_event_mask |
3535 SubstructureRedirectMask | SubstructureNotifyMask);
3536
3537 if (CompScreenImpl::checkForError (dpy))
3538@@ -5038,12 +5037,12 @@
3539 }
3540
3541 wmSnSelectionWindow = newWmSnOwner;
3542- this->wmSnTimestamp = wmSnTimestamp;
3543+ this->wmSnTimestamp = wmSnTimestamp;
3544
3545 Window rootReturn, parentReturn;
3546 Window *children;
3547 unsigned int nchildren;
3548- XQueryTree (dpy, rootWindow(),
3549+ XQueryTree (dpy, rootWindow (),
3550 &rootReturn, &parentReturn,
3551 &children, &nchildren);
3552
3553@@ -5052,7 +5051,7 @@
3554
3555 /* Start initializing windows here */
3556
3557- for (unsigned int i = 0; i < nchildren; i++)
3558+ for (unsigned int i = 0; i < nchildren; ++i)
3559 {
3560 XWindowAttributes attrib;
3561
3562@@ -5073,7 +5072,7 @@
3563 * using list last sent to server
3564 i = 0;
3565 for (CompWindowList::reverse_iterator rit = serverWindows.rbegin ();
3566- rit != serverWindows.rend (); rit++)
3567+ rit != serverWindows.rend (); ++rit)
3568 children[i++] = ROOTPARENT ((*rit));
3569
3570 XRestackWindows (dpy, children, i);
3571@@ -5082,23 +5081,20 @@
3572
3573 windowManager.setWindowActiveness(history);
3574
3575- Window focus;
3576- int revertTo;
3577+ Window focus;
3578+ int revertTo;
3579 XGetInputFocus (dpy, &focus, &revertTo);
3580
3581 /* move input focus to root window so that we get a FocusIn event when
3582 moving it to the default window */
3583- XSetInputFocus (dpy, rootWindow(), RevertToPointerRoot, CurrentTime);
3584+ XSetInputFocus (dpy, rootWindow (), RevertToPointerRoot, CurrentTime);
3585
3586 if (focus == None || focus == PointerRoot)
3587- {
3588 screen->focusDefaultWindow ();
3589- }
3590 else
3591 {
3592- CompWindow *w;
3593+ CompWindow *w = screen->findWindow (focus);
3594
3595- w = screen->findWindow (focus);
3596 if (w)
3597 w->moveInputFocusTo ();
3598 else
3599@@ -5120,6 +5116,7 @@
3600 * screens from option changes */
3601 bool init_succeeded = CompPlugin::screenInitPlugins (screen);
3602 assert (init_succeeded);
3603+
3604 if (!init_succeeded)
3605 return false;
3606
3607@@ -5131,9 +5128,9 @@
3608
3609 setAudibleBell (optionGetAudibleBell ());
3610
3611-
3612+ /* TODO: just query optionGetPingDelay () once */
3613 pingTimer.setTimes (optionGetPingDelay (),
3614- optionGetPingDelay () + 500);
3615+ optionGetPingDelay () + 500);
3616
3617 pingTimer.start ();
3618
3619@@ -5146,8 +5143,8 @@
3620 {
3621 privateScreen.startupSequence.removeAllSequences ();
3622
3623- while (!windowManager.getWindows().empty ())
3624- delete windowManager.getWindows().front ();
3625+ while (!windowManager.getWindows ().empty ())
3626+ delete windowManager.getWindows ().front ();
3627
3628 while (CompPlugin* p = CompPlugin::pop ())
3629 CompPlugin::unload (p);
3630@@ -5159,110 +5156,134 @@
3631 }
3632
3633 cps::GrabManager::GrabManager (CompScreen *screen) :
3634- screen(screen),
3635- currentState(0),
3636+ screen (screen),
3637+ currentState (0),
3638 buttonGrabs (),
3639 keyGrabs ()
3640 {
3641 }
3642
3643-cps::ViewPort::ViewPort() :
3644+cps::ViewPort::ViewPort () :
3645 vp (0, 0),
3646 vpSize (1, 1)
3647 {
3648 }
3649
3650-cps::StartupSequence::StartupSequence() :
3651+cps::StartupSequence::StartupSequence () :
3652 startupSequences (),
3653 startupSequenceTimer ()
3654 {
3655 startupSequenceTimer.setCallback (
3656 boost::bind (&cps::StartupSequence::handleStartupSequenceTimeout, this));
3657+
3658+ /* TODO: Magic number alert */
3659 startupSequenceTimer.setTimes (1000, 1500);
3660 }
3661
3662 PrivateScreen::PrivateScreen (CompScreen *screen, cps::WindowManager& windowManager) :
3663- CoreOptions(false),
3664+ CoreOptions (false),
3665 dpy (NULL),
3666- startupSequence(this),
3667+ xSync (),
3668+ xRandr (),
3669+ xShape (),
3670+ viewPort (),
3671+ startupSequence (this),
3672 eventManager (),
3673+ orphanData (),
3674+ outputDevices (),
3675+ colormap (),
3676+ screenNum (0),
3677 nDesktop (1),
3678 currentDesktop (0),
3679+ fullscreenOutput (),
3680+ screenEdge (),
3681 wmSnSelectionWindow (None),
3682 clientPointerDeviceId (None),
3683 normalCursor (None),
3684 busyCursor (None),
3685 invisibleCursor (None),
3686+ workArea (),
3687 initialized (false),
3688- screen(screen),
3689+ screen (screen),
3690+ xkbEvent (),
3691+ xineramaExtension (false),
3692 screenInfo (),
3693- snDisplay(0),
3694- root(None),
3695+ snDisplay (0),
3696+ displayString_ (),
3697+ escapeKeyCode (),
3698+ returnKeyCode (),
3699+ region (),
3700+ root (None),
3701+ attrib (),
3702 snContext (0),
3703 wmSnAtom (None),
3704+ wmSnTimestamp (0),
3705 desktopHintData (0),
3706 desktopHintSize (0),
3707 edgeWindow (None),
3708+ pingTimer (),
3709 edgeDelayTimer (),
3710+ edgeDelaySettings (),
3711 xdndWindow (None),
3712- windowManager(windowManager)
3713+ pluginManager (),
3714+ windowManager (windowManager)
3715 {
3716- for (int i = 0; i < SCREEN_EDGE_NUM; i++)
3717+ for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
3718 {
3719 screenEdge[i].id = None;
3720 screenEdge[i].count = 0;
3721 }
3722-
3723 }
3724
3725-cps::History::History() :
3726+cps::History::History () :
3727 currentHistory_(0),
3728 activeNum_ (1)
3729 {
3730 memset (history, 0, sizeof history);
3731 }
3732
3733-cps::WindowManager::WindowManager() :
3734+cps::WindowManager::WindowManager () :
3735 windows (),
3736 serverWindows (),
3737 destroyedWindows (),
3738 stackIsFresh (false),
3739 groups (0),
3740 pendingDestroys (0),
3741- lastFoundWindow(0)
3742+ lastFoundWindow (0)
3743 {
3744 }
3745
3746-cps::PluginManager::PluginManager() :
3747+cps::PluginManager::PluginManager () :
3748 plugin (),
3749 dirtyPluginList (true)
3750 {
3751 }
3752
3753 cps::EventManager::EventManager () :
3754- possibleTap(NULL),
3755- source(0),
3756- timeout(0),
3757- sighupSource(0),
3758- sigtermSource(0),
3759- sigintSource(0),
3760+ possibleTap (NULL),
3761+ source (0),
3762+ timeout (0),
3763+ sighupSource (0),
3764+ sigtermSource (0),
3765+ sigintSource (0),
3766 fileWatch (0),
3767 lastFileWatchHandle (1),
3768 watchFds (0),
3769 lastWatchFdHandle (1),
3770+ grabbed (false),
3771 grabWindow (None)
3772 {
3773 TimeoutHandler *dTimeoutHandler = new TimeoutHandler ();
3774 TimeoutHandler::SetDefault (dTimeoutHandler);
3775 }
3776
3777-cps::OrphanData::OrphanData() :
3778+cps::OrphanData::OrphanData () :
3779 activeWindow (0),
3780 nextActiveWindow(0)
3781 {
3782 }
3783
3784-cps::OrphanData::~OrphanData()
3785+cps::OrphanData::~OrphanData ()
3786 {
3787 }
3788
3789@@ -5275,16 +5296,15 @@
3790 * See LP: #1085590 */
3791 g_source_destroy (timeout->gobj ());
3792 }
3793+
3794 delete sigintSource;
3795 delete sigtermSource;
3796 delete sighupSource;
3797
3798 /* Not guaranteed to be created by EventManager's constructor */
3799 if (source)
3800- {
3801 /* This will implicitly call ~CompEventSource */
3802 g_source_destroy (source->gobj ());
3803- }
3804
3805 /* This will implicitly call ~CompWatchFd */
3806 foreach (CompWatchFd *fd, watchFds)
3807@@ -5302,11 +5322,12 @@
3808
3809 if (dpy != NULL)
3810 {
3811- XUngrabKey (dpy, AnyKey, AnyModifier, rootWindow());
3812+ XUngrabKey (dpy, AnyKey, AnyModifier, rootWindow ());
3813
3814- for (int i = 0; i < SCREEN_EDGE_NUM; i++)
3815+ for (int i = 0; i < SCREEN_EDGE_NUM; ++i)
3816 {
3817 Window id = screenEdge[i].id;
3818+
3819 if (id != None)
3820 XDestroyWindow (dpy, id);
3821 }
3822@@ -5340,7 +5361,7 @@
3823 * windows
3824 */
3825
3826- XSync (dpy, False); // Redundant?
3827+ XSync (dpy, False); // TODO: Redundant?
3828 XCloseDisplay (dpy);
3829 }
3830

Subscribers

People subscribed via source and target branches

to all changes: