Merge lp:~thomas-voss/compiz-core/fix-globals into lp:compiz-core/0.9.5
- fix-globals
- Merge into 0.9.5
Status: | Superseded |
---|---|
Proposed branch: | lp:~thomas-voss/compiz-core/fix-globals |
Merge into: | lp:compiz-core/0.9.5 |
Diff against target: |
2590 lines (+795/-724) 31 files modified
include/core/action.h (+1/-1) include/core/global.h (+329/-8) include/core/option.h (+100/-52) 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/CMakeLists.txt (+35/-14) src/action.cpp (+1/-1) src/event.cpp (+12/-12) src/eventsource.cpp (+1/-1) src/logmessage/src/logmessage.cpp (+2/-2) src/main.cpp (+20/-39) src/option.cpp (+105/-433) src/privateoption.h (+0/-26) src/privatescreen.h (+0/-14) src/screen.cpp (+18/-15) src/session.cpp (+5/-5) src/tests/CMakeLists.txt (+20/-0) src/tests/option.cpp (+43/-0) src/window.cpp (+3/-3) |
To merge this branch: | bzr merge lp:~thomas-voss/compiz-core/fix-globals |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alan Griffiths | Disapprove | ||
Review via email:
|
This proposal has been superseded by a proposal from 2012-01-18.
Commit message
Description of the change
Got rid of public externals and replaced them with a singleton.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) wrote : | # |
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 setIndirectRend
114 + {
115 + mIndirectRendering = isIndirectRende
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...
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sam Spilsbury (smspillaz) wrote : | # |
Oh, and targetOutput is only used by the opengl plugin, so it can be moved there or removed alltogether.
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
1 | === modified file 'include/core/action.h' |
2 | --- include/core/action.h 2010-11-09 14:13:19 +0000 |
3 | +++ include/core/action.h 2012-01-17 16:06:33 +0000 |
4 | @@ -154,7 +154,7 @@ |
5 | |
6 | void copyState (const CompAction &action); |
7 | |
8 | - bool operator== (const CompAction& val); |
9 | + bool operator== (const CompAction& val) const; |
10 | CompAction & operator= (const CompAction &action); |
11 | |
12 | bool keyFromString (const CompString &str); |
13 | |
14 | === modified file 'include/core/global.h' |
15 | --- include/core/global.h 2011-12-19 07:06:22 +0000 |
16 | +++ include/core/global.h 2012-01-17 16:06:33 +0000 |
17 | @@ -25,13 +25,334 @@ |
18 | #ifndef _COMPIZ_GLOBAL_H |
19 | #define _COMPIZ_GLOBAL_H |
20 | |
21 | -/** |
22 | -* Flag indicating whether to produce debug output |
23 | -*/ |
24 | -extern bool debugOutput; |
25 | - |
26 | -extern char *programName; |
27 | -extern char **programArgv; |
28 | -extern int programArgc; |
29 | +#include <list> |
30 | + |
31 | +#include "core/string.h" |
32 | + |
33 | +class CompOutput; |
34 | +class CompScreen; |
35 | +class CompWindow; |
36 | +class ModifierHandler; |
37 | + |
38 | +class CompGlobal |
39 | +{ |
40 | +public: |
41 | + |
42 | + static CompGlobal & instance () |
43 | + { |
44 | + static CompGlobal inst; |
45 | + return inst; |
46 | + } |
47 | + |
48 | + bool isDebugOutput () const |
49 | + { |
50 | + return mDebugOutput; |
51 | + } |
52 | + |
53 | + void setDebugOutput (bool isDebugOutput) |
54 | + { |
55 | + mDebugOutput = isDebugOutput; |
56 | + } |
57 | + |
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 | + } |
77 | + |
78 | + int programArgc () const |
79 | + { |
80 | + return mProgramArgc; |
81 | + } |
82 | + |
83 | + void setProgramArgc (int argc) |
84 | + { |
85 | + mProgramArgc = argc; |
86 | + } |
87 | + |
88 | + char * backgroundImage () const |
89 | + { |
90 | + return mBackgroundImage; |
91 | + } |
92 | + |
93 | + void setBackgroundImage (char * bgImage) |
94 | + { |
95 | + mBackgroundImage = bgImage; |
96 | + } |
97 | + |
98 | + bool replaceCurrentWm () const |
99 | + { |
100 | + return mReplaceCurrentWm; |
101 | + } |
102 | + |
103 | + void setReplaceCurrentWm (bool doReplace) |
104 | + { |
105 | + mReplaceCurrentWm = doReplace; |
106 | + } |
107 | + |
108 | + bool indirectRendering () const |
109 | + { |
110 | + return mIndirectRendering; |
111 | + } |
112 | + |
113 | + void setIndirectRendering (bool isIndirectRendering) |
114 | + { |
115 | + mIndirectRendering = isIndirectRendering; |
116 | + } |
117 | + |
118 | + bool noDetection () const |
119 | + { |
120 | + return mNoDetection; |
121 | + } |
122 | + |
123 | + void setNoDetection (bool noDetection) |
124 | + { |
125 | + mNoDetection = noDetection; |
126 | + } |
127 | + |
128 | + CompScreen * screen () const |
129 | + { |
130 | + return mScreen; |
131 | + } |
132 | + |
133 | + void setScreen (CompScreen * screen) |
134 | + { |
135 | + mScreen = screen; |
136 | + } |
137 | + |
138 | + ModifierHandler * modHandler () const |
139 | + { |
140 | + return mModHandler; |
141 | + } |
142 | + |
143 | + void setModHandler (ModifierHandler * handler) |
144 | + { |
145 | + mModHandler = handler; |
146 | + } |
147 | + |
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 | + } |
167 | + |
168 | + unsigned int lastPointerMods () const |
169 | + { |
170 | + return mLastPointerMods; |
171 | + } |
172 | + |
173 | + void setLastPointerMods (unsigned int mods) |
174 | + { |
175 | + mLastPointerMods = mods; |
176 | + } |
177 | + |
178 | + int pointerX () const |
179 | + { |
180 | + return mPointerX; |
181 | + } |
182 | + |
183 | + void setPointerX (int x) |
184 | + { |
185 | + mPointerX = x; |
186 | + } |
187 | + |
188 | + int pointerY () const |
189 | + { |
190 | + return mPointerY; |
191 | + } |
192 | + |
193 | + void setPointerY (int y) |
194 | + { |
195 | + mPointerY = y; |
196 | + } |
197 | + |
198 | + unsigned int pointerMods () const |
199 | + { |
200 | + return mPointerMods; |
201 | + } |
202 | + |
203 | + void setPointerMods (unsigned int mods) |
204 | + { |
205 | + mPointerMods = mods; |
206 | + } |
207 | + |
208 | + bool shutDown () const |
209 | + { |
210 | + return mShutDown; |
211 | + } |
212 | + |
213 | + void setShutDown (bool isShutDown) |
214 | + { |
215 | + mShutDown = isShutDown; |
216 | + } |
217 | + |
218 | + bool inHandleEvent () const |
219 | + { |
220 | + return mInHandleEvent; |
221 | + } |
222 | + |
223 | + std::list<CompString> & initialPlugins () |
224 | + { |
225 | + return mInitialPlugins; |
226 | + } |
227 | + |
228 | + const std::list<CompString> & initialPlugins () const |
229 | + { |
230 | + return mInitialPlugins; |
231 | + } |
232 | + |
233 | + CompWindow *lastFoundWindow () const |
234 | + { |
235 | + return mLastFoundWindow; |
236 | + } |
237 | + |
238 | + bool restartSignal () const |
239 | + { |
240 | + return mRestartSignal; |
241 | + } |
242 | + |
243 | + void setInHandleEvent (bool inHandleEvent) |
244 | + { |
245 | + mInHandleEvent = inHandleEvent; |
246 | + } |
247 | + |
248 | + void setInitialPlugins (const std::list<CompString> & initialPlugins) |
249 | + { |
250 | + mInitialPlugins = initialPlugins; |
251 | + } |
252 | + |
253 | + void setLastFoundWindow (CompWindow *lastFoundWindow) |
254 | + { |
255 | + mLastFoundWindow = lastFoundWindow; |
256 | + } |
257 | + |
258 | + void setRestartSignal (bool restartSignal) |
259 | + { |
260 | + mRestartSignal = restartSignal; |
261 | + } |
262 | + |
263 | + void setTargetOutput (CompOutput *targetOutput) |
264 | + { |
265 | + mTargetOutput = targetOutput; |
266 | + } |
267 | + |
268 | + void setTargetScreen (CompScreen *targetScreen) |
269 | + { |
270 | + mTargetScreen = targetScreen; |
271 | + } |
272 | + |
273 | + void setUseDesktopHints (bool useDesktopHints) |
274 | + { |
275 | + mUseDesktopHints = useDesktopHints; |
276 | + } |
277 | + |
278 | + CompOutput *targetOutput () const |
279 | + { |
280 | + return mTargetOutput; |
281 | + } |
282 | + |
283 | + CompScreen *targetScreen () const |
284 | + { |
285 | + return mTargetScreen; |
286 | + } |
287 | + |
288 | + bool useDesktopHints () const |
289 | + { |
290 | + return mUseDesktopHints; |
291 | + } |
292 | +private: |
293 | + CompGlobal () : |
294 | + mDebugOutput(false), |
295 | + mProgramName(0), |
296 | + mProgramArgv(0), |
297 | + mProgramArgc(0), |
298 | + mBackgroundImage(0), |
299 | + mReplaceCurrentWm(false), |
300 | + mIndirectRendering(false), |
301 | + mNoDetection(false), |
302 | + mScreen(0), |
303 | + mModHandler(0), |
304 | + mLastPointerX(0), |
305 | + mLastPointerY(0), |
306 | + mLastPointerMods(0), |
307 | + mPointerX(0), |
308 | + mPointerY(0), |
309 | + mPointerMods(0), |
310 | + mShutDown(false), |
311 | + mRestartSignal(false), |
312 | + mLastFoundWindow(0), |
313 | + mUseDesktopHints(false), |
314 | + mInHandleEvent(false), |
315 | + mTargetScreen(0), |
316 | + mTargetOutput(0) |
317 | + { |
318 | + } |
319 | + |
320 | + CompGlobal (const CompGlobal & rhs); |
321 | + CompGlobal & operator= (const CompGlobal & rhs); |
322 | + bool operator== (const CompGlobal & rhs) const; |
323 | + |
324 | + bool mDebugOutput; |
325 | + |
326 | + char *mProgramName; |
327 | + char **mProgramArgv; |
328 | + int mProgramArgc; |
329 | + |
330 | + char * mBackgroundImage; |
331 | + bool mReplaceCurrentWm; |
332 | + bool mIndirectRendering; |
333 | + bool mNoDetection; |
334 | + |
335 | + CompScreen * mScreen; |
336 | + ModifierHandler * mModHandler; |
337 | + |
338 | + int mLastPointerX; |
339 | + int mLastPointerY; |
340 | + unsigned int mLastPointerMods; |
341 | + int mPointerX; |
342 | + int mPointerY; |
343 | + unsigned int mPointerMods; |
344 | + |
345 | + bool mShutDown; |
346 | + bool mRestartSignal; |
347 | + |
348 | + CompWindow *mLastFoundWindow; |
349 | + bool mUseDesktopHints; |
350 | + |
351 | + bool mInHandleEvent; |
352 | + |
353 | + CompScreen * mTargetScreen; |
354 | + CompOutput * mTargetOutput; |
355 | + |
356 | + std::list<CompString> mInitialPlugins; |
357 | +}; |
358 | |
359 | #endif // _COMPIZ_GLOBAL_H |
360 | |
361 | === modified file 'include/core/option.h' |
362 | --- include/core/option.h 2011-10-31 13:51:00 +0000 |
363 | +++ include/core/option.h 2012-01-17 16:06:33 +0000 |
364 | @@ -29,11 +29,15 @@ |
365 | #define _COMPOPTION_H |
366 | |
367 | #include <core/string.h> |
368 | + |
369 | +#include <boost/variant.hpp> |
370 | + |
371 | #include <vector> |
372 | |
373 | class PrivateOption; |
374 | class PrivateValue; |
375 | class PrivateRestriction; |
376 | + |
377 | class CompAction; |
378 | class CompMatch; |
379 | class CompScreen; |
380 | @@ -54,12 +58,12 @@ |
381 | TypeString, |
382 | TypeColor, |
383 | TypeAction, |
384 | + TypeMatch, |
385 | + TypeList, |
386 | TypeKey, |
387 | TypeButton, |
388 | TypeEdge, |
389 | TypeBell, |
390 | - TypeMatch, |
391 | - TypeList, |
392 | /* internal use only */ |
393 | TypeUnset |
394 | } Type; |
395 | @@ -69,61 +73,105 @@ |
396 | */ |
397 | class Value { |
398 | public: |
399 | + |
400 | + typedef boost::variant< |
401 | + bool, |
402 | + int, |
403 | + float, |
404 | + CompString, |
405 | + unsigned short*, |
406 | + boost::recursive_wrapper<CompAction>, |
407 | + boost::recursive_wrapper<CompMatch>, |
408 | + boost::recursive_wrapper<std::vector<Value> > |
409 | + > variant_type; |
410 | + |
411 | typedef std::vector<Value> Vector; |
412 | |
413 | public: |
414 | - Value (); |
415 | - Value (const Value &); |
416 | - Value (const bool b); |
417 | - Value (const int i); |
418 | - Value (const float f); |
419 | - Value (const unsigned short *color); |
420 | - Value (const CompString& s); |
421 | - Value (const char *s); |
422 | - Value (const CompMatch& m); |
423 | - Value (const CompAction& a); |
424 | - Value (Type type, const Vector& l); |
425 | - ~Value (); |
426 | - |
427 | - Type type () const; |
428 | - |
429 | - void set (const bool b); |
430 | - void set (const int i); |
431 | - void set (const float f); |
432 | - void set (const unsigned short *color); |
433 | - void set (const CompString& s); |
434 | - void set (const char *s); |
435 | - void set (const CompMatch& m); |
436 | - void set (const CompAction& a); |
437 | - void set (Type type, const Vector& l); |
438 | - |
439 | - bool b (); |
440 | - int i (); |
441 | - float f (); |
442 | - unsigned short* c (); |
443 | - CompString s (); |
444 | - CompMatch & match (); |
445 | - CompAction & action (); |
446 | - Type listType (); |
447 | - Vector & list (); |
448 | - |
449 | - bool operator== (const Value& val); |
450 | - bool operator!= (const Value& val); |
451 | - Value & operator= (const Value &val); |
452 | - |
453 | - operator bool (); |
454 | - operator int (); |
455 | - operator float (); |
456 | - operator unsigned short * (); |
457 | - operator CompString (); |
458 | - operator CompMatch & (); |
459 | - operator CompAction & (); |
460 | - operator CompAction * (); |
461 | - operator Type (); |
462 | - operator Vector & (); |
463 | + Value () : mListType(TypeUnset) |
464 | + { |
465 | + } |
466 | + |
467 | + template<typename T> |
468 | + Value( const T & t ) : mListType(TypeUnset), |
469 | + mValue(t) |
470 | + { |
471 | + } |
472 | + |
473 | + ~Value(); |
474 | + |
475 | + Type |
476 | + type () const |
477 | + { |
478 | + return static_cast<Type>(mValue.which()); |
479 | + } |
480 | + |
481 | + Type |
482 | + listType () const |
483 | + { |
484 | + return mListType; |
485 | + } |
486 | + |
487 | + template<typename T> |
488 | + void set (const T & t) |
489 | + { |
490 | + mValue = t; |
491 | + } |
492 | + |
493 | + template<typename T> |
494 | + const T & get () const |
495 | + { |
496 | + return boost::get<T> (mValue); |
497 | + } |
498 | + |
499 | + void |
500 | + set (Type t, const Vector & v); |
501 | + |
502 | + bool |
503 | + b () const; |
504 | + |
505 | + int |
506 | + i () const; |
507 | + |
508 | + float |
509 | + f () const; |
510 | + |
511 | + unsigned short* |
512 | + c () const; |
513 | + |
514 | + const CompString & |
515 | + s () const; |
516 | + |
517 | + CompString & |
518 | + s (); |
519 | + |
520 | + const CompMatch & |
521 | + match () const; |
522 | + |
523 | + CompMatch & |
524 | + match (); |
525 | + |
526 | + const CompAction & |
527 | + action () const; |
528 | + |
529 | + CompAction & |
530 | + action (); |
531 | + |
532 | + const Vector & |
533 | + list () const; |
534 | + |
535 | + Vector & |
536 | + list (); |
537 | + |
538 | + bool |
539 | + operator== (const Value & rhs) const; |
540 | + |
541 | + bool |
542 | + operator!= (const Value & rhs) const; |
543 | |
544 | private: |
545 | - PrivateValue *priv; |
546 | + Type mListType; |
547 | + variant_type mValue; |
548 | }; |
549 | |
550 | /** |
551 | |
552 | === modified file 'include/core/screen.h' |
553 | --- include/core/screen.h 2011-09-19 12:54:22 +0000 |
554 | +++ include/core/screen.h 2012-01-17 16:06:33 +0000 |
555 | @@ -45,6 +45,7 @@ |
556 | typedef std::list<CompWindow *> CompWindowList; |
557 | typedef std::vector<CompWindow *> CompWindowVector; |
558 | |
559 | +/* |
560 | extern char *backgroundImage; |
561 | extern bool replaceCurrentWm; |
562 | extern bool indirectRendering; |
563 | @@ -60,7 +61,7 @@ |
564 | extern int pointerX; |
565 | extern int pointerY; |
566 | extern unsigned int pointerMods; |
567 | - |
568 | +*/ |
569 | #define NOTIFY_CREATE_MASK (1 << 0) |
570 | #define NOTIFY_DELETE_MASK (1 << 1) |
571 | #define NOTIFY_MOVE_MASK (1 << 2) |
572 | |
573 | === modified file 'plugins/annotate/src/annotate.cpp' |
574 | --- plugins/annotate/src/annotate.cpp 2010-07-02 03:00:14 +0000 |
575 | +++ plugins/annotate/src/annotate.cpp 2012-01-17 16:06:33 +0000 |
576 | @@ -468,8 +468,8 @@ |
577 | if (state & CompAction::StateInitKey) |
578 | action->setState (action->state () | CompAction::StateTermKey); |
579 | |
580 | - annoLastPointerX = pointerX; |
581 | - annoLastPointerY = pointerY; |
582 | + annoLastPointerX = CompGlobal::instance ().pointerX (); |
583 | + annoLastPointerY = CompGlobal::instance ().pointerY (); |
584 | |
585 | drawMode = EraseMode; |
586 | |
587 | @@ -495,8 +495,8 @@ |
588 | if (state & CompAction::StateInitKey) |
589 | action->setState (action->state () | CompAction::StateTermKey); |
590 | |
591 | - annoLastPointerX = pointerX; |
592 | - annoLastPointerY = pointerY; |
593 | + annoLastPointerX = CompGlobal::instance ().pointerX (); |
594 | + annoLastPointerY = CompGlobal::instance ().pointerY (); |
595 | |
596 | drawMode = FreeDrawMode; |
597 | |
598 | @@ -522,8 +522,8 @@ |
599 | if (state & CompAction::StateInitKey) |
600 | action->setState (action->state () | CompAction::StateTermKey); |
601 | |
602 | - initialPointerX = pointerX; |
603 | - initialPointerY = pointerY; |
604 | + initialPointerX = CompGlobal::instance ().pointerX (); |
605 | + initialPointerY = CompGlobal::instance ().pointerY (); |
606 | |
607 | drawMode = LineMode; |
608 | |
609 | @@ -551,8 +551,8 @@ |
610 | |
611 | drawMode = RectangleMode; |
612 | |
613 | - initialPointerX = pointerX; |
614 | - initialPointerY = pointerY; |
615 | + initialPointerX = CompGlobal::instance ().pointerX (); |
616 | + initialPointerY = CompGlobal::instance ().pointerY (); |
617 | rectangle.setGeometry (initialPointerX, initialPointerY, 0, 0); |
618 | lastRect = rectangle; |
619 | |
620 | @@ -580,8 +580,8 @@ |
621 | |
622 | drawMode = EllipseMode; |
623 | |
624 | - initialPointerX = pointerX; |
625 | - initialPointerY = pointerY; |
626 | + initialPointerX = CompGlobal::instance ().pointerX (); |
627 | + initialPointerY = CompGlobal::instance ().pointerY (); |
628 | ellipse.radiusX = 0; |
629 | ellipse.radiusY = 0; |
630 | lastRect.setGeometry (initialPointerX, initialPointerY, 0, 0); |
631 | @@ -884,10 +884,10 @@ |
632 | { |
633 | switch (event->type) { |
634 | case MotionNotify: |
635 | - handleMotionEvent (pointerX, pointerY); |
636 | + handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
637 | case EnterNotify: |
638 | case LeaveNotify: |
639 | - handleMotionEvent (pointerX, pointerY); |
640 | + handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
641 | default: |
642 | if (event->type == cScreen->damageEvent () + XDamageNotify) |
643 | { |
644 | |
645 | === modified file 'plugins/clone/src/clone.cpp' |
646 | --- plugins/clone/src/clone.cpp 2010-02-04 17:16:02 +0000 |
647 | +++ plugins/clone/src/clone.cpp 2012-01-17 16:06:33 +0000 |
648 | @@ -496,14 +496,14 @@ |
649 | { |
650 | case MotionNotify: |
651 | { |
652 | - CompPoint p (pointerX, pointerY); |
653 | + CompPoint p (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
654 | handleMotionEvent (p); |
655 | } |
656 | break; |
657 | case EnterNotify: |
658 | case LeaveNotify: |
659 | { |
660 | - CompPoint p (pointerX, pointerY); |
661 | + CompPoint p (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
662 | handleMotionEvent (p); |
663 | } |
664 | default: |
665 | |
666 | === modified file 'plugins/composite/src/screen.cpp' |
667 | --- plugins/composite/src/screen.cpp 2012-01-12 17:49:40 +0000 |
668 | +++ plugins/composite/src/screen.cpp 2012-01-17 16:06:33 +0000 |
669 | @@ -322,7 +322,7 @@ |
670 | |
671 | if (currentCmSnOwner != None) |
672 | { |
673 | - if (!replaceCurrentWm) |
674 | + if (!CompGlobal::instance ().replaceCurrentWm ()) |
675 | { |
676 | compLogMessage ("composite", CompLogLevelError, |
677 | "Screen %d on display \"%s\" already " |
678 | @@ -648,7 +648,7 @@ |
679 | void |
680 | PrivateCompositeScreen::detectRefreshRate () |
681 | { |
682 | - if (!noDetection && |
683 | + if (!CompGlobal::instance ().noDetection () && |
684 | optionGetDetectRefreshRate ()) |
685 | { |
686 | CompString name; |
687 | |
688 | === modified file 'plugins/move/src/move.cpp' |
689 | --- plugins/move/src/move.cpp 2012-01-09 16:01:47 +0000 |
690 | +++ plugins/move/src/move.cpp 2012-01-17 16:06:33 +0000 |
691 | @@ -96,8 +96,8 @@ |
692 | ms->x = 0; |
693 | ms->y = 0; |
694 | |
695 | - lastPointerX = x; |
696 | - lastPointerY = y; |
697 | + CompGlobal::instance ().setLastPointerX (x); |
698 | + CompGlobal::instance ().setLastPointerY (y); |
699 | |
700 | sourceExternalApp = |
701 | CompOption::getBoolOptionNamed (options, "external", false); |
702 | @@ -141,7 +141,7 @@ |
703 | xRoot = w->geometry ().x () + (w->size ().width () / 2); |
704 | yRoot = w->geometry ().y () + (w->size ().height () / 2); |
705 | |
706 | - s->warpPointer (xRoot - pointerX, yRoot - pointerY); |
707 | + s->warpPointer (xRoot - CompGlobal::instance ().pointerX (), yRoot - CompGlobal::instance ().pointerY ()); |
708 | } |
709 | |
710 | if (ms->moveOpacity != OPAQUE) |
711 | @@ -321,8 +321,8 @@ |
712 | wHeight = w->geometry ().height () + |
713 | w->geometry ().border () * 2; |
714 | |
715 | - ms->x += xRoot - lastPointerX; |
716 | - ms->y += yRoot - lastPointerY; |
717 | + ms->x += xRoot - CompGlobal::instance ().lastPointerX (); |
718 | + ms->y += yRoot - CompGlobal::instance ().lastPointerY (); |
719 | |
720 | if (w->type () & CompWindowTypeFullscreenMask) |
721 | { |
722 | @@ -444,7 +444,7 @@ |
723 | wy = workArea.y () + (w->border ().top >> 1); |
724 | wy += w->sizeHints ().height_inc >> 1; |
725 | |
726 | - s->warpPointer (0, wy - pointerY); |
727 | + s->warpPointer (0, wy - CompGlobal::instance ().pointerY ()); |
728 | |
729 | return; |
730 | } |
731 | @@ -577,12 +577,12 @@ |
732 | break; |
733 | case MotionNotify: |
734 | if (event->xmotion.root == screen->root ()) |
735 | - moveHandleMotionEvent (screen, pointerX, pointerY); |
736 | + moveHandleMotionEvent (screen, CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
737 | break; |
738 | case EnterNotify: |
739 | case LeaveNotify: |
740 | if (event->xcrossing.root == screen->root ()) |
741 | - moveHandleMotionEvent (screen, pointerX, pointerY); |
742 | + moveHandleMotionEvent (screen, CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
743 | break; |
744 | case ClientMessage: |
745 | if (event->xclient.message_type == Atoms::wmMoveResize) |
746 | @@ -616,10 +616,10 @@ |
747 | { |
748 | |
749 | /* TODO: not only button 1 */ |
750 | - if (pointerMods & Button1Mask) |
751 | + if (CompGlobal::instance ().pointerMods () & Button1Mask) |
752 | { |
753 | o.push_back (CompOption ("modifiers", CompOption::TypeInt)); |
754 | - o[2].value ().set ((int) pointerMods); |
755 | + o[2].value ().set ((int) CompGlobal::instance ().pointerMods ()); |
756 | |
757 | o.push_back (CompOption ("x", CompOption::TypeInt)); |
758 | o[3].value ().set ((int) event->xclient.data.l[0]); |
759 | @@ -634,7 +634,7 @@ |
760 | moveInitiate (&optionGetInitiateButton (), |
761 | CompAction::StateInitButton, o); |
762 | |
763 | - moveHandleMotionEvent (screen, pointerX, pointerY); |
764 | + moveHandleMotionEvent (screen, CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
765 | } |
766 | } |
767 | } |
768 | |
769 | === modified file 'plugins/opengl/src/screen.cpp' |
770 | --- plugins/opengl/src/screen.cpp 2012-01-09 15:12:20 +0000 |
771 | +++ plugins/opengl/src/screen.cpp 2012-01-17 16:06:33 +0000 |
772 | @@ -94,7 +94,7 @@ |
773 | const char *glRenderer; |
774 | CompOption::Vector o (0); |
775 | |
776 | - priv->ctx = glXCreateContext (dpy, visinfo, NULL, !indirectRendering); |
777 | + priv->ctx = glXCreateContext (dpy, visinfo, NULL, !CompGlobal::instance ().indirectRendering ()); |
778 | if (!priv->ctx) |
779 | { |
780 | compLogMessage ("opengl", CompLogLevelFatal, |
781 | @@ -298,7 +298,7 @@ |
782 | XWindowAttributes attr; |
783 | CompOption::Vector o (0); |
784 | |
785 | - if (indirectRendering) |
786 | + if (CompGlobal::instance ().indirectRendering ()) |
787 | { |
788 | /* force Mesa libGL into indirect rendering mode, because |
789 | glXQueryExtensionsString is context-independant */ |
790 | @@ -849,9 +849,9 @@ |
791 | if (backgroundTextures.empty ()) |
792 | { |
793 | CompSize size; |
794 | - if (backgroundImage) |
795 | + if (CompGlobal::instance ().backgroundImage ()) |
796 | { |
797 | - CompString fileName (backgroundImage); |
798 | + CompString fileName (CompGlobal::instance ().backgroundImage ()); |
799 | CompString pname (""); |
800 | |
801 | backgroundTextures = GLTexture::readImageToTexture (fileName, pname, size); |
802 | |
803 | === modified file 'plugins/resize/src/resize.cpp' |
804 | --- plugins/resize/src/resize.cpp 2011-08-19 14:25:11 +0000 |
805 | +++ plugins/resize/src/resize.cpp 2012-01-17 16:06:33 +0000 |
806 | @@ -321,8 +321,8 @@ |
807 | |
808 | CompWindow::Geometry server = w->serverGeometry (); |
809 | |
810 | - x = CompOption::getIntOptionNamed (options, "x", pointerX); |
811 | - y = CompOption::getIntOptionNamed (options, "y", pointerY); |
812 | + x = CompOption::getIntOptionNamed (options, "x", CompGlobal::instance ().pointerX ()); |
813 | + y = CompOption::getIntOptionNamed (options, "y", CompGlobal::instance ().pointerY ()); |
814 | |
815 | button = CompOption::getIntOptionNamed (options, "button", -1); |
816 | |
817 | @@ -391,8 +391,8 @@ |
818 | |
819 | rs->geometry = rs->savedGeometry; |
820 | |
821 | - rs->pointerDx = x - pointerX; |
822 | - rs->pointerDy = y - pointerY; |
823 | + rs->pointerDx = x - CompGlobal::instance ().pointerX (); |
824 | + rs->pointerDy = y - CompGlobal::instance ().pointerY (); |
825 | |
826 | rs->centered |= rs->optionGetResizeFromCenterMatch ().evaluate (w); |
827 | |
828 | @@ -469,7 +469,7 @@ |
829 | xRoot = server.x () + (server.width () / 2); |
830 | yRoot = server.y () + (server.height () / 2); |
831 | |
832 | - screen->warpPointer (xRoot - pointerX, yRoot - pointerY); |
833 | + screen->warpPointer (xRoot - CompGlobal::instance ().pointerX (), yRoot - CompGlobal::instance ().pointerY ()); |
834 | } |
835 | |
836 | rs->isConstrained = sourceExternalApp; |
837 | @@ -726,7 +726,7 @@ |
838 | x = left + width * (rKeys[i].dx + 1) / 2; |
839 | y = top + height * (rKeys[i].dy + 1) / 2; |
840 | |
841 | - screen->warpPointer (x - pointerX, y - pointerY); |
842 | + screen->warpPointer (x - CompGlobal::instance ().pointerX (), y - CompGlobal::instance ().pointerY ()); |
843 | |
844 | mask = rKeys[i].resizeMask; |
845 | |
846 | @@ -830,13 +830,13 @@ |
847 | |
848 | if (centered || optionGetResizeFromCenter ()) |
849 | { |
850 | - pointerDx += (xRoot - lastPointerX) * 2; |
851 | - pointerDy += (yRoot - lastPointerY) * 2; |
852 | + pointerDx += (xRoot - CompGlobal::instance ().lastPointerX ()) * 2; |
853 | + pointerDy += (yRoot - CompGlobal::instance ().lastPointerY ()) * 2; |
854 | } |
855 | else |
856 | { |
857 | - pointerDx += xRoot - lastPointerX; |
858 | - pointerDy += yRoot - lastPointerY; |
859 | + pointerDx += xRoot - CompGlobal::instance ().lastPointerX (); |
860 | + pointerDy += yRoot - CompGlobal::instance ().lastPointerY (); |
861 | } |
862 | |
863 | /* If we hit the edge of the screen while resizing |
864 | @@ -852,25 +852,25 @@ |
865 | { |
866 | if (xRoot == 0 && |
867 | geometry.x - w->border ().left > grabWindowWorkArea->left ()) |
868 | - pointerDx += abs (yRoot - lastPointerY) * -1; |
869 | + pointerDx += abs (yRoot - CompGlobal::instance ().lastPointerY ()) * -1; |
870 | } |
871 | else if (mask == ResizeRightMask) |
872 | { |
873 | if (xRoot == screen->width () -1 && |
874 | geometry.x + geometry.width + w->border ().right < grabWindowWorkArea->right ()) |
875 | - pointerDx += abs (yRoot - lastPointerY); |
876 | + pointerDx += abs (yRoot - CompGlobal::instance ().lastPointerY ()); |
877 | } |
878 | if (mask == ResizeUpMask) |
879 | { |
880 | if (yRoot == 0 && |
881 | geometry.y - w->border ().top > grabWindowWorkArea->top ()) |
882 | - pointerDy += abs (xRoot - lastPointerX) * -1; |
883 | + pointerDy += abs (xRoot - CompGlobal::instance ().lastPointerX ()) * -1; |
884 | } |
885 | else if (mask == ResizeDownMask) |
886 | { |
887 | if (yRoot == screen->height () -1 && |
888 | geometry.y + geometry.height + w->border ().bottom < grabWindowWorkArea->bottom ()) |
889 | - pointerDx += abs (yRoot - lastPointerY); |
890 | + pointerDx += abs (yRoot - CompGlobal::instance ().lastPointerY ()); |
891 | } |
892 | } |
893 | } |
894 | @@ -1268,12 +1268,12 @@ |
895 | break; |
896 | case MotionNotify: |
897 | if (event->xmotion.root == screen->root ()) |
898 | - handleMotionEvent (pointerX, pointerY); |
899 | + handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
900 | break; |
901 | case EnterNotify: |
902 | case LeaveNotify: |
903 | if (event->xcrossing.root == screen->root ()) |
904 | - handleMotionEvent (pointerX, pointerY); |
905 | + handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
906 | break; |
907 | case ClientMessage: |
908 | if (event->xclient.message_type == Atoms::wmMoveResize) |
909 | @@ -1319,7 +1319,7 @@ |
910 | }; |
911 | |
912 | /* TODO: not only button 1 */ |
913 | - if (pointerMods & Button1Mask) |
914 | + if (CompGlobal::instance ().pointerMods () & Button1Mask) |
915 | { |
916 | o.push_back (CompOption ("modifiers", |
917 | CompOption::TypeInt)); |
918 | @@ -1332,7 +1332,7 @@ |
919 | o.push_back (CompOption ("button", |
920 | CompOption::TypeInt)); |
921 | |
922 | - o[2].value ().set ((int) pointerMods); |
923 | + o[2].value ().set ((int) CompGlobal::instance ().pointerMods ()); |
924 | o[3].value ().set |
925 | ((int) event->xclient.data.l[0]); |
926 | o[4].value ().set |
927 | @@ -1348,7 +1348,7 @@ |
928 | CompAction::StateInitButton, o); |
929 | |
930 | ResizeScreen::get (screen)-> |
931 | - handleMotionEvent (pointerX, pointerY); |
932 | + handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
933 | } |
934 | } |
935 | } |
936 | |
937 | === modified file 'plugins/rotate/src/rotate.cpp' |
938 | --- plugins/rotate/src/rotate.cpp 2010-12-23 03:57:46 +0000 |
939 | +++ plugins/rotate/src/rotate.cpp 2012-01-17 16:06:33 +0000 |
940 | @@ -606,12 +606,12 @@ |
941 | if (screen->otherGrabExist ("rotate", "move", "group-drag", NULL)) |
942 | return false; |
943 | |
944 | - warpX = pointerX - (screen->width () * direction); |
945 | + warpX = CompGlobal::instance ().pointerX () - (screen->width () * direction); |
946 | if (direction == -1) |
947 | screen->warpPointer (screen->width () - 10, 0); |
948 | else |
949 | screen->warpPointer (10 - screen->width (), 0); |
950 | - lastPointerX = warpX; |
951 | + CompGlobal::instance ().setLastPointerX (warpX); |
952 | |
953 | o.push_back (CompOption ("root", CompOption::TypeInt)); |
954 | o.push_back (CompOption ("x", CompOption::TypeInt)); |
955 | @@ -619,12 +619,12 @@ |
956 | |
957 | o[0].value ().set ((int) screen->root ()); |
958 | o[1].value ().set (0); |
959 | - o[2].value ().set (pointerY); |
960 | + o[2].value ().set (CompGlobal::instance ().pointerY ()); |
961 | |
962 | rotate (NULL, 0, o, direction); |
963 | |
964 | XWarpPointer (screen->dpy (), None, None, 0, 0, 0, 0, direction, 0); |
965 | - mSavedPointer.setX (lastPointerX + (9 * direction)); |
966 | + mSavedPointer.setX (CompGlobal::instance ().lastPointerX () + (9 * direction)); |
967 | |
968 | return false; |
969 | } |
970 | @@ -690,28 +690,28 @@ |
971 | |
972 | if (optionGetFlipTime () == 0 || (mMoving && !mSlow)) |
973 | { |
974 | - int pointerDx = pointerX - lastPointerX; |
975 | + int pointerDx = CompGlobal::instance ().pointerX () - CompGlobal::instance ().lastPointerX (); |
976 | int warpX; |
977 | |
978 | if (direction == -1) |
979 | { |
980 | - warpX = pointerX + screen->width (); |
981 | + warpX = CompGlobal::instance ().pointerX () + screen->width (); |
982 | screen->warpPointer (screen->width () - 10, 0); |
983 | - lastPointerX = warpX - pointerDx; |
984 | + CompGlobal::instance ().setLastPointerX (warpX - pointerDx); |
985 | rotate (NULL, 0, o, direction); |
986 | |
987 | XWarpPointer (screen->dpy (), None, None, 0, 0, 0, 0, -1, 0); |
988 | - mSavedPointer.setX (lastPointerX - 9); |
989 | + mSavedPointer.setX (CompGlobal::instance ().lastPointerX () - 9); |
990 | } |
991 | else |
992 | { |
993 | - warpX = pointerX - screen->width (); |
994 | + warpX = CompGlobal::instance ().pointerX () - screen->width (); |
995 | screen->warpPointer (10 - screen->width (), 0); |
996 | - lastPointerX = warpX - pointerDx; |
997 | + CompGlobal::instance ().setLastPointerX (warpX - pointerDx); |
998 | rotate (NULL, 0, o, direction); |
999 | |
1000 | XWarpPointer (screen->dpy (), None, None, 0, 0, 0, 0, 1, 0); |
1001 | - mSavedPointer.setX (lastPointerX + 9); |
1002 | + mSavedPointer.setX (CompGlobal::instance ().lastPointerX () + 9); |
1003 | } |
1004 | |
1005 | } |
1006 | @@ -807,8 +807,8 @@ |
1007 | o.push_back (CompOption ("y", CompOption::TypeInt)); |
1008 | |
1009 | o[0].value ().set ((int) screen->root ()); |
1010 | - o[1].value ().set (CompOption::getIntOptionNamed (options, "x", pointerX)); |
1011 | - o[2].value ().set (CompOption::getIntOptionNamed (options, "y", pointerY)); |
1012 | + o[1].value ().set (CompOption::getIntOptionNamed (options, "x", CompGlobal::instance ().pointerX ())); |
1013 | + o[2].value ().set (CompOption::getIntOptionNamed (options, "y", CompGlobal::instance ().pointerY ())); |
1014 | |
1015 | if (withWindow) |
1016 | { |
1017 | @@ -835,16 +835,16 @@ |
1018 | { |
1019 | GLfloat pointerDx, pointerDy; |
1020 | |
1021 | - pointerDx = pointerX - lastPointerX; |
1022 | - pointerDy = pointerY - lastPointerY; |
1023 | + pointerDx = CompGlobal::instance ().pointerX () - CompGlobal::instance ().lastPointerX (); |
1024 | + pointerDy = CompGlobal::instance ().pointerY () - CompGlobal::instance ().lastPointerY (); |
1025 | |
1026 | if (event->xmotion.x_root < 50 || |
1027 | event->xmotion.y_root < 50 || |
1028 | event->xmotion.x_root > screen->width () - 50 || |
1029 | event->xmotion.y_root > screen->height () - 50) |
1030 | { |
1031 | - screen->warpPointer ((screen->width () / 2) - pointerX, |
1032 | - (screen->height () / 2) - pointerY); |
1033 | + screen->warpPointer ((screen->width () / 2) - CompGlobal::instance ().pointerX (), |
1034 | + (screen->height () / 2) - CompGlobal::instance ().pointerY ()); |
1035 | } |
1036 | |
1037 | if (optionGetInvertY ()) |
1038 | @@ -858,8 +858,8 @@ |
1039 | } |
1040 | else |
1041 | { |
1042 | - mSavedPointer.setX (mSavedPointer.x () + pointerX - lastPointerX); |
1043 | - mSavedPointer.setY (mSavedPointer.y () + pointerY - lastPointerY); |
1044 | + mSavedPointer.setX (mSavedPointer.x () + CompGlobal::instance ().pointerX () - CompGlobal::instance ().lastPointerX ()); |
1045 | + mSavedPointer.setY (mSavedPointer.y () + CompGlobal::instance ().pointerY () - CompGlobal::instance ().lastPointerY ()); |
1046 | } |
1047 | } |
1048 | } |
1049 | |
1050 | === modified file 'plugins/scale/src/scale.cpp' |
1051 | --- plugins/scale/src/scale.cpp 2012-01-12 17:49:40 +0000 |
1052 | +++ plugins/scale/src/scale.cpp 2012-01-17 16:06:33 +0000 |
1053 | @@ -1598,7 +1598,7 @@ |
1054 | state != ScaleScreen::In && |
1055 | w->id () == dndTarget) |
1056 | { |
1057 | - ScaleWindow *sw = checkForWindowAt (pointerX, pointerY); |
1058 | + ScaleWindow *sw = checkForWindowAt (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
1059 | if (sw && sw->priv->isScaleWin ()) |
1060 | { |
1061 | int time; |
1062 | @@ -1607,7 +1607,7 @@ |
1063 | |
1064 | if (hover.active ()) |
1065 | { |
1066 | - int lastMotion = sqrt (pow (pointerX - lastPointerX, 2) + pow (pointerY - lastPointerY, 2)); |
1067 | + int lastMotion = sqrt (pow (CompGlobal::instance ().pointerX () - CompGlobal::instance ().lastPointerX (), 2) + pow (CompGlobal::instance ().pointerY () - CompGlobal::instance ().lastPointerY (), 2)); |
1068 | |
1069 | if (sw->window->id () != selectedWindow || lastMotion > optionGetDndDistance ()) |
1070 | hover.stop (); |
1071 | @@ -1618,7 +1618,7 @@ |
1072 | hover.start (time, (float) time * 1.2); |
1073 | } |
1074 | |
1075 | - selectWindowAt (pointerX, pointerY, focus); |
1076 | + selectWindowAt (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY (), focus); |
1077 | } |
1078 | else |
1079 | { |
1080 | |
1081 | === modified file 'plugins/screenshot/src/screenshot.cpp' |
1082 | --- plugins/screenshot/src/screenshot.cpp 2010-12-07 03:14:59 +0000 |
1083 | +++ plugins/screenshot/src/screenshot.cpp 2012-01-17 16:06:33 +0000 |
1084 | @@ -53,8 +53,8 @@ |
1085 | |
1086 | /* start selection screenshot rectangle */ |
1087 | |
1088 | - mX1 = mX2 = pointerX; |
1089 | - mY1 = mY2 = pointerY; |
1090 | + mX1 = mX2 = CompGlobal::instance ().pointerX (); |
1091 | + mY1 = mY2 = CompGlobal::instance ().pointerY (); |
1092 | |
1093 | mGrab = true; |
1094 | |
1095 | @@ -321,12 +321,12 @@ |
1096 | switch (event->type) { |
1097 | case MotionNotify: |
1098 | if (event->xmotion.root == screen->root ()) |
1099 | - handleMotionEvent (pointerX, pointerY); |
1100 | + handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
1101 | break; |
1102 | case EnterNotify: |
1103 | case LeaveNotify: |
1104 | if (event->xcrossing.root == screen->root ()) |
1105 | - handleMotionEvent (pointerX, pointerY); |
1106 | + handleMotionEvent (CompGlobal::instance ().pointerX (), CompGlobal::instance ().pointerY ()); |
1107 | default: |
1108 | break; |
1109 | } |
1110 | |
1111 | === modified file 'plugins/switcher/src/switcher.cpp' |
1112 | --- plugins/switcher/src/switcher.cpp 2011-03-11 18:13:44 +0000 |
1113 | +++ plugins/switcher/src/switcher.cpp 2012-01-17 16:06:33 +0000 |
1114 | @@ -265,7 +265,8 @@ |
1115 | CWBackPixel | CWBorderPixel | CWColormap | CWOverrideRedirect, &attr); |
1116 | |
1117 | XSetWMProperties (dpy, popupWindow, NULL, NULL, |
1118 | - programArgv, programArgc, |
1119 | + CompGlobal::instance ().programArgv (), |
1120 | + CompGlobal::instance ().programArgc (), |
1121 | &xsh, &xwmh, &xch); |
1122 | |
1123 | state[nState++] = Atoms::winStateAbove; |
1124 | |
1125 | === modified file 'plugins/water/src/water.cpp' |
1126 | --- plugins/water/src/water.cpp 2011-03-14 16:12:45 +0000 |
1127 | +++ plugins/water/src/water.cpp 2012-01-17 16:06:33 +0000 |
1128 | @@ -1019,8 +1019,8 @@ |
1129 | p[0].x = waterLastPointerX; |
1130 | p[0].y = waterLastPointerY; |
1131 | |
1132 | - p[1].x = waterLastPointerX = pointerX; |
1133 | - p[1].y = waterLastPointerY = pointerY; |
1134 | + p[1].x = waterLastPointerX = CompGlobal::instance ().pointerX (); |
1135 | + p[1].y = waterLastPointerY = CompGlobal::instance ().pointerY (); |
1136 | |
1137 | waterVertices (GL_LINES, p, 2, 0.2f); |
1138 | |
1139 | @@ -1225,8 +1225,8 @@ |
1140 | { |
1141 | XPoint p; |
1142 | |
1143 | - p.x = pointerX; |
1144 | - p.y = pointerY; |
1145 | + p.x = CompGlobal::instance ().pointerX (); |
1146 | + p.y = CompGlobal::instance ().pointerY (); |
1147 | |
1148 | waterVertices (GL_POINTS, &p, 1, 0.8f); |
1149 | cScreen->damageScreen (); |
1150 | |
1151 | === modified file 'plugins/wobbly/src/wobbly.cpp' |
1152 | --- plugins/wobbly/src/wobbly.cpp 2011-03-14 16:12:45 +0000 |
1153 | +++ plugins/wobbly/src/wobbly.cpp 2012-01-17 16:06:33 +0000 |
1154 | @@ -1860,12 +1860,12 @@ |
1155 | int dx, dy; |
1156 | |
1157 | if (ww->state & CompWindowStateMaximizedHorzMask) |
1158 | - dx = pointerX - lastPointerX; |
1159 | + dx = CompGlobal::instance ().pointerX () - CompGlobal::instance ().lastPointerX (); |
1160 | else |
1161 | dx = 0; |
1162 | |
1163 | if (ww->state & CompWindowStateMaximizedVertMask) |
1164 | - dy = pointerY - lastPointerY; |
1165 | + dy = CompGlobal::instance ().pointerY () - CompGlobal::instance ().lastPointerY (); |
1166 | else |
1167 | dy = 0; |
1168 | |
1169 | @@ -2070,8 +2070,8 @@ |
1170 | if (model->anchorObject) |
1171 | model->anchorObject->immobile = false; |
1172 | |
1173 | - model->anchorObject = model->findNearestObject (pointerX, |
1174 | - pointerY); |
1175 | + model->anchorObject = model->findNearestObject (CompGlobal::instance ().pointerX (), |
1176 | + CompGlobal::instance ().pointerY ()); |
1177 | model->anchorObject->immobile = true; |
1178 | |
1179 | model->adjustObjectPosition (model->anchorObject, |
1180 | |
1181 | === modified file 'plugins/zoom/src/zoom.cpp' |
1182 | --- plugins/zoom/src/zoom.cpp 2010-02-04 17:16:02 +0000 |
1183 | +++ plugins/zoom/src/zoom.cpp 2012-01-17 16:06:33 +0000 |
1184 | @@ -348,7 +348,7 @@ |
1185 | |
1186 | ZOOM_SCREEN (screen); |
1187 | |
1188 | - output = screen->outputDeviceForPoint (pointerX, pointerY); |
1189 | + output = screen->outputDeviceForPoint (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY()); |
1190 | |
1191 | if (!zs->grabIndex) |
1192 | { |
1193 | @@ -371,9 +371,9 @@ |
1194 | w = (box.x2 - box.x1) / zs->optionGetZoomFactor (); |
1195 | h = (box.y2 - box.y1) / zs->optionGetZoomFactor (); |
1196 | |
1197 | - x0 = (pointerX - screen->outputDevs ()[output].x1 ()) / (float) |
1198 | + x0 = (CompGlobal::instance ().pointerX() - screen->outputDevs ()[output].x1 ()) / (float) |
1199 | screen->outputDevs ()[output].width (); |
1200 | - y0 = (pointerY - screen->outputDevs ()[output].y1 ()) / (float) |
1201 | + y0 = (CompGlobal::instance ().pointerY() - screen->outputDevs ()[output].y1 ()) / (float) |
1202 | screen->outputDevs ()[output].height (); |
1203 | |
1204 | zs->x1 = box.x1 + (x0 * (box.x2 - box.x1) - x0 * w + 0.5f); |
1205 | @@ -410,7 +410,7 @@ |
1206 | |
1207 | /* start selection zoom rectangle */ |
1208 | |
1209 | - output = screen->outputDeviceForPoint (pointerX, pointerY); |
1210 | + output = screen->outputDeviceForPoint (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY()); |
1211 | |
1212 | if (zs->zoomed & (1 << output)) |
1213 | { |
1214 | @@ -433,10 +433,10 @@ |
1215 | } |
1216 | |
1217 | zs->x1 = zs->x2 = x1 + |
1218 | - ((pointerX - screen->outputDevs ()[output].x1 ()) / |
1219 | + ((CompGlobal::instance ().pointerX() - screen->outputDevs ()[output].x1 ()) / |
1220 | scale + 0.5f); |
1221 | zs->y1 = zs->y2 = y1 + |
1222 | - ((pointerY - screen->outputDevs ()[output].y1 ()) / |
1223 | + ((CompGlobal::instance ().pointerY() - screen->outputDevs ()[output].y1 ()) / |
1224 | scale + 0.5f); |
1225 | |
1226 | zs->zoomOutput = output; |
1227 | @@ -458,7 +458,7 @@ |
1228 | |
1229 | ZOOM_SCREEN (screen); |
1230 | |
1231 | - output = screen->outputDeviceForPoint (pointerX, pointerY); |
1232 | + output = screen->outputDeviceForPoint (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY()); |
1233 | |
1234 | zs->getCurrentZoom (output, &zs->last[output]); |
1235 | |
1236 | @@ -526,7 +526,7 @@ |
1237 | |
1238 | ZOOM_SCREEN (screen); |
1239 | |
1240 | - output = screen->outputDeviceForPoint (pointerX, pointerY); |
1241 | + output = screen->outputDeviceForPoint (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY()); |
1242 | |
1243 | if (!(zs->zoomed & (1 << output))) |
1244 | return false; |
1245 | @@ -610,8 +610,8 @@ |
1246 | { |
1247 | float dx, dy; |
1248 | |
1249 | - dx = (xRoot - lastPointerX) / scale; |
1250 | - dy = (yRoot - lastPointerY) / scale; |
1251 | + dx = (xRoot - CompGlobal::instance ().lastPointerX ()) / scale; |
1252 | + dy = (yRoot - CompGlobal::instance ().lastPointerY ()) / scale; |
1253 | |
1254 | box.x1 -= dx; |
1255 | box.y1 -= dy; |
1256 | @@ -677,12 +677,12 @@ |
1257 | switch (event->type) { |
1258 | case MotionNotify: |
1259 | if (event->xmotion.root == screen->root ()) |
1260 | - handleMotionEvent (pointerX, pointerY); |
1261 | + handleMotionEvent (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY()); |
1262 | break; |
1263 | case EnterNotify: |
1264 | case LeaveNotify: |
1265 | if (event->xcrossing.root == screen->root ()) |
1266 | - handleMotionEvent (pointerX, pointerY); |
1267 | + handleMotionEvent (CompGlobal::instance ().pointerX(), CompGlobal::instance ().pointerY()); |
1268 | default: |
1269 | break; |
1270 | } |
1271 | |
1272 | === modified file 'src/CMakeLists.txt' |
1273 | --- src/CMakeLists.txt 2012-01-12 13:44:07 +0000 |
1274 | +++ src/CMakeLists.txt 2012-01-17 16:06:33 +0000 |
1275 | @@ -59,10 +59,9 @@ |
1276 | ${CORE_MOD_LIBRARY_DIRS} |
1277 | ) |
1278 | |
1279 | -add_executable (compiz |
1280 | - ${CMAKE_CURRENT_SOURCE_DIR}/region.cpp |
1281 | +add_library (compiz_core |
1282 | + ${CMAKE_CURRENT_SOURCE_DIR}/region.cpp |
1283 | ${CMAKE_CURRENT_SOURCE_DIR}/atoms.cpp |
1284 | - ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp |
1285 | ${CMAKE_CURRENT_SOURCE_DIR}/actions.cpp |
1286 | ${CMAKE_CURRENT_SOURCE_DIR}/screen.cpp |
1287 | ${CMAKE_CURRENT_SOURCE_DIR}/window.cpp |
1288 | @@ -86,6 +85,10 @@ |
1289 | ${_bcop_sources} |
1290 | ) |
1291 | |
1292 | +add_executable (compiz |
1293 | + ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp |
1294 | +) |
1295 | + |
1296 | # workaround for build race |
1297 | add_dependencies (compiz core-xml-file) |
1298 | |
1299 | @@ -94,17 +97,33 @@ |
1300 | PROPERTY CORE_MOD_LIBRARIES) |
1301 | |
1302 | target_link_libraries ( |
1303 | - compiz ${COMPIZ_LIBRARIES} |
1304 | - |
1305 | - m |
1306 | - pthread |
1307 | - dl |
1308 | - |
1309 | - compiz_string |
1310 | - compiz_timer |
1311 | - compiz_logmessage |
1312 | - compiz_pluginclasshandler |
1313 | -# ${CORE_MOD_LIBRARIES} |
1314 | + compiz_core |
1315 | + |
1316 | + ${COMPIZ_LIBRARIES} |
1317 | + |
1318 | + m |
1319 | + pthread |
1320 | + dl |
1321 | + |
1322 | + compiz_string |
1323 | + compiz_timer |
1324 | + compiz_logmessage |
1325 | + compiz_pluginclasshandler |
1326 | +) |
1327 | + |
1328 | +target_link_libraries ( |
1329 | + compiz |
1330 | + compiz_core |
1331 | + ${COMPIZ_LIBRARIES} |
1332 | + |
1333 | + m |
1334 | + pthread |
1335 | + dl |
1336 | + |
1337 | + compiz_string |
1338 | + compiz_timer |
1339 | + compiz_logmessage |
1340 | + compiz_pluginclasshandler |
1341 | ) |
1342 | |
1343 | install ( |
1344 | @@ -112,4 +131,6 @@ |
1345 | DESTINATION ${COMPIZ_DESTDIR}${exec_prefix} |
1346 | ) |
1347 | |
1348 | +add_subdirectory(tests) |
1349 | + |
1350 | enable_coverage_report( TARGETS compiz ) |
1351 | |
1352 | === modified file 'src/action.cpp' |
1353 | --- src/action.cpp 2011-10-31 13:51:00 +0000 |
1354 | +++ src/action.cpp 2012-01-17 16:06:33 +0000 |
1355 | @@ -455,7 +455,7 @@ |
1356 | } |
1357 | |
1358 | bool |
1359 | -CompAction::operator== (const CompAction& val) |
1360 | +CompAction::operator== (const CompAction& val) const |
1361 | { |
1362 | if (priv->state != val.priv->state) |
1363 | return false; |
1364 | |
1365 | === modified file 'src/event.cpp' |
1366 | --- src/event.cpp 2012-01-12 17:49:40 +0000 |
1367 | +++ src/event.cpp 2012-01-17 16:06:33 +0000 |
1368 | @@ -142,7 +142,7 @@ |
1369 | { |
1370 | CompAction::State state = CompAction::StateInitButton; |
1371 | CompAction *action; |
1372 | - unsigned int ignored = modHandler->ignoredModMask (); |
1373 | + unsigned int ignored = CompGlobal::instance ().modHandler ()->ignoredModMask (); |
1374 | unsigned int modMask = REAL_MOD_MASK & ~ignored; |
1375 | unsigned int bindMods; |
1376 | unsigned int edge = 0; |
1377 | @@ -178,7 +178,7 @@ |
1378 | { |
1379 | if (action->button ().button () == (int) event->button) |
1380 | { |
1381 | - bindMods = modHandler->virtualToRealModMask ( |
1382 | + bindMods = CompGlobal::instance ().modHandler ()->virtualToRealModMask ( |
1383 | action->button ().modifiers ()); |
1384 | |
1385 | if ((bindMods & modMask) == (event->state & modMask)) |
1386 | @@ -197,7 +197,7 @@ |
1387 | if ((action->button ().button () == (int) event->button) && |
1388 | (action->edgeMask () & edge)) |
1389 | { |
1390 | - bindMods = modHandler->virtualToRealModMask ( |
1391 | + bindMods = CompGlobal::instance ().modHandler ()->virtualToRealModMask ( |
1392 | action->button ().modifiers ()); |
1393 | |
1394 | if ((bindMods & modMask) == (event->state & modMask)) |
1395 | @@ -245,7 +245,7 @@ |
1396 | { |
1397 | CompAction::State state = 0; |
1398 | CompAction *action; |
1399 | - unsigned int modMask = REAL_MOD_MASK & ~modHandler->ignoredModMask (); |
1400 | + unsigned int modMask = REAL_MOD_MASK & ~CompGlobal::instance ().modHandler ()->ignoredModMask (); |
1401 | unsigned int bindMods; |
1402 | |
1403 | if (event->keycode == escapeKeyCode) |
1404 | @@ -275,7 +275,7 @@ |
1405 | if (isInitiateBinding (option, CompAction::BindingTypeKey, |
1406 | state, &action)) |
1407 | { |
1408 | - bindMods = modHandler->virtualToRealModMask ( |
1409 | + bindMods = CompGlobal::instance ().modHandler ()->virtualToRealModMask ( |
1410 | action->key ().modifiers ()); |
1411 | |
1412 | if (action->key ().keycode () == (int) event->keycode) |
1413 | @@ -303,12 +303,12 @@ |
1414 | { |
1415 | CompAction::State state = CompAction::StateTermKey; |
1416 | CompAction *action; |
1417 | - unsigned int ignored = modHandler->ignoredModMask (); |
1418 | + unsigned int ignored = CompGlobal::instance ().modHandler ()->ignoredModMask (); |
1419 | unsigned int modMask = REAL_MOD_MASK & ~ignored; |
1420 | unsigned int bindMods; |
1421 | unsigned int mods; |
1422 | |
1423 | - mods = modHandler->keycodeToModifiers (event->keycode); |
1424 | + mods = CompGlobal::instance ().modHandler ()->keycodeToModifiers (event->keycode); |
1425 | if (!xkbEvent && !mods) |
1426 | return false; |
1427 | |
1428 | @@ -317,7 +317,7 @@ |
1429 | if (isTerminateBinding (option, CompAction::BindingTypeKey, |
1430 | state, &action)) |
1431 | { |
1432 | - bindMods = modHandler->virtualToRealModMask (action->key ().modifiers ()); |
1433 | + bindMods = CompGlobal::instance ().modHandler ()->virtualToRealModMask (action->key ().modifiers ()); |
1434 | |
1435 | if ((bindMods & modMask) == 0) |
1436 | { |
1437 | @@ -346,7 +346,7 @@ |
1438 | { |
1439 | CompAction::State state; |
1440 | CompAction *action; |
1441 | - unsigned int ignored = modHandler->ignoredModMask (); |
1442 | + unsigned int ignored = CompGlobal::instance ().modHandler ()->ignoredModMask (); |
1443 | unsigned int modMask = REAL_MOD_MASK & ~ignored; |
1444 | unsigned int bindMods; |
1445 | |
1446 | @@ -362,7 +362,7 @@ |
1447 | if (action->key ().keycode () == 0) |
1448 | { |
1449 | bindMods = |
1450 | - modHandler->virtualToRealModMask (action->key ().modifiers ()); |
1451 | + CompGlobal::instance ().modHandler ()->virtualToRealModMask (action->key ().modifiers ()); |
1452 | |
1453 | if ((event->mods & modMask & bindMods) == bindMods) |
1454 | { |
1455 | @@ -382,7 +382,7 @@ |
1456 | if (isTerminateBinding (option, CompAction::BindingTypeKey, |
1457 | state, &action)) |
1458 | { |
1459 | - bindMods = modHandler->virtualToRealModMask (action->key ().modifiers ()); |
1460 | + bindMods = CompGlobal::instance ().modHandler ()->virtualToRealModMask (action->key ().modifiers ()); |
1461 | |
1462 | if ((event->mods & modMask & bindMods) != bindMods) |
1463 | { |
1464 | @@ -1710,7 +1710,7 @@ |
1465 | } |
1466 | break; |
1467 | case MappingNotify: |
1468 | - modHandler->updateModifierMappings (); |
1469 | + CompGlobal::instance ().modHandler ()->updateModifierMappings (); |
1470 | break; |
1471 | case MapRequest: |
1472 | w = screen->findWindow (event->xmaprequest.window); |
1473 | |
1474 | === modified file 'src/eventsource.cpp' |
1475 | --- src/eventsource.cpp 2011-08-19 14:25:11 +0000 |
1476 | +++ src/eventsource.cpp 2012-01-17 16:06:33 +0000 |
1477 | @@ -62,7 +62,7 @@ |
1478 | bool |
1479 | CompEventSource::callback () |
1480 | { |
1481 | - if (restartSignal || shutDown) |
1482 | + if (CompGlobal::instance ().restartSignal () || CompGlobal::instance ().shutDown ()) |
1483 | { |
1484 | screen->priv->mainloop->quit (); |
1485 | return false; |
1486 | |
1487 | === modified file 'src/logmessage/src/logmessage.cpp' |
1488 | --- src/logmessage/src/logmessage.cpp 2011-12-19 07:06:22 +0000 |
1489 | +++ src/logmessage/src/logmessage.cpp 2012-01-17 16:06:33 +0000 |
1490 | @@ -56,11 +56,11 @@ |
1491 | CompLogLevel level, |
1492 | const char *message) |
1493 | { |
1494 | - if (!debugOutput && level >= CompLogLevelDebug) |
1495 | + if (!CompGlobal::instance ().isDebugOutput () && level >= CompLogLevelDebug) |
1496 | return; |
1497 | |
1498 | fprintf (stderr, "%s (%s) - %s: %s\n", |
1499 | - programName, componentName, |
1500 | + CompGlobal::instance ().programName (), componentName, |
1501 | logLevelToString (level), message); |
1502 | } |
1503 | |
1504 | |
1505 | === modified file 'src/main.cpp' |
1506 | --- src/main.cpp 2011-10-31 13:51:00 +0000 |
1507 | +++ src/main.cpp 2012-01-17 16:06:33 +0000 |
1508 | @@ -38,26 +38,7 @@ |
1509 | #include "privatescreen.h" |
1510 | #include "privatestackdebugger.h" |
1511 | |
1512 | -char *programName; |
1513 | -char **programArgv; |
1514 | -int programArgc; |
1515 | - |
1516 | -char *backgroundImage = NULL; |
1517 | - |
1518 | -bool shutDown = false; |
1519 | -bool restartSignal = false; |
1520 | - |
1521 | -CompWindow *lastFoundWindow = 0; |
1522 | - |
1523 | -bool replaceCurrentWm = false; |
1524 | -bool indirectRendering = false; |
1525 | -bool noDetection = false; |
1526 | -bool useDesktopHints = false; |
1527 | -bool debugOutput = false; |
1528 | -bool useCow = true; |
1529 | - |
1530 | -std::list <CompString> initialPlugins; |
1531 | - |
1532 | +bool useCow = false; |
1533 | unsigned int pluginClassHandlerIndex = 0; |
1534 | |
1535 | void |
1536 | @@ -77,7 +58,7 @@ |
1537 | "[--version] " |
1538 | "[--help] " |
1539 | "[PLUGIN]...\n", |
1540 | - programName); |
1541 | + CompGlobal::instance ().programName ()); |
1542 | } |
1543 | |
1544 | static void |
1545 | @@ -90,11 +71,11 @@ |
1546 | waitpid (-1, &status, WNOHANG | WUNTRACED); |
1547 | break; |
1548 | case SIGHUP: |
1549 | - restartSignal = true; |
1550 | + CompGlobal::instance ().setRestartSignal (true); |
1551 | break; |
1552 | case SIGINT: |
1553 | case SIGTERM: |
1554 | - shutDown = true; |
1555 | + CompGlobal::instance ().setShutDown (true); |
1556 | default: |
1557 | break; |
1558 | } |
1559 | @@ -117,7 +98,7 @@ |
1560 | } |
1561 | else if (!strcmp (argv[i], "--debug")) |
1562 | { |
1563 | - debugOutput = true; |
1564 | + CompGlobal::instance ().setDebugOutput (true); |
1565 | } |
1566 | else if (!strcmp (argv[i], "--display")) |
1567 | { |
1568 | @@ -126,11 +107,11 @@ |
1569 | } |
1570 | else if (!strcmp (argv[i], "--indirect-rendering")) |
1571 | { |
1572 | - indirectRendering = true; |
1573 | + CompGlobal::instance ().setIndirectRendering (true); |
1574 | } |
1575 | else if (!strcmp (argv[i], "--keep-desktop-hints")) |
1576 | { |
1577 | - useDesktopHints = true; |
1578 | + CompGlobal::instance ().setUseDesktopHints(true); |
1579 | } |
1580 | else if (!strcmp (argv[i], "--use-root-window")) |
1581 | { |
1582 | @@ -138,7 +119,7 @@ |
1583 | } |
1584 | else if (!strcmp (argv[i], "--replace")) |
1585 | { |
1586 | - replaceCurrentWm = true; |
1587 | + CompGlobal::instance ().setReplaceCurrentWm (true); |
1588 | } |
1589 | else if (!strcmp (argv[i], "--sm-disable")) |
1590 | { |
1591 | @@ -151,12 +132,12 @@ |
1592 | } |
1593 | else if (!strcmp (argv[i], "--no-detection")) |
1594 | { |
1595 | - noDetection = true; |
1596 | + CompGlobal::instance ().setNoDetection (true); |
1597 | } |
1598 | else if (!strcmp (argv[i], "--bg-image")) |
1599 | { |
1600 | if (i + 1 < argc) |
1601 | - backgroundImage = argv[++i]; |
1602 | + CompGlobal::instance ().setBackgroundImage (argv[++i]); |
1603 | } |
1604 | else if (*argv[i] == '-') |
1605 | { |
1606 | @@ -169,7 +150,7 @@ |
1607 | } |
1608 | } |
1609 | |
1610 | - initialPlugins = plugins; |
1611 | + CompGlobal::instance ().setInitialPlugins (plugins); |
1612 | |
1613 | return true; |
1614 | } |
1615 | @@ -195,9 +176,9 @@ |
1616 | return false; |
1617 | } |
1618 | |
1619 | - modHandler = new ModifierHandler (); |
1620 | + CompGlobal::instance ().setModHandler (new ModifierHandler ()); |
1621 | |
1622 | - if (!modHandler) |
1623 | + if (!CompGlobal::instance ().modHandler ()) |
1624 | return false; |
1625 | |
1626 | if (!plugins.empty ()) |
1627 | @@ -224,7 +205,7 @@ |
1628 | if (!screen->init (displayName)) |
1629 | return false; |
1630 | |
1631 | - if (debugOutput) |
1632 | + if (CompGlobal::instance ().isDebugOutput()) |
1633 | { |
1634 | StackDebugger::SetDefault (new StackDebugger (screen->dpy (), |
1635 | screen->root (), |
1636 | @@ -262,7 +243,7 @@ |
1637 | StackDebugger::SetDefault (NULL); |
1638 | |
1639 | delete screen; |
1640 | - delete modHandler; |
1641 | + delete CompGlobal::instance ().modHandler (); |
1642 | } |
1643 | |
1644 | |
1645 | @@ -272,9 +253,9 @@ |
1646 | { |
1647 | CompManager manager; |
1648 | |
1649 | - programName = argv[0]; |
1650 | - programArgc = argc; |
1651 | - programArgv = argv; |
1652 | + CompGlobal::instance ().setProgramName (argv[0]); |
1653 | + CompGlobal::instance ().setProgramArgc(argc); |
1654 | + CompGlobal::instance ().setProgramArgv(argv); |
1655 | |
1656 | signal (SIGHUP, signalHandler); |
1657 | signal (SIGCHLD, signalHandler); |
1658 | @@ -291,9 +272,9 @@ |
1659 | |
1660 | manager.fini (); |
1661 | |
1662 | - if (restartSignal) |
1663 | + if (CompGlobal::instance ().restartSignal ()) |
1664 | { |
1665 | - execvp (programName, programArgv); |
1666 | + execvp (CompGlobal::instance ().programName(), CompGlobal::instance ().programArgv ()); |
1667 | return 1; |
1668 | } |
1669 | |
1670 | |
1671 | === modified file 'src/option.cpp' |
1672 | --- src/option.cpp 2010-11-11 03:14:20 +0000 |
1673 | +++ src/option.cpp 2012-01-17 16:06:33 +0000 |
1674 | @@ -32,164 +32,14 @@ |
1675 | #include <boost/foreach.hpp> |
1676 | #define foreach BOOST_FOREACH |
1677 | |
1678 | +#include <core/action.h> |
1679 | #include <core/core.h> |
1680 | +#include <core/match.h> |
1681 | #include <core/option.h> |
1682 | #include "privateoption.h" |
1683 | |
1684 | CompOption::Vector noOptions (0); |
1685 | |
1686 | -CompOption::Value::Value () : |
1687 | - priv (new PrivateValue ()) |
1688 | -{ |
1689 | -} |
1690 | - |
1691 | -CompOption::Value::Value (const Value &v) : |
1692 | - priv (new PrivateValue (*v.priv)) |
1693 | -{ |
1694 | -} |
1695 | - |
1696 | -CompOption::Value::~Value () |
1697 | -{ |
1698 | - delete priv; |
1699 | -} |
1700 | - |
1701 | -CompOption::Value::Value (const bool b) : |
1702 | - priv (new PrivateValue ()) |
1703 | -{ |
1704 | - set (b); |
1705 | -} |
1706 | - |
1707 | -CompOption::Value::Value (const int i) : |
1708 | - priv (new PrivateValue ()) |
1709 | -{ |
1710 | - set (i); |
1711 | -} |
1712 | - |
1713 | -CompOption::Value::Value (const float f) : |
1714 | - priv (new PrivateValue ()) |
1715 | -{ |
1716 | - set (f); |
1717 | -} |
1718 | - |
1719 | -CompOption::Value::Value (const unsigned short *color) : |
1720 | - priv (new PrivateValue ()) |
1721 | -{ |
1722 | - set (color); |
1723 | -} |
1724 | - |
1725 | -CompOption::Value::Value (const CompString& s) : |
1726 | - priv (new PrivateValue ()) |
1727 | -{ |
1728 | - set (s); |
1729 | -} |
1730 | - |
1731 | -CompOption::Value::Value (const char *s) : |
1732 | - priv (new PrivateValue ()) |
1733 | -{ |
1734 | - set (s); |
1735 | -} |
1736 | - |
1737 | - |
1738 | -CompOption::Value::Value (const CompMatch& m) : |
1739 | - priv (new PrivateValue ()) |
1740 | -{ |
1741 | - set (m); |
1742 | -} |
1743 | - |
1744 | -CompOption::Value::Value (const CompAction& a) : |
1745 | - priv (new PrivateValue ()) |
1746 | -{ |
1747 | - set (a); |
1748 | -} |
1749 | - |
1750 | -CompOption::Value::Value (CompOption::Type type, const Vector& l) : |
1751 | - priv (new PrivateValue ()) |
1752 | -{ |
1753 | - set (type, l); |
1754 | -} |
1755 | - |
1756 | -CompOption::Type |
1757 | -CompOption::Value::type () const |
1758 | -{ |
1759 | - return priv->type; |
1760 | -} |
1761 | - |
1762 | -void |
1763 | -CompOption::Value::set (const bool b) |
1764 | -{ |
1765 | - priv->reset (); |
1766 | - priv->type = CompOption::TypeBool; |
1767 | - priv->value.b = b; |
1768 | -} |
1769 | - |
1770 | -void |
1771 | -CompOption::Value::set (const int i) |
1772 | -{ |
1773 | - priv->reset (); |
1774 | - priv->type = CompOption::TypeInt; |
1775 | - priv->value.i = i; |
1776 | -} |
1777 | - |
1778 | -void |
1779 | -CompOption::Value::set (const float f) |
1780 | -{ |
1781 | - priv->reset (); |
1782 | - priv->type = CompOption::TypeFloat; |
1783 | - priv->value.f = f; |
1784 | -} |
1785 | - |
1786 | -void |
1787 | -CompOption::Value::set (const unsigned short *color) |
1788 | -{ |
1789 | - priv->reset (); |
1790 | - priv->type = CompOption::TypeColor; |
1791 | - priv->value.c[0] = color[0]; |
1792 | - priv->value.c[1] = color[1]; |
1793 | - priv->value.c[2] = color[2]; |
1794 | - priv->value.c[3] = color[3]; |
1795 | -} |
1796 | - |
1797 | -void |
1798 | -CompOption::Value::set (const CompString& s) |
1799 | -{ |
1800 | - priv->reset (); |
1801 | - priv->type = CompOption::TypeString; |
1802 | - priv->string = s; |
1803 | -} |
1804 | - |
1805 | -void |
1806 | -CompOption::Value::set (const char *s) |
1807 | -{ |
1808 | - priv->reset (); |
1809 | - priv->type = CompOption::TypeString; |
1810 | - priv->string = CompString (s); |
1811 | -} |
1812 | - |
1813 | -void |
1814 | -CompOption::Value::set (const CompMatch& m) |
1815 | -{ |
1816 | - priv->reset (); |
1817 | - priv->type = CompOption::TypeMatch; |
1818 | - priv->match = m; |
1819 | -} |
1820 | - |
1821 | -void |
1822 | -CompOption::Value::set (const CompAction& a) |
1823 | -{ |
1824 | - priv->reset (); |
1825 | - priv->type = CompOption::TypeAction; |
1826 | - priv->action = a; |
1827 | -} |
1828 | - |
1829 | -void |
1830 | -CompOption::Value::set (CompOption::Type type, const Vector& l) |
1831 | -{ |
1832 | - priv->reset (); |
1833 | - priv->type = CompOption::TypeList; |
1834 | - priv->list = l; |
1835 | - priv->listType = type; |
1836 | -} |
1837 | - |
1838 | static bool |
1839 | checkIsAction (CompOption::Type type) |
1840 | { |
1841 | @@ -207,307 +57,130 @@ |
1842 | return false; |
1843 | } |
1844 | |
1845 | -bool |
1846 | -CompOption::Value::b () |
1847 | -{ |
1848 | - if (!priv->checkType (CompOption::TypeBool)) |
1849 | - return false; |
1850 | - |
1851 | - return priv->value.b; |
1852 | -} |
1853 | - |
1854 | -int |
1855 | -CompOption::Value::i () |
1856 | -{ |
1857 | - if (!priv->checkType (CompOption::TypeInt)) |
1858 | - return 0; |
1859 | - |
1860 | - return priv->value.i; |
1861 | -} |
1862 | - |
1863 | -float |
1864 | -CompOption::Value::f () |
1865 | -{ |
1866 | - if (!priv->checkType (CompOption::TypeFloat)) |
1867 | - return 0.0; |
1868 | - |
1869 | - return priv->value.f; |
1870 | -} |
1871 | + |
1872 | |
1873 | static unsigned short defaultColor[4] = { 0x0, 0x0, 0x0, 0xffff}; |
1874 | |
1875 | -unsigned short * |
1876 | -CompOption::Value::c () |
1877 | -{ |
1878 | - if (!priv->checkType (CompOption::TypeColor)) |
1879 | - return reinterpret_cast<unsigned short *> (defaultColor); |
1880 | - |
1881 | - return priv->value.c; |
1882 | -} |
1883 | - |
1884 | -CompString |
1885 | + |
1886 | +static void |
1887 | +finiOptionValue (CompOption::Value &v) |
1888 | +{ |
1889 | + switch (v.type()) { |
1890 | + case CompOption::TypeAction: |
1891 | + case CompOption::TypeKey: |
1892 | + case CompOption::TypeButton: |
1893 | + case CompOption::TypeEdge: |
1894 | + case CompOption::TypeBell: |
1895 | + if (v.action ().state () & CompAction::StateAutoGrab && screen) |
1896 | + screen->removeAction (&v.action ()); |
1897 | + break; |
1898 | + |
1899 | + case CompOption::TypeList: |
1900 | + foreach (CompOption::Value &val, v.list ()) |
1901 | + finiOptionValue (val); |
1902 | + break; |
1903 | + |
1904 | + default: |
1905 | + break; |
1906 | + } |
1907 | +} |
1908 | + |
1909 | +CompOption::Value::~Value() |
1910 | +{ |
1911 | + finiOptionValue(*this); |
1912 | +} |
1913 | + |
1914 | +void |
1915 | +CompOption::Value::set (Type t, const CompOption::Value::Vector & v) |
1916 | +{ |
1917 | + mListType = t; |
1918 | + mValue = v; |
1919 | +} |
1920 | + |
1921 | +bool |
1922 | +CompOption::Value::b () const |
1923 | +{ |
1924 | + return boost::get<bool>(mValue); |
1925 | +} |
1926 | + |
1927 | +int |
1928 | +CompOption::Value::i () const |
1929 | +{ |
1930 | + return boost::get<int>(mValue); |
1931 | +} |
1932 | + |
1933 | +float |
1934 | +CompOption::Value::f () const |
1935 | +{ |
1936 | + return boost::get<float>(mValue); |
1937 | +} |
1938 | + |
1939 | +unsigned short* |
1940 | +CompOption::Value::c () const |
1941 | +{ |
1942 | + return boost::get<unsigned short*>(mValue); |
1943 | +} |
1944 | + |
1945 | +const CompString & |
1946 | +CompOption::Value::s () const |
1947 | +{ |
1948 | + return boost::get<CompString>(mValue); |
1949 | +} |
1950 | + |
1951 | +CompString & |
1952 | CompOption::Value::s () |
1953 | { |
1954 | - if (!priv->checkType (CompOption::TypeString)) |
1955 | - return ""; |
1956 | + return boost::get < CompString > (mValue); |
1957 | +} |
1958 | |
1959 | - return priv->string; |
1960 | +const CompMatch & |
1961 | +CompOption::Value::match () const |
1962 | +{ |
1963 | + return boost::get<CompMatch>(mValue); |
1964 | } |
1965 | |
1966 | CompMatch & |
1967 | CompOption::Value::match () |
1968 | { |
1969 | - priv->checkType (CompOption::TypeMatch); |
1970 | + return boost::get<CompMatch>(mValue); |
1971 | +} |
1972 | |
1973 | - return priv->match; |
1974 | +const CompAction & |
1975 | +CompOption::Value::action () const |
1976 | +{ |
1977 | + return boost::get<CompAction>(mValue); |
1978 | } |
1979 | |
1980 | CompAction & |
1981 | CompOption::Value::action () |
1982 | { |
1983 | - priv->checkType (priv->type); |
1984 | - |
1985 | - if (!checkIsAction (priv->type)) |
1986 | - compLogMessage ("core", CompLogLevelWarn, |
1987 | - "CompOption::Value not an action"); |
1988 | - |
1989 | - return priv->action; |
1990 | + return boost::get<CompAction>(mValue); |
1991 | } |
1992 | |
1993 | -CompOption::Type |
1994 | -CompOption::Value::listType () |
1995 | +// Type listType () const; |
1996 | + |
1997 | +const CompOption::Value::Vector & |
1998 | +CompOption::Value::list () const |
1999 | { |
2000 | - priv->checkType (CompOption::TypeList); |
2001 | - |
2002 | - return priv->listType; |
2003 | + return boost::get< std::vector<Value> >(mValue); |
2004 | } |
2005 | |
2006 | CompOption::Value::Vector & |
2007 | CompOption::Value::list () |
2008 | { |
2009 | - priv->checkType (CompOption::TypeList); |
2010 | - |
2011 | - return priv->list; |
2012 | -} |
2013 | - |
2014 | -CompOption::Value::operator bool () |
2015 | -{ |
2016 | - return b (); |
2017 | -} |
2018 | - |
2019 | -CompOption::Value::operator int () |
2020 | -{ |
2021 | - return i (); |
2022 | -} |
2023 | - |
2024 | -CompOption::Value::operator float () |
2025 | -{ |
2026 | - return f (); |
2027 | -} |
2028 | - |
2029 | -CompOption::Value::operator unsigned short * () |
2030 | -{ |
2031 | - return c (); |
2032 | -} |
2033 | - |
2034 | -CompOption::Value::operator CompString () |
2035 | -{ |
2036 | - return s (); |
2037 | -} |
2038 | - |
2039 | -CompOption::Value::operator CompMatch & () |
2040 | -{ |
2041 | - return match (); |
2042 | -} |
2043 | - |
2044 | -CompOption::Value::operator CompAction & () |
2045 | -{ |
2046 | - return action (); |
2047 | -} |
2048 | - |
2049 | -CompOption::Value::operator CompAction * () |
2050 | -{ |
2051 | - return &action (); |
2052 | -} |
2053 | - |
2054 | -CompOption::Value::operator Type () |
2055 | -{ |
2056 | - return listType (); |
2057 | -} |
2058 | - |
2059 | -CompOption::Value::operator Vector & () |
2060 | -{ |
2061 | - return list (); |
2062 | -} |
2063 | - |
2064 | -bool |
2065 | -CompOption::Value::operator== (const CompOption::Value &val) |
2066 | -{ |
2067 | - if (priv->type != val.priv->type) |
2068 | - return false; |
2069 | - |
2070 | - switch (priv->type) |
2071 | - { |
2072 | - case CompOption::TypeBool: |
2073 | - return priv->value.b == val.priv->value.b; |
2074 | - break; |
2075 | - |
2076 | - case CompOption::TypeInt: |
2077 | - return priv->value.i == val.priv->value.i; |
2078 | - break; |
2079 | - |
2080 | - case CompOption::TypeFloat: |
2081 | - return priv->value.f == val.priv->value.f; |
2082 | - break; |
2083 | - |
2084 | - case CompOption::TypeColor: |
2085 | - return (priv->value.c[0] == val.priv->value.c[0]) && |
2086 | - (priv->value.c[1] == val.priv->value.c[1]) && |
2087 | - (priv->value.c[2] == val.priv->value.c[2]) && |
2088 | - (priv->value.c[3] == val.priv->value.c[3]); |
2089 | - break; |
2090 | - |
2091 | - case CompOption::TypeString: |
2092 | - return priv->string.compare (val.priv->string) == 0; |
2093 | - break; |
2094 | - |
2095 | - case CompOption::TypeMatch: |
2096 | - return priv->match == val.priv->match; |
2097 | - break; |
2098 | - |
2099 | - case CompOption::TypeAction: |
2100 | - return priv->action == val.priv->action; |
2101 | - break; |
2102 | - |
2103 | - case CompOption::TypeList: |
2104 | - if (priv->listType != val.priv->listType) |
2105 | - return false; |
2106 | - |
2107 | - if (priv->list.size () != val.priv->list.size ()) |
2108 | - return false; |
2109 | - |
2110 | - for (unsigned int i = 0; i < priv->list.size (); i++) |
2111 | - if (priv->list[i] != val.priv->list[i]) |
2112 | - return false; |
2113 | - |
2114 | - return true; |
2115 | - break; |
2116 | - |
2117 | - default: |
2118 | - break; |
2119 | - } |
2120 | - |
2121 | - return true; |
2122 | -} |
2123 | - |
2124 | -bool |
2125 | -CompOption::Value::operator!= (const CompOption::Value &val) |
2126 | -{ |
2127 | - return !(*this == val); |
2128 | -} |
2129 | - |
2130 | -static void |
2131 | -finiOptionValue (CompOption::Value &v, |
2132 | - CompOption::Type type) |
2133 | -{ |
2134 | - switch (type) { |
2135 | - case CompOption::TypeAction: |
2136 | - case CompOption::TypeKey: |
2137 | - case CompOption::TypeButton: |
2138 | - case CompOption::TypeEdge: |
2139 | - case CompOption::TypeBell: |
2140 | - if (v.action ().state () & CompAction::StateAutoGrab && screen) |
2141 | - screen->removeAction (&v.action ()); |
2142 | - break; |
2143 | - |
2144 | - case CompOption::TypeList: |
2145 | - foreach (CompOption::Value &val, v.list ()) |
2146 | - finiOptionValue (val, v.listType ()); |
2147 | - break; |
2148 | - |
2149 | - default: |
2150 | - break; |
2151 | - } |
2152 | -} |
2153 | - |
2154 | -CompOption::Value & |
2155 | -CompOption::Value::operator= (const CompOption::Value &val) |
2156 | -{ |
2157 | - if (this == &val) |
2158 | - return *this; |
2159 | - |
2160 | - finiOptionValue (*this, priv->type); |
2161 | - |
2162 | - delete priv; |
2163 | - priv = new PrivateValue (*val.priv); |
2164 | - |
2165 | - return *this; |
2166 | -} |
2167 | - |
2168 | -PrivateValue::PrivateValue () : |
2169 | - type (CompOption::TypeUnset), |
2170 | - string (""), |
2171 | - action (), |
2172 | - match (), |
2173 | - listType (CompOption::TypeUnset), |
2174 | - list () |
2175 | -{ |
2176 | - memset (&value, 0, sizeof (ValueUnion)); |
2177 | -} |
2178 | - |
2179 | -PrivateValue::PrivateValue (const PrivateValue& p) : |
2180 | - type (p.type), |
2181 | - string (p.string), |
2182 | - action (p.action), |
2183 | - match (p.match), |
2184 | - listType (p.listType), |
2185 | - list (p.list) |
2186 | -{ |
2187 | - memcpy (&value, &p.value, sizeof (ValueUnion)); |
2188 | -} |
2189 | - |
2190 | -bool |
2191 | -PrivateValue::checkType (CompOption::Type refType) |
2192 | -{ |
2193 | - if (type == CompOption::TypeUnset) |
2194 | - { |
2195 | - compLogMessage ("core", CompLogLevelWarn, |
2196 | - "Value type is not yet set"); |
2197 | - return false; |
2198 | - } |
2199 | - |
2200 | - if (type != refType) |
2201 | - { |
2202 | - compLogMessage ("core", CompLogLevelWarn, |
2203 | - "Value type does not match (is %d, expected %d)", |
2204 | - type, refType); |
2205 | - return false; |
2206 | - } |
2207 | - |
2208 | - return true; |
2209 | -} |
2210 | - |
2211 | -void |
2212 | -PrivateValue::reset () |
2213 | -{ |
2214 | - switch (type) { |
2215 | - case CompOption::TypeString: |
2216 | - string = ""; |
2217 | - break; |
2218 | - case CompOption::TypeMatch: |
2219 | - match = CompMatch (); |
2220 | - break; |
2221 | - case CompOption::TypeAction: |
2222 | - action = CompAction (); |
2223 | - break; |
2224 | - case CompOption::TypeList: |
2225 | - list.clear (); |
2226 | - listType = CompOption::TypeBool; |
2227 | - break; |
2228 | - default: |
2229 | - break; |
2230 | - } |
2231 | - type = CompOption::TypeBool; |
2232 | + return boost::get< std::vector<Value> >(mValue); |
2233 | +} |
2234 | + |
2235 | +bool |
2236 | +CompOption::Value::operator== (const Value & rhs) const |
2237 | +{ |
2238 | + return mValue == rhs.mValue; |
2239 | +} |
2240 | + |
2241 | +bool |
2242 | +CompOption::Value::operator!= (const Value & rhs) const |
2243 | +{ |
2244 | + return !(mValue == rhs.mValue); |
2245 | } |
2246 | |
2247 | CompOption::Restriction::Restriction () : |
2248 | @@ -664,10 +337,9 @@ |
2249 | |
2250 | static void |
2251 | finiScreenOptionValue (CompScreen *s, |
2252 | - CompOption::Value &v, |
2253 | - CompOption::Type type) |
2254 | + CompOption::Value &v) |
2255 | { |
2256 | - switch (type) { |
2257 | + switch (v.type()) { |
2258 | case CompOption::TypeAction: |
2259 | case CompOption::TypeKey: |
2260 | case CompOption::TypeButton: |
2261 | @@ -679,7 +351,7 @@ |
2262 | |
2263 | case CompOption::TypeList: |
2264 | foreach (CompOption::Value &val, v.list ()) |
2265 | - finiScreenOptionValue (s, val, v.listType ()); |
2266 | + finiScreenOptionValue (s, val); |
2267 | break; |
2268 | |
2269 | default: |
2270 | @@ -689,7 +361,7 @@ |
2271 | |
2272 | CompOption::~CompOption () |
2273 | { |
2274 | - finiOptionValue (priv->value, priv->type); |
2275 | + finiOptionValue (priv->value); |
2276 | delete priv; |
2277 | } |
2278 | |
2279 | |
2280 | === modified file 'src/privateoption.h' |
2281 | --- src/privateoption.h 2010-11-09 14:13:19 +0000 |
2282 | +++ src/privateoption.h 2012-01-17 16:06:33 +0000 |
2283 | @@ -56,32 +56,6 @@ |
2284 | RestrictionUnion rest; |
2285 | }; |
2286 | |
2287 | -typedef union { |
2288 | - bool b; |
2289 | - int i; |
2290 | - float f; |
2291 | - unsigned short c[4]; |
2292 | -} ValueUnion; |
2293 | - |
2294 | -class PrivateValue { |
2295 | - public: |
2296 | - PrivateValue (); |
2297 | - PrivateValue (const PrivateValue&); |
2298 | - |
2299 | - void reset (); |
2300 | - bool checkType (CompOption::Type refType); |
2301 | - |
2302 | - CompOption::Type type; |
2303 | - ValueUnion value; |
2304 | - CompString string; |
2305 | - CompAction action; |
2306 | - CompMatch match; |
2307 | - CompOption::Type listType; |
2308 | - CompOption::Value::Vector list; |
2309 | - |
2310 | - bool active; |
2311 | -}; |
2312 | - |
2313 | class PrivateOption |
2314 | { |
2315 | public: |
2316 | |
2317 | === modified file 'src/privatescreen.h' |
2318 | --- src/privatescreen.h 2011-10-31 13:51:00 +0000 |
2319 | +++ src/privatescreen.h 2012-01-17 16:06:33 +0000 |
2320 | @@ -49,20 +49,6 @@ |
2321 | |
2322 | class CoreWindow; |
2323 | |
2324 | -extern bool shutDown; |
2325 | -extern bool restartSignal; |
2326 | - |
2327 | -extern CompWindow *lastFoundWindow; |
2328 | -extern bool useDesktopHints; |
2329 | - |
2330 | -extern bool inHandleEvent; |
2331 | - |
2332 | -extern CompScreen *targetScreen; |
2333 | -extern CompOutput *targetOutput; |
2334 | - |
2335 | -extern std::list <CompString> initialPlugins; |
2336 | - |
2337 | - |
2338 | typedef struct _CompDelayedEdgeSettings |
2339 | { |
2340 | CompAction::CallBack initiate; |
2341 | |
2342 | === modified file 'src/screen.cpp' |
2343 | --- src/screen.cpp 2012-01-16 08:36:54 +0000 |
2344 | +++ src/screen.cpp 2012-01-17 16:06:33 +0000 |
2345 | @@ -610,7 +610,7 @@ |
2346 | return screen->updateDefaultIcon (); |
2347 | break; |
2348 | case CoreOptions::Outputs: |
2349 | - if (!noDetection && optionGetDetectOutputs ()) |
2350 | + if (!CompGlobal::instance ().noDetection () && optionGetDetectOutputs ()) |
2351 | return false; |
2352 | updateOutputDevices (); |
2353 | break; |
2354 | @@ -787,7 +787,7 @@ |
2355 | /* Determine the number of plugins, which is core + |
2356 | * initial plugins + plugins in option list in addition |
2357 | * to initial plugins */ |
2358 | - foreach (CompString &pn, initialPlugins) |
2359 | + foreach (CompString &pn, CompGlobal::instance ().initialPlugins ()) |
2360 | { |
2361 | if (pn != "core") |
2362 | pListCount++; |
2363 | @@ -799,7 +799,7 @@ |
2364 | if (lp.s () == "core") |
2365 | continue; |
2366 | |
2367 | - foreach (CompString &p, initialPlugins) |
2368 | + foreach (CompString &p, CompGlobal::instance ().initialPlugins ()) |
2369 | { |
2370 | if (p == lp.s ()) |
2371 | { |
2372 | @@ -828,7 +828,7 @@ |
2373 | j = 1; |
2374 | |
2375 | /* Add initial plugins */ |
2376 | - foreach (CompString &p, initialPlugins) |
2377 | + foreach (CompString &p, CompGlobal::instance ().initialPlugins ()) |
2378 | { |
2379 | if (p == "core") |
2380 | continue; |
2381 | @@ -839,12 +839,12 @@ |
2382 | /* Add plugins not in the initial list */ |
2383 | foreach (CompOption::Value &opt, list) |
2384 | { |
2385 | - std::list <CompString>::iterator it = initialPlugins.begin (); |
2386 | + std::list <CompString>::iterator it = CompGlobal::instance ().initialPlugins ().begin (); |
2387 | bool skip = false; |
2388 | if (opt.s () == "core") |
2389 | continue; |
2390 | |
2391 | - for (; it != initialPlugins.end (); it++) |
2392 | + for (; it != CompGlobal::instance ().initialPlugins ().end (); it++) |
2393 | { |
2394 | if ((*it) == opt.s ()) |
2395 | { |
2396 | @@ -1054,7 +1054,7 @@ |
2397 | wmSnAtom != event->xselectionclear.selection) |
2398 | return; |
2399 | |
2400 | - shutDown = true; |
2401 | + CompGlobal::instance ().setShutDown (true); |
2402 | } |
2403 | |
2404 | #define IMAGEDIR "images" |
2405 | @@ -1868,7 +1868,7 @@ |
2406 | void |
2407 | PrivateScreen::detectOutputDevices () |
2408 | { |
2409 | - if (!noDetection && optionGetDetectOutputs ()) |
2410 | + if (!CompGlobal::instance ().noDetection () && optionGetDetectOutputs ()) |
2411 | { |
2412 | CompString name; |
2413 | CompOption::Value value; |
2414 | @@ -2257,7 +2257,7 @@ |
2415 | unsigned long n, left; |
2416 | unsigned char *propData; |
2417 | |
2418 | - if (useDesktopHints) |
2419 | + if (CompGlobal::instance ().useDesktopHints ()) |
2420 | { |
2421 | result = XGetWindowProperty (dpy, root, |
2422 | Atoms::numberOfDesktops, |
2423 | @@ -2531,16 +2531,19 @@ |
2424 | CompWindow * |
2425 | CompScreen::findWindow (Window id) |
2426 | { |
2427 | - if (lastFoundWindow && lastFoundWindow->id () == id) |
2428 | + if (CompGlobal::instance ().lastFoundWindow () && CompGlobal::instance ().lastFoundWindow ()->id () == id) |
2429 | { |
2430 | - return lastFoundWindow; |
2431 | + return CompGlobal::instance ().lastFoundWindow (); |
2432 | } |
2433 | else |
2434 | { |
2435 | CompWindow::Map::iterator it = priv->windowsMap.find (id); |
2436 | |
2437 | if (it != priv->windowsMap.end ()) |
2438 | - return (lastFoundWindow = it->second); |
2439 | + { |
2440 | + CompGlobal::instance ().setLastFoundWindow (it->second); |
2441 | + return (CompGlobal::instance ().lastFoundWindow ()); |
2442 | + } |
2443 | } |
2444 | |
2445 | return 0; |
2446 | @@ -2729,8 +2732,8 @@ |
2447 | w->next = NULL; |
2448 | w->prev = NULL; |
2449 | |
2450 | - if (w == lastFoundWindow) |
2451 | - lastFoundWindow = NULL; |
2452 | + if (w == CompGlobal::instance ().lastFoundWindow ()) |
2453 | + CompGlobal::instance ().setLastFoundWindow (NULL); |
2454 | } |
2455 | |
2456 | void |
2457 | @@ -4398,7 +4401,7 @@ |
2458 | |
2459 | if (currentWmSnOwner != None) |
2460 | { |
2461 | - if (!replaceCurrentWm) |
2462 | + if (!CompGlobal::instance ().replaceCurrentWm ()) |
2463 | { |
2464 | compLogMessage ("core", CompLogLevelError, |
2465 | "Screen %d on display \"%s\" already " |
2466 | |
2467 | === modified file 'src/session.cpp' |
2468 | --- src/session.cpp 2011-10-31 13:51:00 +0000 |
2469 | +++ src/session.cpp 2012-01-17 16:06:33 +0000 |
2470 | @@ -91,18 +91,18 @@ |
2471 | |
2472 | /* at maximum, we pass our old arguments + our new client id |
2473 | to the SM, so allocate for that case */ |
2474 | - args = (const char **) malloc ((programArgc + 2) * sizeof (char *)); |
2475 | + args = (const char **) malloc ((CompGlobal::instance ().programArgc () + 2) * sizeof (char *)); |
2476 | if (!args) |
2477 | return; |
2478 | |
2479 | - for (i = 0; i < programArgc; i++) |
2480 | + for (i = 0; i < CompGlobal::instance ().programArgc(); i++) |
2481 | { |
2482 | - if (strcmp (programArgv[i], "--sm-client-id") == 0) |
2483 | + if (strcmp (CompGlobal::instance ().programArgv ()[i], "--sm-client-id") == 0) |
2484 | i++; /* skip old client id, we'll add the new one later */ |
2485 | - else if (strcmp (programArgv[i], "--replace") == 0) |
2486 | + else if (strcmp (CompGlobal::instance ().programArgv ()[i], "--replace") == 0) |
2487 | continue; /* there's nothing to replace when starting session */ |
2488 | else |
2489 | - args[count++] = programArgv[i]; |
2490 | + args[count++] = CompGlobal::instance ().programArgv ()[i]; |
2491 | } |
2492 | |
2493 | setStringListProperty (connection, SmCloneCommand, args, count); |
2494 | |
2495 | === added directory 'src/tests' |
2496 | === added file 'src/tests/CMakeLists.txt' |
2497 | --- src/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2498 | +++ src/tests/CMakeLists.txt 2012-01-17 16:06:33 +0000 |
2499 | @@ -0,0 +1,20 @@ |
2500 | +include_directories( |
2501 | + ${CMAKE_CURRENT_SOURCE_DIR} |
2502 | +) |
2503 | + |
2504 | +add_executable( |
2505 | + compiz_option_test |
2506 | + |
2507 | + ${CMAKE_CURRENT_SOURCE_DIR}/option.cpp |
2508 | +) |
2509 | + |
2510 | +target_link_libraries( |
2511 | + compiz_option_test |
2512 | + |
2513 | + compiz_core |
2514 | + |
2515 | + ${GTEST_BOTH_LIBRARIES} |
2516 | + ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. |
2517 | +) |
2518 | + |
2519 | +add_test( compiz_option_test compiz_option_test ) |
2520 | |
2521 | === added file 'src/tests/option.cpp' |
2522 | --- src/tests/option.cpp 1970-01-01 00:00:00 +0000 |
2523 | +++ src/tests/option.cpp 2012-01-17 16:06:33 +0000 |
2524 | @@ -0,0 +1,43 @@ |
2525 | +#include <gtest/gtest.h> |
2526 | + |
2527 | +#include "core/core.h" |
2528 | +#include "core/action.h" |
2529 | +#include "core/match.h" |
2530 | +#include "core/option.h" |
2531 | + |
2532 | +namespace { |
2533 | + template<typename T> |
2534 | + void |
2535 | + check_type_value(CompOption::Type type, const T & value) |
2536 | + { |
2537 | + CompOption::Value v; |
2538 | + v.set(value); |
2539 | + ASSERT_EQ(v.type(),type); |
2540 | + ASSERT_EQ (v.get<T>(),value); |
2541 | + } |
2542 | +} |
2543 | + |
2544 | + |
2545 | + |
2546 | +static unsigned short defaultColor[4] = { 0x0, 0x0, 0x0, 0xffff}; |
2547 | + |
2548 | +TEST(CompOption,Value) |
2549 | +{ |
2550 | + |
2551 | + check_type_value<bool> (CompOption::TypeBool, true); |
2552 | + check_type_value<bool> (CompOption::TypeBool, false); |
2553 | + |
2554 | + check_type_value<int> (CompOption::TypeInt, 1); |
2555 | + check_type_value<float> (CompOption::TypeFloat, 1.f); |
2556 | + check_type_value<CompString> (CompOption::TypeString, CompString("Check")); |
2557 | + |
2558 | + check_type_value<CompAction> (CompOption::TypeAction, CompAction()); |
2559 | + check_type_value<CompMatch> (CompOption::TypeMatch, CompMatch()); |
2560 | + |
2561 | + check_type_value<CompOption::Value::Vector> (CompOption::TypeList, CompOption::Value::Vector(5)); |
2562 | + |
2563 | + CompOption::Value v1, v2; |
2564 | + ASSERT_EQ (v1,v2); |
2565 | + v1.set (CompString("SomeString")); |
2566 | + ASSERT_TRUE(v1 != v2); |
2567 | +} |
2568 | |
2569 | === modified file 'src/window.cpp' |
2570 | --- src/window.cpp 2012-01-16 09:10:42 +0000 |
2571 | +++ src/window.cpp 2012-01-17 16:06:33 +0000 |
2572 | @@ -5984,15 +5984,15 @@ |
2573 | /* Grab only we have bindings on */ |
2574 | foreach (PrivateScreen::ButtonGrab &bind, screen->priv->buttonGrabs) |
2575 | { |
2576 | - unsigned int mods = modHandler->virtualToRealModMask (bind.modifiers); |
2577 | + unsigned int mods = CompGlobal::instance ().modHandler ()->virtualToRealModMask (bind.modifiers); |
2578 | |
2579 | if (mods & CompNoMask) |
2580 | continue; |
2581 | |
2582 | for (unsigned int ignore = 0; |
2583 | - ignore <= modHandler->ignoredModMask (); ignore++) |
2584 | + ignore <= CompGlobal::instance ().modHandler ()->ignoredModMask (); ignore++) |
2585 | { |
2586 | - if (ignore & ~modHandler->ignoredModMask ()) |
2587 | + if (ignore & ~CompGlobal::instance ().modHandler ()->ignoredModMask ()) |
2588 | continue; |
2589 | |
2590 | XGrabButton (screen->priv->dpy, |
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.)