Merge lp:~thomas-voss/compiz-core/fix-globals into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Rejected
Rejected by: Alan Griffiths
Proposed branch: lp:~thomas-voss/compiz-core/fix-globals
Merge into: lp:compiz-core/0.9.5
Prerequisite: lp:~thomas-voss/compiz-core/fix-option
Diff against target: 1615 lines (+490/-223)
25 files modified
include/core/global.h (+329/-8)
include/core/screen.h (+2/-1)
plugins/annotate/src/annotate.cpp (+12/-12)
plugins/clone/src/clone.cpp (+2/-2)
plugins/composite/src/screen.cpp (+2/-2)
plugins/move/src/move.cpp (+11/-11)
plugins/opengl/src/screen.cpp (+4/-4)
plugins/resize/src/resize.cpp (+19/-19)
plugins/rotate/src/rotate.cpp (+19/-19)
plugins/scale/src/scale.cpp (+3/-3)
plugins/screenshot/src/screenshot.cpp (+4/-4)
plugins/switcher/src/switcher.cpp (+2/-1)
plugins/water/src/water.cpp (+4/-4)
plugins/wobbly/src/wobbly.cpp (+4/-4)
plugins/zoom/src/zoom.cpp (+12/-12)
src/event.cpp (+12/-12)
src/eventsource.cpp (+1/-1)
src/logmessage/src/logmessage.cpp (+2/-2)
src/main.cpp (+20/-39)
src/privatescreen.h (+0/-14)
src/screen.cpp (+18/-15)
src/session.cpp (+5/-5)
src/tests/globals.h (+0/-24)
src/tests/option.cpp (+0/-2)
src/window.cpp (+3/-3)
To merge this branch: bzr merge lp:~thomas-voss/compiz-core/fix-globals
Reviewer Review Type Date Requested Status
Alan Griffiths Abstain
Review via email: mp+88983@code.launchpad.net

This proposal supersedes a proposal from 2012-01-17.

Description of the change

Got rid of public externals and replaced them with a singleton.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

Global variables are not good. But neither are singletons (for all the same reasons).

There seems to be no attempt to, for example, group related variables - so what problem does this solve?

AFAICS this increases coupling as anything that depended on the declaration of any one global variable now depends on the singleton.

The correct pattern to replace globals is "parameterise from above" not singleton.

(Also, this diff seems to have got mixed with the "variant" change.)

review: Disapprove
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal
Download full text (4.0 KiB)

58 + char * programName () const
59 + {
60 + return mProgramName;
61 + }
62 +
63 + void setProgramName (char * programName)
64 + {
65 + mProgramName = programName;
66 + }
67 +
68 + char** programArgv () const
69 + {
70 + return mProgramArgv;
71 + }
72 +
73 + void setProgramArgv (char ** argv)
74 + {
75 + mProgramArgv = argv;
76 + }

These are constant, so you only need getters for them and then they can be constructed in the constructor

88 + char * backgroundImage () const
89 + {
90 + return mBackgroundImage;
91 + }
92 +
93 + void setBackgroundImage (char * bgImage)
94 + {
95 + mBackgroundImage = bgImage;
96 + }

This command lind switch is redundant, so just remove it. I think the opengl plugin uses it but honestly who actually uses compiz and sets the background image manuallly. We already have the wallpaper plugin

48 + bool isDebugOutput () const
49 + {
50 + return mDebugOutput;
51 + }
52 +
53 + void setDebugOutput (bool isDebugOutput)
54 + {
55 + mDebugOutput = isDebugOutput;
56 + }

Something to consider later - we need to get a proper logging object in place, and then the level would be passed to the log object's constructor rather than conditionalizing on "debugOutput"

98 + bool replaceCurrentWm () const
99 + {
100 + return mReplaceCurrentWm;
101 + }
102 +
103 + void setReplaceCurrentWm (bool doReplace)
104 + {
105 + mReplaceCurrentWm = doReplace;
106 + }

I don't think there are any cases where the plugins need this tbh.

108 + bool indirectRendering () const
109 + {
110 + return mIndirectRendering;
111 + }
112 +
113 + void setIndirectRendering (bool isIndirectRendering)
114 + {
115 + mIndirectRendering = isIndirectRendering;
116 + }

Obsolete. Remove, also remove the related parts in the OpenGL plugin (but keep the fallback that detects for a direct context failing to be created)

148 + int lastPointerX () const
149 + {
150 + return mLastPointerX;
151 + }
152 +
153 + void setLastPointerX (int x)
154 + {
155 + mLastPointerX = x;
156 + }
157 +
158 + int lastPointerY () const
159 + {
160 + return mLastPointerY;
161 + }
162 +
163 + void setLastPointerY (int y)
164 + {
165 + mLastPointerY = y;
166 + }

168 + unsigned int lastPointerMods () const
169 + {
170 + return mLastPointerMods;
171 + }
172 +
173 + void setLastPointerMods (unsigned int mods)
174 + {
175 + mLastPointerMods = mods;
176 + }

In the future this needs to be a CompPoint, and ideally, removed alltogether

138 + ModifierHandler * modHandler () const
139 + {
140 + return mModHandler;
141 + }
142 +
143 + void setModHandler (ModifierHandler * handler)
144 + {
145 + mModHandler = handler;
146 + }

This is a singleton on its own, so feel free to make it one. There is only one plugin which depends on it

233 + CompWindow *lastFoundWindow () const
234 + {
235 + return mLastFoundWindow;
236 + }

This can be a local static variable in screen.cpp

208 + bool shutDown () const
209 + {
210 + return mShutDown;
211 + }
212 +
213 + void setShutDown (bool isShutDown)
214 + {
215 + mShutDown = isShutDown;
216 + }

I am 99% sure the only thing that uses this is the CompEventSource. It may not even be necessary now that we have a proper shutdown handler.

243 + void setInHandleEvent (bool i...

Read more...

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Oh, and targetOutput is only used by the opengl plugin, so it can be moved there or removed alltogether.

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

Re Sam's comments: A good alternative to static members (which are visible to all translation units including the header) to is to put variable in an anonymous namespace in the .cpp file.

I still think a singleton makes things worse.

review: Abstain

Unmerged revisions

2921. By Thomas Voß

Removed all public externals and put them in a class CompGlobal.

2913. By Daniel van Vugt

Fixes focus being on the wrong window after viewport changes (LP: #896762)
Merged from lp:~smspillaz/compiz-core/fix_896762

2912. By Daniel van Vugt

Test harness for wrapsystem and some code initial cleanup.
Merged from lp:~alan-griffiths/compiz-core/wrapsystem

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/core/global.h'
2--- include/core/global.h 2011-12-19 07:06:22 +0000
3+++ include/core/global.h 2012-01-18 06:49:24 +0000
4@@ -25,13 +25,334 @@
5 #ifndef _COMPIZ_GLOBAL_H
6 #define _COMPIZ_GLOBAL_H
7
8-/**
9-* Flag indicating whether to produce debug output
10-*/
11-extern bool debugOutput;
12-
13-extern char *programName;
14-extern char **programArgv;
15-extern int programArgc;
16+#include <list>
17+
18+#include "core/string.h"
19+
20+class CompOutput;
21+class CompScreen;
22+class CompWindow;
23+class ModifierHandler;
24+
25+class CompGlobal
26+{
27+public:
28+
29+ static CompGlobal & instance ()
30+ {
31+ static CompGlobal inst;
32+ return inst;
33+ }
34+
35+ bool isDebugOutput () const
36+ {
37+ return mDebugOutput;
38+ }
39+
40+ void setDebugOutput (bool isDebugOutput)
41+ {
42+ mDebugOutput = isDebugOutput;
43+ }
44+
45+ char * programName () const
46+ {
47+ return mProgramName;
48+ }
49+
50+ void setProgramName (char * programName)
51+ {
52+ mProgramName = programName;
53+ }
54+
55+ char** programArgv () const
56+ {
57+ return mProgramArgv;
58+ }
59+
60+ void setProgramArgv (char ** argv)
61+ {
62+ mProgramArgv = argv;
63+ }
64+
65+ int programArgc () const
66+ {
67+ return mProgramArgc;
68+ }
69+
70+ void setProgramArgc (int argc)
71+ {
72+ mProgramArgc = argc;
73+ }
74+
75+ char * backgroundImage () const
76+ {
77+ return mBackgroundImage;
78+ }
79+
80+ void setBackgroundImage (char * bgImage)
81+ {
82+ mBackgroundImage = bgImage;
83+ }
84+
85+ bool replaceCurrentWm () const
86+ {
87+ return mReplaceCurrentWm;
88+ }
89+
90+ void setReplaceCurrentWm (bool doReplace)
91+ {
92+ mReplaceCurrentWm = doReplace;
93+ }
94+
95+ bool indirectRendering () const
96+ {
97+ return mIndirectRendering;
98+ }
99+
100+ void setIndirectRendering (bool isIndirectRendering)
101+ {
102+ mIndirectRendering = isIndirectRendering;
103+ }
104+
105+ bool noDetection () const
106+ {
107+ return mNoDetection;
108+ }
109+
110+ void setNoDetection (bool noDetection)
111+ {
112+ mNoDetection = noDetection;
113+ }
114+
115+ CompScreen * screen () const
116+ {
117+ return mScreen;
118+ }
119+
120+ void setScreen (CompScreen * screen)
121+ {
122+ mScreen = screen;
123+ }
124+
125+ ModifierHandler * modHandler () const
126+ {
127+ return mModHandler;
128+ }
129+
130+ void setModHandler (ModifierHandler * handler)
131+ {
132+ mModHandler = handler;
133+ }
134+
135+ int lastPointerX () const
136+ {
137+ return mLastPointerX;
138+ }
139+
140+ void setLastPointerX (int x)
141+ {
142+ mLastPointerX = x;
143+ }
144+
145+ int lastPointerY () const
146+ {
147+ return mLastPointerY;
148+ }
149+
150+ void setLastPointerY (int y)
151+ {
152+ mLastPointerY = y;
153+ }
154+
155+ unsigned int lastPointerMods () const
156+ {
157+ return mLastPointerMods;
158+ }
159+
160+ void setLastPointerMods (unsigned int mods)
161+ {
162+ mLastPointerMods = mods;
163+ }
164+
165+ int pointerX () const
166+ {
167+ return mPointerX;
168+ }
169+
170+ void setPointerX (int x)
171+ {
172+ mPointerX = x;
173+ }
174+
175+ int pointerY () const
176+ {
177+ return mPointerY;
178+ }
179+
180+ void setPointerY (int y)
181+ {
182+ mPointerY = y;
183+ }
184+
185+ unsigned int pointerMods () const
186+ {
187+ return mPointerMods;
188+ }
189+
190+ void setPointerMods (unsigned int mods)
191+ {
192+ mPointerMods = mods;
193+ }
194+
195+ bool shutDown () const
196+ {
197+ return mShutDown;
198+ }
199+
200+ void setShutDown (bool isShutDown)
201+ {
202+ mShutDown = isShutDown;
203+ }
204+
205+ bool inHandleEvent () const
206+ {
207+ return mInHandleEvent;
208+ }
209+
210+ std::list<CompString> & initialPlugins ()
211+ {
212+ return mInitialPlugins;
213+ }
214+
215+ const std::list<CompString> & initialPlugins () const
216+ {
217+ return mInitialPlugins;
218+ }
219+
220+ CompWindow *lastFoundWindow () const
221+ {
222+ return mLastFoundWindow;
223+ }
224+
225+ bool restartSignal () const
226+ {
227+ return mRestartSignal;
228+ }
229+
230+ void setInHandleEvent (bool inHandleEvent)
231+ {
232+ mInHandleEvent = inHandleEvent;
233+ }
234+
235+ void setInitialPlugins (const std::list<CompString> & initialPlugins)
236+ {
237+ mInitialPlugins = initialPlugins;
238+ }
239+
240+ void setLastFoundWindow (CompWindow *lastFoundWindow)
241+ {
242+ mLastFoundWindow = lastFoundWindow;
243+ }
244+
245+ void setRestartSignal (bool restartSignal)
246+ {
247+ mRestartSignal = restartSignal;
248+ }
249+
250+ void setTargetOutput (CompOutput *targetOutput)
251+ {
252+ mTargetOutput = targetOutput;
253+ }
254+
255+ void setTargetScreen (CompScreen *targetScreen)
256+ {
257+ mTargetScreen = targetScreen;
258+ }
259+
260+ void setUseDesktopHints (bool useDesktopHints)
261+ {
262+ mUseDesktopHints = useDesktopHints;
263+ }
264+
265+ CompOutput *targetOutput () const
266+ {
267+ return mTargetOutput;
268+ }
269+
270+ CompScreen *targetScreen () const
271+ {
272+ return mTargetScreen;
273+ }
274+
275+ bool useDesktopHints () const
276+ {
277+ return mUseDesktopHints;
278+ }
279+private:
280+ CompGlobal () :
281+ mDebugOutput(false),
282+ mProgramName(0),
283+ mProgramArgv(0),
284+ mProgramArgc(0),
285+ mBackgroundImage(0),
286+ mReplaceCurrentWm(false),
287+ mIndirectRendering(false),
288+ mNoDetection(false),
289+ mScreen(0),
290+ mModHandler(0),
291+ mLastPointerX(0),
292+ mLastPointerY(0),
293+ mLastPointerMods(0),
294+ mPointerX(0),
295+ mPointerY(0),
296+ mPointerMods(0),
297+ mShutDown(false),
298+ mRestartSignal(false),
299+ mLastFoundWindow(0),
300+ mUseDesktopHints(false),
301+ mInHandleEvent(false),
302+ mTargetScreen(0),
303+ mTargetOutput(0)
304+ {
305+ }
306+
307+ CompGlobal (const CompGlobal & rhs);
308+ CompGlobal & operator= (const CompGlobal & rhs);
309+ bool operator== (const CompGlobal & rhs) const;
310+
311+ bool mDebugOutput;
312+
313+ char *mProgramName;
314+ char **mProgramArgv;
315+ int mProgramArgc;
316+
317+ char * mBackgroundImage;
318+ bool mReplaceCurrentWm;
319+ bool mIndirectRendering;
320+ bool mNoDetection;
321+
322+ CompScreen * mScreen;
323+ ModifierHandler * mModHandler;
324+
325+ int mLastPointerX;
326+ int mLastPointerY;
327+ unsigned int mLastPointerMods;
328+ int mPointerX;
329+ int mPointerY;
330+ unsigned int mPointerMods;
331+
332+ bool mShutDown;
333+ bool mRestartSignal;
334+
335+ CompWindow *mLastFoundWindow;
336+ bool mUseDesktopHints;
337+
338+ bool mInHandleEvent;
339+
340+ CompScreen * mTargetScreen;
341+ CompOutput * mTargetOutput;
342+
343+ std::list<CompString> mInitialPlugins;
344+};
345
346 #endif // _COMPIZ_GLOBAL_H
347
348=== modified file 'include/core/screen.h'
349--- include/core/screen.h 2011-09-19 12:54:22 +0000
350+++ include/core/screen.h 2012-01-18 06:49:24 +0000
351@@ -45,6 +45,7 @@
352 typedef std::list<CompWindow *> CompWindowList;
353 typedef std::vector<CompWindow *> CompWindowVector;
354
355+/*
356 extern char *backgroundImage;
357 extern bool replaceCurrentWm;
358 extern bool indirectRendering;
359@@ -60,7 +61,7 @@
360 extern int pointerX;
361 extern int pointerY;
362 extern unsigned int pointerMods;
363-
364+*/
365 #define NOTIFY_CREATE_MASK (1 << 0)
366 #define NOTIFY_DELETE_MASK (1 << 1)
367 #define NOTIFY_MOVE_MASK (1 << 2)
368
369=== modified file 'plugins/annotate/src/annotate.cpp'
370--- plugins/annotate/src/annotate.cpp 2010-07-02 03:00:14 +0000
371+++ plugins/annotate/src/annotate.cpp 2012-01-18 06:49:24 +0000
372@@ -468,8 +468,8 @@
373 if (state & CompAction::StateInitKey)
374 action->setState (action->state () | CompAction::StateTermKey);
375
376- annoLastPointerX = pointerX;
377- annoLastPointerY = pointerY;
378+ annoLastPointerX = CompGlobal::instance ().pointerX ();
379+ annoLastPointerY = CompGlobal::instance ().pointerY ();
380
381 drawMode = EraseMode;
382
383@@ -495,8 +495,8 @@
384 if (state & CompAction::StateInitKey)
385 action->setState (action->state () | CompAction::StateTermKey);
386
387- annoLastPointerX = pointerX;
388- annoLastPointerY = pointerY;
389+ annoLastPointerX = CompGlobal::instance ().pointerX ();
390+ annoLastPointerY = CompGlobal::instance ().pointerY ();
391
392 drawMode = FreeDrawMode;
393
394@@ -522,8 +522,8 @@
395 if (state & CompAction::StateInitKey)
396 action->setState (action->state () | CompAction::StateTermKey);
397
398- initialPointerX = pointerX;
399- initialPointerY = pointerY;
400+ initialPointerX = CompGlobal::instance ().pointerX ();
401+ initialPointerY = CompGlobal::instance ().pointerY ();
402
403 drawMode = LineMode;
404
405@@ -551,8 +551,8 @@
406
407 drawMode = RectangleMode;
408
409- initialPointerX = pointerX;
410- initialPointerY = pointerY;
411+ initialPointerX = CompGlobal::instance ().pointerX ();
412+ initialPointerY = CompGlobal::instance ().pointerY ();
413 rectangle.setGeometry (initialPointerX, initialPointerY, 0, 0);
414 lastRect = rectangle;
415
416@@ -580,8 +580,8 @@
417
418 drawMode = EllipseMode;
419
420- initialPointerX = pointerX;
421- initialPointerY = pointerY;
422+ initialPointerX = CompGlobal::instance ().pointerX ();
423+ initialPointerY = CompGlobal::instance ().pointerY ();
424 ellipse.radiusX = 0;
425 ellipse.radiusY = 0;
426 lastRect.setGeometry (initialPointerX, initialPointerY, 0, 0);
427@@ -884,10 +884,10 @@
428 {
429 switch (event->type) {
430 case MotionNotify:
431- handleMotionEvent (pointerX, pointerY);
432+ handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
433 case EnterNotify:
434 case LeaveNotify:
435- handleMotionEvent (pointerX, pointerY);
436+ handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
437 default:
438 if (event->type == cScreen->damageEvent () + XDamageNotify)
439 {
440
441=== modified file 'plugins/clone/src/clone.cpp'
442--- plugins/clone/src/clone.cpp 2010-02-04 17:16:02 +0000
443+++ plugins/clone/src/clone.cpp 2012-01-18 06:49:24 +0000
444@@ -496,14 +496,14 @@
445 {
446 case MotionNotify:
447 {
448- CompPoint p (pointerX, pointerY);
449+ CompPoint p (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
450 handleMotionEvent (p);
451 }
452 break;
453 case EnterNotify:
454 case LeaveNotify:
455 {
456- CompPoint p (pointerX, pointerY);
457+ CompPoint p (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
458 handleMotionEvent (p);
459 }
460 default:
461
462=== modified file 'plugins/composite/src/screen.cpp'
463--- plugins/composite/src/screen.cpp 2012-01-12 17:49:40 +0000
464+++ plugins/composite/src/screen.cpp 2012-01-18 06:49:24 +0000
465@@ -322,7 +322,7 @@
466
467 if (currentCmSnOwner != None)
468 {
469- if (!replaceCurrentWm)
470+ if (!CompGlobal::instance ().replaceCurrentWm ())
471 {
472 compLogMessage ("composite", CompLogLevelError,
473 "Screen %d on display \"%s\" already "
474@@ -648,7 +648,7 @@
475 void
476 PrivateCompositeScreen::detectRefreshRate ()
477 {
478- if (!noDetection &&
479+ if (!CompGlobal::instance ().noDetection () &&
480 optionGetDetectRefreshRate ())
481 {
482 CompString name;
483
484=== modified file 'plugins/move/src/move.cpp'
485--- plugins/move/src/move.cpp 2012-01-09 16:01:47 +0000
486+++ plugins/move/src/move.cpp 2012-01-18 06:49:24 +0000
487@@ -96,8 +96,8 @@
488 ms->x = 0;
489 ms->y = 0;
490
491- lastPointerX = x;
492- lastPointerY = y;
493+ CompGlobal::instance ().setLastPointerX (x);
494+ CompGlobal::instance ().setLastPointerY (y);
495
496 sourceExternalApp =
497 CompOption::getBoolOptionNamed (options, "external", false);
498@@ -141,7 +141,7 @@
499 xRoot = w->geometry ().x () + (w->size ().width () / 2);
500 yRoot = w->geometry ().y () + (w->size ().height () / 2);
501
502- s->warpPointer (xRoot - pointerX, yRoot - pointerY);
503+ s->warpPointer (xRoot - CompGlobal::instance ().pointerX (), yRoot - CompGlobal::instance ().pointerY ());
504 }
505
506 if (ms->moveOpacity != OPAQUE)
507@@ -321,8 +321,8 @@
508 wHeight = w->geometry ().height () +
509 w->geometry ().border () * 2;
510
511- ms->x += xRoot - lastPointerX;
512- ms->y += yRoot - lastPointerY;
513+ ms->x += xRoot - CompGlobal::instance ().lastPointerX ();
514+ ms->y += yRoot - CompGlobal::instance ().lastPointerY ();
515
516 if (w->type () & CompWindowTypeFullscreenMask)
517 {
518@@ -444,7 +444,7 @@
519 wy = workArea.y () + (w->border ().top >> 1);
520 wy += w->sizeHints ().height_inc >> 1;
521
522- s->warpPointer (0, wy - pointerY);
523+ s->warpPointer (0, wy - CompGlobal::instance ().pointerY ());
524
525 return;
526 }
527@@ -577,12 +577,12 @@
528 break;
529 case MotionNotify:
530 if (event->xmotion.root == screen->root ())
531- moveHandleMotionEvent (screen, pointerX, pointerY);
532+ moveHandleMotionEvent (screen, CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
533 break;
534 case EnterNotify:
535 case LeaveNotify:
536 if (event->xcrossing.root == screen->root ())
537- moveHandleMotionEvent (screen, pointerX, pointerY);
538+ moveHandleMotionEvent (screen, CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
539 break;
540 case ClientMessage:
541 if (event->xclient.message_type == Atoms::wmMoveResize)
542@@ -616,10 +616,10 @@
543 {
544
545 /* TODO: not only button 1 */
546- if (pointerMods & Button1Mask)
547+ if (CompGlobal::instance ().pointerMods () & Button1Mask)
548 {
549 o.push_back (CompOption ("modifiers", CompOption::TypeInt));
550- o[2].value ().set ((int) pointerMods);
551+ o[2].value ().set ((int) CompGlobal::instance ().pointerMods ());
552
553 o.push_back (CompOption ("x", CompOption::TypeInt));
554 o[3].value ().set ((int) event->xclient.data.l[0]);
555@@ -634,7 +634,7 @@
556 moveInitiate (&optionGetInitiateButton (),
557 CompAction::StateInitButton, o);
558
559- moveHandleMotionEvent (screen, pointerX, pointerY);
560+ moveHandleMotionEvent (screen, CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
561 }
562 }
563 }
564
565=== modified file 'plugins/opengl/src/screen.cpp'
566--- plugins/opengl/src/screen.cpp 2012-01-09 15:12:20 +0000
567+++ plugins/opengl/src/screen.cpp 2012-01-18 06:49:24 +0000
568@@ -94,7 +94,7 @@
569 const char *glRenderer;
570 CompOption::Vector o (0);
571
572- priv->ctx = glXCreateContext (dpy, visinfo, NULL, !indirectRendering);
573+ priv->ctx = glXCreateContext (dpy, visinfo, NULL, !CompGlobal::instance ().indirectRendering ());
574 if (!priv->ctx)
575 {
576 compLogMessage ("opengl", CompLogLevelFatal,
577@@ -298,7 +298,7 @@
578 XWindowAttributes attr;
579 CompOption::Vector o (0);
580
581- if (indirectRendering)
582+ if (CompGlobal::instance ().indirectRendering ())
583 {
584 /* force Mesa libGL into indirect rendering mode, because
585 glXQueryExtensionsString is context-independant */
586@@ -849,9 +849,9 @@
587 if (backgroundTextures.empty ())
588 {
589 CompSize size;
590- if (backgroundImage)
591+ if (CompGlobal::instance ().backgroundImage ())
592 {
593- CompString fileName (backgroundImage);
594+ CompString fileName (CompGlobal::instance ().backgroundImage ());
595 CompString pname ("");
596
597 backgroundTextures = GLTexture::readImageToTexture (fileName, pname, size);
598
599=== modified file 'plugins/resize/src/resize.cpp'
600--- plugins/resize/src/resize.cpp 2011-08-19 14:25:11 +0000
601+++ plugins/resize/src/resize.cpp 2012-01-18 06:49:24 +0000
602@@ -321,8 +321,8 @@
603
604 CompWindow::Geometry server = w->serverGeometry ();
605
606- x = CompOption::getIntOptionNamed (options, "x", pointerX);
607- y = CompOption::getIntOptionNamed (options, "y", pointerY);
608+ x = CompOption::getIntOptionNamed (options, "x", CompGlobal::instance ().pointerX ());
609+ y = CompOption::getIntOptionNamed (options, "y", CompGlobal::instance ().pointerY ());
610
611 button = CompOption::getIntOptionNamed (options, "button", -1);
612
613@@ -391,8 +391,8 @@
614
615 rs->geometry = rs->savedGeometry;
616
617- rs->pointerDx = x - pointerX;
618- rs->pointerDy = y - pointerY;
619+ rs->pointerDx = x - CompGlobal::instance ().pointerX ();
620+ rs->pointerDy = y - CompGlobal::instance ().pointerY ();
621
622 rs->centered |= rs->optionGetResizeFromCenterMatch ().evaluate (w);
623
624@@ -469,7 +469,7 @@
625 xRoot = server.x () + (server.width () / 2);
626 yRoot = server.y () + (server.height () / 2);
627
628- screen->warpPointer (xRoot - pointerX, yRoot - pointerY);
629+ screen->warpPointer (xRoot - CompGlobal::instance ().pointerX (), yRoot - CompGlobal::instance ().pointerY ());
630 }
631
632 rs->isConstrained = sourceExternalApp;
633@@ -726,7 +726,7 @@
634 x = left + width * (rKeys[i].dx + 1) / 2;
635 y = top + height * (rKeys[i].dy + 1) / 2;
636
637- screen->warpPointer (x - pointerX, y - pointerY);
638+ screen->warpPointer (x - CompGlobal::instance ().pointerX (), y - CompGlobal::instance ().pointerY ());
639
640 mask = rKeys[i].resizeMask;
641
642@@ -830,13 +830,13 @@
643
644 if (centered || optionGetResizeFromCenter ())
645 {
646- pointerDx += (xRoot - lastPointerX) * 2;
647- pointerDy += (yRoot - lastPointerY) * 2;
648+ pointerDx += (xRoot - CompGlobal::instance ().lastPointerX ()) * 2;
649+ pointerDy += (yRoot - CompGlobal::instance ().lastPointerY ()) * 2;
650 }
651 else
652 {
653- pointerDx += xRoot - lastPointerX;
654- pointerDy += yRoot - lastPointerY;
655+ pointerDx += xRoot - CompGlobal::instance ().lastPointerX ();
656+ pointerDy += yRoot - CompGlobal::instance ().lastPointerY ();
657 }
658
659 /* If we hit the edge of the screen while resizing
660@@ -852,25 +852,25 @@
661 {
662 if (xRoot == 0 &&
663 geometry.x - w->border ().left > grabWindowWorkArea->left ())
664- pointerDx += abs (yRoot - lastPointerY) * -1;
665+ pointerDx += abs (yRoot - CompGlobal::instance ().lastPointerY ()) * -1;
666 }
667 else if (mask == ResizeRightMask)
668 {
669 if (xRoot == screen->width () -1 &&
670 geometry.x + geometry.width + w->border ().right < grabWindowWorkArea->right ())
671- pointerDx += abs (yRoot - lastPointerY);
672+ pointerDx += abs (yRoot - CompGlobal::instance ().lastPointerY ());
673 }
674 if (mask == ResizeUpMask)
675 {
676 if (yRoot == 0 &&
677 geometry.y - w->border ().top > grabWindowWorkArea->top ())
678- pointerDy += abs (xRoot - lastPointerX) * -1;
679+ pointerDy += abs (xRoot - CompGlobal::instance ().lastPointerX ()) * -1;
680 }
681 else if (mask == ResizeDownMask)
682 {
683 if (yRoot == screen->height () -1 &&
684 geometry.y + geometry.height + w->border ().bottom < grabWindowWorkArea->bottom ())
685- pointerDx += abs (yRoot - lastPointerY);
686+ pointerDx += abs (yRoot - CompGlobal::instance ().lastPointerY ());
687 }
688 }
689 }
690@@ -1268,12 +1268,12 @@
691 break;
692 case MotionNotify:
693 if (event->xmotion.root == screen->root ())
694- handleMotionEvent (pointerX, pointerY);
695+ handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
696 break;
697 case EnterNotify:
698 case LeaveNotify:
699 if (event->xcrossing.root == screen->root ())
700- handleMotionEvent (pointerX, pointerY);
701+ handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
702 break;
703 case ClientMessage:
704 if (event->xclient.message_type == Atoms::wmMoveResize)
705@@ -1319,7 +1319,7 @@
706 };
707
708 /* TODO: not only button 1 */
709- if (pointerMods & Button1Mask)
710+ if (CompGlobal::instance ().pointerMods () & Button1Mask)
711 {
712 o.push_back (CompOption ("modifiers",
713 CompOption::TypeInt));
714@@ -1332,7 +1332,7 @@
715 o.push_back (CompOption ("button",
716 CompOption::TypeInt));
717
718- o[2].value ().set ((int) pointerMods);
719+ o[2].value ().set ((int) CompGlobal::instance ().pointerMods ());
720 o[3].value ().set
721 ((int) event->xclient.data.l[0]);
722 o[4].value ().set
723@@ -1348,7 +1348,7 @@
724 CompAction::StateInitButton, o);
725
726 ResizeScreen::get (screen)->
727- handleMotionEvent (pointerX, pointerY);
728+ handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
729 }
730 }
731 }
732
733=== modified file 'plugins/rotate/src/rotate.cpp'
734--- plugins/rotate/src/rotate.cpp 2010-12-23 03:57:46 +0000
735+++ plugins/rotate/src/rotate.cpp 2012-01-18 06:49:24 +0000
736@@ -606,12 +606,12 @@
737 if (screen->otherGrabExist ("rotate", "move", "group-drag", NULL))
738 return false;
739
740- warpX = pointerX - (screen->width () * direction);
741+ warpX = CompGlobal::instance ().pointerX () - (screen->width () * direction);
742 if (direction == -1)
743 screen->warpPointer (screen->width () - 10, 0);
744 else
745 screen->warpPointer (10 - screen->width (), 0);
746- lastPointerX = warpX;
747+ CompGlobal::instance ().setLastPointerX (warpX);
748
749 o.push_back (CompOption ("root", CompOption::TypeInt));
750 o.push_back (CompOption ("x", CompOption::TypeInt));
751@@ -619,12 +619,12 @@
752
753 o[0].value ().set ((int) screen->root ());
754 o[1].value ().set (0);
755- o[2].value ().set (pointerY);
756+ o[2].value ().set (CompGlobal::instance ().pointerY ());
757
758 rotate (NULL, 0, o, direction);
759
760 XWarpPointer (screen->dpy (), None, None, 0, 0, 0, 0, direction, 0);
761- mSavedPointer.setX (lastPointerX + (9 * direction));
762+ mSavedPointer.setX (CompGlobal::instance ().lastPointerX () + (9 * direction));
763
764 return false;
765 }
766@@ -690,28 +690,28 @@
767
768 if (optionGetFlipTime () == 0 || (mMoving && !mSlow))
769 {
770- int pointerDx = pointerX - lastPointerX;
771+ int pointerDx = CompGlobal::instance ().pointerX () - CompGlobal::instance ().lastPointerX ();
772 int warpX;
773
774 if (direction == -1)
775 {
776- warpX = pointerX + screen->width ();
777+ warpX = CompGlobal::instance ().pointerX () + screen->width ();
778 screen->warpPointer (screen->width () - 10, 0);
779- lastPointerX = warpX - pointerDx;
780+ CompGlobal::instance ().setLastPointerX (warpX - pointerDx);
781 rotate (NULL, 0, o, direction);
782
783 XWarpPointer (screen->dpy (), None, None, 0, 0, 0, 0, -1, 0);
784- mSavedPointer.setX (lastPointerX - 9);
785+ mSavedPointer.setX (CompGlobal::instance ().lastPointerX () - 9);
786 }
787 else
788 {
789- warpX = pointerX - screen->width ();
790+ warpX = CompGlobal::instance ().pointerX () - screen->width ();
791 screen->warpPointer (10 - screen->width (), 0);
792- lastPointerX = warpX - pointerDx;
793+ CompGlobal::instance ().setLastPointerX (warpX - pointerDx);
794 rotate (NULL, 0, o, direction);
795
796 XWarpPointer (screen->dpy (), None, None, 0, 0, 0, 0, 1, 0);
797- mSavedPointer.setX (lastPointerX + 9);
798+ mSavedPointer.setX (CompGlobal::instance ().lastPointerX () + 9);
799 }
800
801 }
802@@ -807,8 +807,8 @@
803 o.push_back (CompOption ("y", CompOption::TypeInt));
804
805 o[0].value ().set ((int) screen->root ());
806- o[1].value ().set (CompOption::getIntOptionNamed (options, "x", pointerX));
807- o[2].value ().set (CompOption::getIntOptionNamed (options, "y", pointerY));
808+ o[1].value ().set (CompOption::getIntOptionNamed (options, "x", CompGlobal::instance ().pointerX ()));
809+ o[2].value ().set (CompOption::getIntOptionNamed (options, "y", CompGlobal::instance ().pointerY ()));
810
811 if (withWindow)
812 {
813@@ -835,16 +835,16 @@
814 {
815 GLfloat pointerDx, pointerDy;
816
817- pointerDx = pointerX - lastPointerX;
818- pointerDy = pointerY - lastPointerY;
819+ pointerDx = CompGlobal::instance ().pointerX () - CompGlobal::instance ().lastPointerX ();
820+ pointerDy = CompGlobal::instance ().pointerY () - CompGlobal::instance ().lastPointerY ();
821
822 if (event->xmotion.x_root < 50 ||
823 event->xmotion.y_root < 50 ||
824 event->xmotion.x_root > screen->width () - 50 ||
825 event->xmotion.y_root > screen->height () - 50)
826 {
827- screen->warpPointer ((screen->width () / 2) - pointerX,
828- (screen->height () / 2) - pointerY);
829+ screen->warpPointer ((screen->width () / 2) - CompGlobal::instance ().pointerX (),
830+ (screen->height () / 2) - CompGlobal::instance ().pointerY ());
831 }
832
833 if (optionGetInvertY ())
834@@ -858,8 +858,8 @@
835 }
836 else
837 {
838- mSavedPointer.setX (mSavedPointer.x () + pointerX - lastPointerX);
839- mSavedPointer.setY (mSavedPointer.y () + pointerY - lastPointerY);
840+ mSavedPointer.setX (mSavedPointer.x () + CompGlobal::instance ().pointerX () - CompGlobal::instance ().lastPointerX ());
841+ mSavedPointer.setY (mSavedPointer.y () + CompGlobal::instance ().pointerY () - CompGlobal::instance ().lastPointerY ());
842 }
843 }
844 }
845
846=== modified file 'plugins/scale/src/scale.cpp'
847--- plugins/scale/src/scale.cpp 2012-01-12 17:49:40 +0000
848+++ plugins/scale/src/scale.cpp 2012-01-18 06:49:24 +0000
849@@ -1598,7 +1598,7 @@
850 state != ScaleScreen::In &&
851 w->id () == dndTarget)
852 {
853- ScaleWindow *sw = checkForWindowAt (pointerX, pointerY);
854+ ScaleWindow *sw = checkForWindowAt (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
855 if (sw && sw->priv->isScaleWin ())
856 {
857 int time;
858@@ -1607,7 +1607,7 @@
859
860 if (hover.active ())
861 {
862- int lastMotion = sqrt (pow (pointerX - lastPointerX, 2) + pow (pointerY - lastPointerY, 2));
863+ int lastMotion = sqrt (pow (CompGlobal::instance ().pointerX () - CompGlobal::instance ().lastPointerX (), 2) + pow (CompGlobal::instance ().pointerY () - CompGlobal::instance ().lastPointerY (), 2));
864
865 if (sw->window->id () != selectedWindow || lastMotion > optionGetDndDistance ())
866 hover.stop ();
867@@ -1618,7 +1618,7 @@
868 hover.start (time, (float) time * 1.2);
869 }
870
871- selectWindowAt (pointerX, pointerY, focus);
872+ selectWindowAt (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY (), focus);
873 }
874 else
875 {
876
877=== modified file 'plugins/screenshot/src/screenshot.cpp'
878--- plugins/screenshot/src/screenshot.cpp 2010-12-07 03:14:59 +0000
879+++ plugins/screenshot/src/screenshot.cpp 2012-01-18 06:49:24 +0000
880@@ -53,8 +53,8 @@
881
882 /* start selection screenshot rectangle */
883
884- mX1 = mX2 = pointerX;
885- mY1 = mY2 = pointerY;
886+ mX1 = mX2 = CompGlobal::instance ().pointerX ();
887+ mY1 = mY2 = CompGlobal::instance ().pointerY ();
888
889 mGrab = true;
890
891@@ -321,12 +321,12 @@
892 switch (event->type) {
893 case MotionNotify:
894 if (event->xmotion.root == screen->root ())
895- handleMotionEvent (pointerX, pointerY);
896+ handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
897 break;
898 case EnterNotify:
899 case LeaveNotify:
900 if (event->xcrossing.root == screen->root ())
901- handleMotionEvent (pointerX, pointerY);
902+ handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ());
903 default:
904 break;
905 }
906
907=== modified file 'plugins/switcher/src/switcher.cpp'
908--- plugins/switcher/src/switcher.cpp 2011-03-11 18:13:44 +0000
909+++ plugins/switcher/src/switcher.cpp 2012-01-18 06:49:24 +0000
910@@ -265,7 +265,8 @@
911 CWBackPixel | CWBorderPixel | CWColormap | CWOverrideRedirect, &attr);
912
913 XSetWMProperties (dpy, popupWindow, NULL, NULL,
914- programArgv, programArgc,
915+ CompGlobal::instance ().programArgv (),
916+ CompGlobal::instance ().programArgc (),
917 &xsh, &xwmh, &xch);
918
919 state[nState++] = Atoms::winStateAbove;
920
921=== modified file 'plugins/water/src/water.cpp'
922--- plugins/water/src/water.cpp 2011-03-14 16:12:45 +0000
923+++ plugins/water/src/water.cpp 2012-01-18 06:49:24 +0000
924@@ -1019,8 +1019,8 @@
925 p[0].x = waterLastPointerX;
926 p[0].y = waterLastPointerY;
927
928- p[1].x = waterLastPointerX = pointerX;
929- p[1].y = waterLastPointerY = pointerY;
930+ p[1].x = waterLastPointerX = CompGlobal::instance ().pointerX ();
931+ p[1].y = waterLastPointerY = CompGlobal::instance ().pointerY ();
932
933 waterVertices (GL_LINES, p, 2, 0.2f);
934
935@@ -1225,8 +1225,8 @@
936 {
937 XPoint p;
938
939- p.x = pointerX;
940- p.y = pointerY;
941+ p.x = CompGlobal::instance ().pointerX ();
942+ p.y = CompGlobal::instance ().pointerY ();
943
944 waterVertices (GL_POINTS, &p, 1, 0.8f);
945 cScreen->damageScreen ();
946
947=== modified file 'plugins/wobbly/src/wobbly.cpp'
948--- plugins/wobbly/src/wobbly.cpp 2011-03-14 16:12:45 +0000
949+++ plugins/wobbly/src/wobbly.cpp 2012-01-18 06:49:24 +0000
950@@ -1860,12 +1860,12 @@
951 int dx, dy;
952
953 if (ww->state & CompWindowStateMaximizedHorzMask)
954- dx = pointerX - lastPointerX;
955+ dx = CompGlobal::instance ().pointerX () - CompGlobal::instance ().lastPointerX ();
956 else
957 dx = 0;
958
959 if (ww->state & CompWindowStateMaximizedVertMask)
960- dy = pointerY - lastPointerY;
961+ dy = CompGlobal::instance ().pointerY () - CompGlobal::instance ().lastPointerY ();
962 else
963 dy = 0;
964
965@@ -2070,8 +2070,8 @@
966 if (model->anchorObject)
967 model->anchorObject->immobile = false;
968
969- model->anchorObject = model->findNearestObject (pointerX,
970- pointerY);
971+ model->anchorObject = model->findNearestObject (CompGlobal::instance ().pointerX (),
972+ CompGlobal::instance ().pointerY ());
973 model->anchorObject->immobile = true;
974
975 model->adjustObjectPosition (model->anchorObject,
976
977=== modified file 'plugins/zoom/src/zoom.cpp'
978--- plugins/zoom/src/zoom.cpp 2010-02-04 17:16:02 +0000
979+++ plugins/zoom/src/zoom.cpp 2012-01-18 06:49:24 +0000
980@@ -348,7 +348,7 @@
981
982 ZOOM_SCREEN (screen);
983
984- output = screen->outputDeviceForPoint (pointerX, pointerY);
985+ output = screen->outputDeviceForPoint (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY());
986
987 if (!zs->grabIndex)
988 {
989@@ -371,9 +371,9 @@
990 w = (box.x2 - box.x1) / zs->optionGetZoomFactor ();
991 h = (box.y2 - box.y1) / zs->optionGetZoomFactor ();
992
993- x0 = (pointerX - screen->outputDevs ()[output].x1 ()) / (float)
994+ x0 = (CompGlobal::instance ().pointerX() - screen->outputDevs ()[output].x1 ()) / (float)
995 screen->outputDevs ()[output].width ();
996- y0 = (pointerY - screen->outputDevs ()[output].y1 ()) / (float)
997+ y0 = (CompGlobal::instance ().pointerY() - screen->outputDevs ()[output].y1 ()) / (float)
998 screen->outputDevs ()[output].height ();
999
1000 zs->x1 = box.x1 + (x0 * (box.x2 - box.x1) - x0 * w + 0.5f);
1001@@ -410,7 +410,7 @@
1002
1003 /* start selection zoom rectangle */
1004
1005- output = screen->outputDeviceForPoint (pointerX, pointerY);
1006+ output = screen->outputDeviceForPoint (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY());
1007
1008 if (zs->zoomed & (1 << output))
1009 {
1010@@ -433,10 +433,10 @@
1011 }
1012
1013 zs->x1 = zs->x2 = x1 +
1014- ((pointerX - screen->outputDevs ()[output].x1 ()) /
1015+ ((CompGlobal::instance ().pointerX() - screen->outputDevs ()[output].x1 ()) /
1016 scale + 0.5f);
1017 zs->y1 = zs->y2 = y1 +
1018- ((pointerY - screen->outputDevs ()[output].y1 ()) /
1019+ ((CompGlobal::instance ().pointerY() - screen->outputDevs ()[output].y1 ()) /
1020 scale + 0.5f);
1021
1022 zs->zoomOutput = output;
1023@@ -458,7 +458,7 @@
1024
1025 ZOOM_SCREEN (screen);
1026
1027- output = screen->outputDeviceForPoint (pointerX, pointerY);
1028+ output = screen->outputDeviceForPoint (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY());
1029
1030 zs->getCurrentZoom (output, &zs->last[output]);
1031
1032@@ -526,7 +526,7 @@
1033
1034 ZOOM_SCREEN (screen);
1035
1036- output = screen->outputDeviceForPoint (pointerX, pointerY);
1037+ output = screen->outputDeviceForPoint (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY());
1038
1039 if (!(zs->zoomed & (1 << output)))
1040 return false;
1041@@ -610,8 +610,8 @@
1042 {
1043 float dx, dy;
1044
1045- dx = (xRoot - lastPointerX) / scale;
1046- dy = (yRoot - lastPointerY) / scale;
1047+ dx = (xRoot - CompGlobal::instance ().lastPointerX ()) / scale;
1048+ dy = (yRoot - CompGlobal::instance ().lastPointerY ()) / scale;
1049
1050 box.x1 -= dx;
1051 box.y1 -= dy;
1052@@ -677,12 +677,12 @@
1053 switch (event->type) {
1054 case MotionNotify:
1055 if (event->xmotion.root == screen->root ())
1056- handleMotionEvent (pointerX, pointerY);
1057+ handleMotionEvent (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY());
1058 break;
1059 case EnterNotify:
1060 case LeaveNotify:
1061 if (event->xcrossing.root == screen->root ())
1062- handleMotionEvent (pointerX, pointerY);
1063+ handleMotionEvent (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY());
1064 default:
1065 break;
1066 }
1067
1068=== modified file 'src/event.cpp'
1069--- src/event.cpp 2012-01-12 17:49:40 +0000
1070+++ src/event.cpp 2012-01-18 06:49:24 +0000
1071@@ -142,7 +142,7 @@
1072 {
1073 CompAction::State state = CompAction::StateInitButton;
1074 CompAction *action;
1075- unsigned int ignored = modHandler->ignoredModMask ();
1076+ unsigned int ignored = CompGlobal::instance ().modHandler ()->ignoredModMask ();
1077 unsigned int modMask = REAL_MOD_MASK & ~ignored;
1078 unsigned int bindMods;
1079 unsigned int edge = 0;
1080@@ -178,7 +178,7 @@
1081 {
1082 if (action->button ().button () == (int) event->button)
1083 {
1084- bindMods = modHandler->virtualToRealModMask (
1085+ bindMods = CompGlobal::instance ().modHandler ()->virtualToRealModMask (
1086 action->button ().modifiers ());
1087
1088 if ((bindMods & modMask) == (event->state & modMask))
1089@@ -197,7 +197,7 @@
1090 if ((action->button ().button () == (int) event->button) &&
1091 (action->edgeMask () & edge))
1092 {
1093- bindMods = modHandler->virtualToRealModMask (
1094+ bindMods = CompGlobal::instance ().modHandler ()->virtualToRealModMask (
1095 action->button ().modifiers ());
1096
1097 if ((bindMods & modMask) == (event->state & modMask))
1098@@ -245,7 +245,7 @@
1099 {
1100 CompAction::State state = 0;
1101 CompAction *action;
1102- unsigned int modMask = REAL_MOD_MASK & ~modHandler->ignoredModMask ();
1103+ unsigned int modMask = REAL_MOD_MASK & ~CompGlobal::instance ().modHandler ()->ignoredModMask ();
1104 unsigned int bindMods;
1105
1106 if (event->keycode == escapeKeyCode)
1107@@ -275,7 +275,7 @@
1108 if (isInitiateBinding (option, CompAction::BindingTypeKey,
1109 state, &action))
1110 {
1111- bindMods = modHandler->virtualToRealModMask (
1112+ bindMods = CompGlobal::instance ().modHandler ()->virtualToRealModMask (
1113 action->key ().modifiers ());
1114
1115 if (action->key ().keycode () == (int) event->keycode)
1116@@ -303,12 +303,12 @@
1117 {
1118 CompAction::State state = CompAction::StateTermKey;
1119 CompAction *action;
1120- unsigned int ignored = modHandler->ignoredModMask ();
1121+ unsigned int ignored = CompGlobal::instance ().modHandler ()->ignoredModMask ();
1122 unsigned int modMask = REAL_MOD_MASK & ~ignored;
1123 unsigned int bindMods;
1124 unsigned int mods;
1125
1126- mods = modHandler->keycodeToModifiers (event->keycode);
1127+ mods = CompGlobal::instance ().modHandler ()->keycodeToModifiers (event->keycode);
1128 if (!xkbEvent && !mods)
1129 return false;
1130
1131@@ -317,7 +317,7 @@
1132 if (isTerminateBinding (option, CompAction::BindingTypeKey,
1133 state, &action))
1134 {
1135- bindMods = modHandler->virtualToRealModMask (action->key ().modifiers ());
1136+ bindMods = CompGlobal::instance ().modHandler ()->virtualToRealModMask (action->key ().modifiers ());
1137
1138 if ((bindMods & modMask) == 0)
1139 {
1140@@ -346,7 +346,7 @@
1141 {
1142 CompAction::State state;
1143 CompAction *action;
1144- unsigned int ignored = modHandler->ignoredModMask ();
1145+ unsigned int ignored = CompGlobal::instance ().modHandler ()->ignoredModMask ();
1146 unsigned int modMask = REAL_MOD_MASK & ~ignored;
1147 unsigned int bindMods;
1148
1149@@ -362,7 +362,7 @@
1150 if (action->key ().keycode () == 0)
1151 {
1152 bindMods =
1153- modHandler->virtualToRealModMask (action->key ().modifiers ());
1154+ CompGlobal::instance ().modHandler ()->virtualToRealModMask (action->key ().modifiers ());
1155
1156 if ((event->mods & modMask & bindMods) == bindMods)
1157 {
1158@@ -382,7 +382,7 @@
1159 if (isTerminateBinding (option, CompAction::BindingTypeKey,
1160 state, &action))
1161 {
1162- bindMods = modHandler->virtualToRealModMask (action->key ().modifiers ());
1163+ bindMods = CompGlobal::instance ().modHandler ()->virtualToRealModMask (action->key ().modifiers ());
1164
1165 if ((event->mods & modMask & bindMods) != bindMods)
1166 {
1167@@ -1710,7 +1710,7 @@
1168 }
1169 break;
1170 case MappingNotify:
1171- modHandler->updateModifierMappings ();
1172+ CompGlobal::instance ().modHandler ()->updateModifierMappings ();
1173 break;
1174 case MapRequest:
1175 w = screen->findWindow (event->xmaprequest.window);
1176
1177=== modified file 'src/eventsource.cpp'
1178--- src/eventsource.cpp 2011-08-19 14:25:11 +0000
1179+++ src/eventsource.cpp 2012-01-18 06:49:24 +0000
1180@@ -62,7 +62,7 @@
1181 bool
1182 CompEventSource::callback ()
1183 {
1184- if (restartSignal || shutDown)
1185+ if (CompGlobal::instance ().restartSignal () || CompGlobal::instance ().shutDown ())
1186 {
1187 screen->priv->mainloop->quit ();
1188 return false;
1189
1190=== modified file 'src/logmessage/src/logmessage.cpp'
1191--- src/logmessage/src/logmessage.cpp 2011-12-19 07:06:22 +0000
1192+++ src/logmessage/src/logmessage.cpp 2012-01-18 06:49:24 +0000
1193@@ -56,11 +56,11 @@
1194 CompLogLevel level,
1195 const char *message)
1196 {
1197- if (!debugOutput && level >= CompLogLevelDebug)
1198+ if (!CompGlobal::instance ().isDebugOutput () && level >= CompLogLevelDebug)
1199 return;
1200
1201 fprintf (stderr, "%s (%s) - %s: %s\n",
1202- programName, componentName,
1203+ CompGlobal::instance ().programName (), componentName,
1204 logLevelToString (level), message);
1205 }
1206
1207
1208=== modified file 'src/main.cpp'
1209--- src/main.cpp 2011-10-31 13:51:00 +0000
1210+++ src/main.cpp 2012-01-18 06:49:24 +0000
1211@@ -38,26 +38,7 @@
1212 #include "privatescreen.h"
1213 #include "privatestackdebugger.h"
1214
1215-char *programName;
1216-char **programArgv;
1217-int programArgc;
1218-
1219-char *backgroundImage = NULL;
1220-
1221-bool shutDown = false;
1222-bool restartSignal = false;
1223-
1224-CompWindow *lastFoundWindow = 0;
1225-
1226-bool replaceCurrentWm = false;
1227-bool indirectRendering = false;
1228-bool noDetection = false;
1229-bool useDesktopHints = false;
1230-bool debugOutput = false;
1231-bool useCow = true;
1232-
1233-std::list <CompString> initialPlugins;
1234-
1235+bool useCow = false;
1236 unsigned int pluginClassHandlerIndex = 0;
1237
1238 void
1239@@ -77,7 +58,7 @@
1240 "[--version] "
1241 "[--help] "
1242 "[PLUGIN]...\n",
1243- programName);
1244+ CompGlobal::instance ().programName ());
1245 }
1246
1247 static void
1248@@ -90,11 +71,11 @@
1249 waitpid (-1, &status, WNOHANG | WUNTRACED);
1250 break;
1251 case SIGHUP:
1252- restartSignal = true;
1253+ CompGlobal::instance ().setRestartSignal (true);
1254 break;
1255 case SIGINT:
1256 case SIGTERM:
1257- shutDown = true;
1258+ CompGlobal::instance ().setShutDown (true);
1259 default:
1260 break;
1261 }
1262@@ -117,7 +98,7 @@
1263 }
1264 else if (!strcmp (argv[i], "--debug"))
1265 {
1266- debugOutput = true;
1267+ CompGlobal::instance ().setDebugOutput (true);
1268 }
1269 else if (!strcmp (argv[i], "--display"))
1270 {
1271@@ -126,11 +107,11 @@
1272 }
1273 else if (!strcmp (argv[i], "--indirect-rendering"))
1274 {
1275- indirectRendering = true;
1276+ CompGlobal::instance ().setIndirectRendering (true);
1277 }
1278 else if (!strcmp (argv[i], "--keep-desktop-hints"))
1279 {
1280- useDesktopHints = true;
1281+ CompGlobal::instance ().setUseDesktopHints(true);
1282 }
1283 else if (!strcmp (argv[i], "--use-root-window"))
1284 {
1285@@ -138,7 +119,7 @@
1286 }
1287 else if (!strcmp (argv[i], "--replace"))
1288 {
1289- replaceCurrentWm = true;
1290+ CompGlobal::instance ().setReplaceCurrentWm (true);
1291 }
1292 else if (!strcmp (argv[i], "--sm-disable"))
1293 {
1294@@ -151,12 +132,12 @@
1295 }
1296 else if (!strcmp (argv[i], "--no-detection"))
1297 {
1298- noDetection = true;
1299+ CompGlobal::instance ().setNoDetection (true);
1300 }
1301 else if (!strcmp (argv[i], "--bg-image"))
1302 {
1303 if (i + 1 < argc)
1304- backgroundImage = argv[++i];
1305+ CompGlobal::instance ().setBackgroundImage (argv[++i]);
1306 }
1307 else if (*argv[i] == '-')
1308 {
1309@@ -169,7 +150,7 @@
1310 }
1311 }
1312
1313- initialPlugins = plugins;
1314+ CompGlobal::instance ().setInitialPlugins (plugins);
1315
1316 return true;
1317 }
1318@@ -195,9 +176,9 @@
1319 return false;
1320 }
1321
1322- modHandler = new ModifierHandler ();
1323+ CompGlobal::instance ().setModHandler (new ModifierHandler ());
1324
1325- if (!modHandler)
1326+ if (!CompGlobal::instance ().modHandler ())
1327 return false;
1328
1329 if (!plugins.empty ())
1330@@ -224,7 +205,7 @@
1331 if (!screen->init (displayName))
1332 return false;
1333
1334- if (debugOutput)
1335+ if (CompGlobal::instance ().isDebugOutput())
1336 {
1337 StackDebugger::SetDefault (new StackDebugger (screen->dpy (),
1338 screen->root (),
1339@@ -262,7 +243,7 @@
1340 StackDebugger::SetDefault (NULL);
1341
1342 delete screen;
1343- delete modHandler;
1344+ delete CompGlobal::instance ().modHandler ();
1345 }
1346
1347
1348@@ -272,9 +253,9 @@
1349 {
1350 CompManager manager;
1351
1352- programName = argv[0];
1353- programArgc = argc;
1354- programArgv = argv;
1355+ CompGlobal::instance ().setProgramName (argv[0]);
1356+ CompGlobal::instance ().setProgramArgc(argc);
1357+ CompGlobal::instance ().setProgramArgv(argv);
1358
1359 signal (SIGHUP, signalHandler);
1360 signal (SIGCHLD, signalHandler);
1361@@ -291,9 +272,9 @@
1362
1363 manager.fini ();
1364
1365- if (restartSignal)
1366+ if (CompGlobal::instance ().restartSignal ())
1367 {
1368- execvp (programName, programArgv);
1369+ execvp (CompGlobal::instance ().programName(), CompGlobal::instance ().programArgv ());
1370 return 1;
1371 }
1372
1373
1374=== modified file 'src/privatescreen.h'
1375--- src/privatescreen.h 2011-10-31 13:51:00 +0000
1376+++ src/privatescreen.h 2012-01-18 06:49:24 +0000
1377@@ -49,20 +49,6 @@
1378
1379 class CoreWindow;
1380
1381-extern bool shutDown;
1382-extern bool restartSignal;
1383-
1384-extern CompWindow *lastFoundWindow;
1385-extern bool useDesktopHints;
1386-
1387-extern bool inHandleEvent;
1388-
1389-extern CompScreen *targetScreen;
1390-extern CompOutput *targetOutput;
1391-
1392-extern std::list <CompString> initialPlugins;
1393-
1394-
1395 typedef struct _CompDelayedEdgeSettings
1396 {
1397 CompAction::CallBack initiate;
1398
1399=== modified file 'src/screen.cpp'
1400--- src/screen.cpp 2012-01-16 08:36:54 +0000
1401+++ src/screen.cpp 2012-01-18 06:49:24 +0000
1402@@ -610,7 +610,7 @@
1403 return screen->updateDefaultIcon ();
1404 break;
1405 case CoreOptions::Outputs:
1406- if (!noDetection && optionGetDetectOutputs ())
1407+ if (!CompGlobal::instance ().noDetection () && optionGetDetectOutputs ())
1408 return false;
1409 updateOutputDevices ();
1410 break;
1411@@ -787,7 +787,7 @@
1412 /* Determine the number of plugins, which is core +
1413 * initial plugins + plugins in option list in addition
1414 * to initial plugins */
1415- foreach (CompString &pn, initialPlugins)
1416+ foreach (CompString &pn, CompGlobal::instance ().initialPlugins ())
1417 {
1418 if (pn != "core")
1419 pListCount++;
1420@@ -799,7 +799,7 @@
1421 if (lp.s () == "core")
1422 continue;
1423
1424- foreach (CompString &p, initialPlugins)
1425+ foreach (CompString &p, CompGlobal::instance ().initialPlugins ())
1426 {
1427 if (p == lp.s ())
1428 {
1429@@ -828,7 +828,7 @@
1430 j = 1;
1431
1432 /* Add initial plugins */
1433- foreach (CompString &p, initialPlugins)
1434+ foreach (CompString &p, CompGlobal::instance ().initialPlugins ())
1435 {
1436 if (p == "core")
1437 continue;
1438@@ -839,12 +839,12 @@
1439 /* Add plugins not in the initial list */
1440 foreach (CompOption::Value &opt, list)
1441 {
1442- std::list <CompString>::iterator it = initialPlugins.begin ();
1443+ std::list <CompString>::iterator it = CompGlobal::instance ().initialPlugins ().begin ();
1444 bool skip = false;
1445 if (opt.s () == "core")
1446 continue;
1447
1448- for (; it != initialPlugins.end (); it++)
1449+ for (; it != CompGlobal::instance ().initialPlugins ().end (); it++)
1450 {
1451 if ((*it) == opt.s ())
1452 {
1453@@ -1054,7 +1054,7 @@
1454 wmSnAtom != event->xselectionclear.selection)
1455 return;
1456
1457- shutDown = true;
1458+ CompGlobal::instance ().setShutDown (true);
1459 }
1460
1461 #define IMAGEDIR "images"
1462@@ -1868,7 +1868,7 @@
1463 void
1464 PrivateScreen::detectOutputDevices ()
1465 {
1466- if (!noDetection && optionGetDetectOutputs ())
1467+ if (!CompGlobal::instance ().noDetection () && optionGetDetectOutputs ())
1468 {
1469 CompString name;
1470 CompOption::Value value;
1471@@ -2257,7 +2257,7 @@
1472 unsigned long n, left;
1473 unsigned char *propData;
1474
1475- if (useDesktopHints)
1476+ if (CompGlobal::instance ().useDesktopHints ())
1477 {
1478 result = XGetWindowProperty (dpy, root,
1479 Atoms::numberOfDesktops,
1480@@ -2531,16 +2531,19 @@
1481 CompWindow *
1482 CompScreen::findWindow (Window id)
1483 {
1484- if (lastFoundWindow && lastFoundWindow->id () == id)
1485+ if (CompGlobal::instance ().lastFoundWindow () && CompGlobal::instance ().lastFoundWindow ()->id () == id)
1486 {
1487- return lastFoundWindow;
1488+ return CompGlobal::instance ().lastFoundWindow ();
1489 }
1490 else
1491 {
1492 CompWindow::Map::iterator it = priv->windowsMap.find (id);
1493
1494 if (it != priv->windowsMap.end ())
1495- return (lastFoundWindow = it->second);
1496+ {
1497+ CompGlobal::instance ().setLastFoundWindow (it->second);
1498+ return (CompGlobal::instance ().lastFoundWindow ());
1499+ }
1500 }
1501
1502 return 0;
1503@@ -2729,8 +2732,8 @@
1504 w->next = NULL;
1505 w->prev = NULL;
1506
1507- if (w == lastFoundWindow)
1508- lastFoundWindow = NULL;
1509+ if (w == CompGlobal::instance ().lastFoundWindow ())
1510+ CompGlobal::instance ().setLastFoundWindow (NULL);
1511 }
1512
1513 void
1514@@ -4398,7 +4401,7 @@
1515
1516 if (currentWmSnOwner != None)
1517 {
1518- if (!replaceCurrentWm)
1519+ if (!CompGlobal::instance ().replaceCurrentWm ())
1520 {
1521 compLogMessage ("core", CompLogLevelError,
1522 "Screen %d on display \"%s\" already "
1523
1524=== modified file 'src/session.cpp'
1525--- src/session.cpp 2011-10-31 13:51:00 +0000
1526+++ src/session.cpp 2012-01-18 06:49:24 +0000
1527@@ -91,18 +91,18 @@
1528
1529 /* at maximum, we pass our old arguments + our new client id
1530 to the SM, so allocate for that case */
1531- args = (const char **) malloc ((programArgc + 2) * sizeof (char *));
1532+ args = (const char **) malloc ((CompGlobal::instance ().programArgc () + 2) * sizeof (char *));
1533 if (!args)
1534 return;
1535
1536- for (i = 0; i < programArgc; i++)
1537+ for (i = 0; i < CompGlobal::instance ().programArgc(); i++)
1538 {
1539- if (strcmp (programArgv[i], "--sm-client-id") == 0)
1540+ if (strcmp (CompGlobal::instance ().programArgv ()[i], "--sm-client-id") == 0)
1541 i++; /* skip old client id, we'll add the new one later */
1542- else if (strcmp (programArgv[i], "--replace") == 0)
1543+ else if (strcmp (CompGlobal::instance ().programArgv ()[i], "--replace") == 0)
1544 continue; /* there's nothing to replace when starting session */
1545 else
1546- args[count++] = programArgv[i];
1547+ args[count++] = CompGlobal::instance ().programArgv ()[i];
1548 }
1549
1550 setStringListProperty (connection, SmCloneCommand, args, count);
1551
1552=== removed file 'src/tests/globals.h'
1553--- src/tests/globals.h 2012-01-18 06:49:24 +0000
1554+++ src/tests/globals.h 1970-01-01 00:00:00 +0000
1555@@ -1,24 +0,0 @@
1556-#ifndef GLOBALS_H
1557-#define GLOBALS_H
1558-
1559-char *programName;
1560-char **programArgv;
1561-int programArgc;
1562-
1563-bool shutDown = false;
1564-bool restartSignal = false;
1565-
1566-CompWindow *lastFoundWindow = 0;
1567-
1568-bool replaceCurrentWm = false;
1569-bool indirectRendering = false;
1570-bool noDetection = false;
1571-bool useDesktopHints = false;
1572-bool debugOutput = false;
1573-bool useCow = true;
1574-
1575-std::list <CompString> initialPlugins;
1576-
1577-unsigned int pluginClassHandlerIndex = 0;
1578-
1579-#endif // GLOBALS_H
1580
1581=== modified file 'src/tests/option.cpp'
1582--- src/tests/option.cpp 2012-01-18 06:49:24 +0000
1583+++ src/tests/option.cpp 2012-01-18 06:49:24 +0000
1584@@ -5,8 +5,6 @@
1585 #include "core/match.h"
1586 #include "core/option.h"
1587
1588-#include "globals.h"
1589-
1590 namespace {
1591 template<typename T>
1592 void
1593
1594=== modified file 'src/window.cpp'
1595--- src/window.cpp 2012-01-16 09:10:42 +0000
1596+++ src/window.cpp 2012-01-18 06:49:24 +0000
1597@@ -5984,15 +5984,15 @@
1598 /* Grab only we have bindings on */
1599 foreach (PrivateScreen::ButtonGrab &bind, screen->priv->buttonGrabs)
1600 {
1601- unsigned int mods = modHandler->virtualToRealModMask (bind.modifiers);
1602+ unsigned int mods = CompGlobal::instance ().modHandler ()->virtualToRealModMask (bind.modifiers);
1603
1604 if (mods & CompNoMask)
1605 continue;
1606
1607 for (unsigned int ignore = 0;
1608- ignore <= modHandler->ignoredModMask (); ignore++)
1609+ ignore <= CompGlobal::instance ().modHandler ()->ignoredModMask (); ignore++)
1610 {
1611- if (ignore & ~modHandler->ignoredModMask ())
1612+ if (ignore & ~CompGlobal::instance ().modHandler ()->ignoredModMask ())
1613 continue;
1614
1615 XGrabButton (screen->priv->dpy,

Subscribers

People subscribed via source and target branches