Merge lp:~alan-griffiths/compiz-core/move-stuff-to-CompScreenImpl into lp:compiz-core/0.9.8

Proposed by Alan Griffiths
Status: Merged
Merged at revision: 3134
Proposed branch: lp:~alan-griffiths/compiz-core/move-stuff-to-CompScreenImpl
Merge into: lp:compiz-core/0.9.8
Prerequisite: lp:~alan-griffiths/compiz-core/Law-of-Demeter-applied-to-CompScreen
Diff against target: 491 lines (+97/-73)
5 files modified
include/core/screen.h (+6/-6)
src/event.cpp (+5/-5)
src/privatescreen.h (+25/-12)
src/privatescreen/tests/test-privatescreen.cpp (+6/-0)
src/screen.cpp (+55/-50)
To merge this branch: bzr merge lp:~alan-griffiths/compiz-core/move-stuff-to-CompScreenImpl
Reviewer Review Type Date Requested Status
Sam Spilsbury Approve
Review via email: mp+105215@code.launchpad.net

Description of the change

Moving some members to CompScreenImpl

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

342 + ValueHolder::SetDefault (&valueHolder);
343 +

We should probably get rid of that singleton soon.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/core/screen.h'
2--- include/core/screen.h 2012-05-10 09:06:19 +0000
3+++ include/core/screen.h 2012-05-10 09:06:19 +0000
4@@ -330,7 +330,7 @@
5 // ensure the ABI is stable if/when they are moved to CompScreenImpl.
6 // They are only intended for use within compiz-core
7 virtual bool displayInitialised() const;
8- virtual void updatePassiveKeyGrabs () const;
9+ virtual void updatePassiveKeyGrabs () const = 0;
10 virtual void applyStartupProperties (CompWindow *window);
11 virtual void updateClientList();
12 virtual Window getTopWindow() const;
13@@ -338,13 +338,13 @@
14 virtual Colormap colormap() const;
15 virtual void setCurrentDesktop (unsigned int desktop);
16 virtual Window activeWindow() const;
17- virtual void updatePassiveButtonGrabs(Window serverFrame);
18+ virtual void updatePassiveButtonGrabs(Window serverFrame) = 0;
19 virtual bool grabWindowIsNot(Window w) const;
20 virtual void incrementPendingDestroys();
21- virtual void incrementDesktopWindowCount();
22- virtual void decrementDesktopWindowCount();
23- virtual unsigned int nextMapNum();
24- virtual unsigned int lastPing () const;
25+ virtual void incrementDesktopWindowCount() = 0;
26+ virtual void decrementDesktopWindowCount() = 0;
27+ virtual unsigned int nextMapNum() = 0;
28+ virtual unsigned int lastPing () const = 0;
29 virtual void setNextActiveWindow(Window id);
30 virtual Window getNextActiveWindow() const;
31 virtual CompWindow * focusTopMostWindow ();
32
33=== modified file 'src/event.cpp'
34--- src/event.cpp 2012-05-10 09:06:19 +0000
35+++ src/event.cpp 2012-05-10 09:06:19 +0000
36@@ -1412,9 +1412,9 @@
37 if (w->isViewable ())
38 {
39 if (w->type () == CompWindowTypeDesktopMask)
40- priv->orphanData.desktopWindowCount--;
41+ desktopWindowCount_--;
42 else if (type == CompWindowTypeDesktopMask)
43- priv->orphanData.desktopWindowCount++;
44+ desktopWindowCount_++;
45 }
46
47 w->wmType () = type;
48@@ -1613,7 +1613,7 @@
49 {
50 w = findWindow (event->xclient.data.l[2]);
51 if (w)
52- w->priv->handlePing (priv->ping.lastPing ());
53+ w->priv->handlePing (ping.lastPing ());
54 }
55 }
56 else if (event->xclient.message_type == Atoms::closeWindow)
57@@ -1932,7 +1932,7 @@
58 CompWindow *active = screen->findWindow (priv->orphanData.activeWindow);
59
60 priv->orphanData.activeWindow = w->id ();
61- w->priv->activeNum = priv->history.nextActiveNum();
62+ w->priv->activeNum = history.nextActiveNum();
63
64 if (active)
65 {
66@@ -1988,7 +1988,7 @@
67
68 w->priv->updatePassiveButtonGrabs ();
69
70- priv->history.addToCurrentActiveWindowHistory (w->id ());
71+ history.addToCurrentActiveWindowHistory (w->id ());
72
73 XChangeProperty (priv->dpy , priv->rootWindow(),
74 Atoms::winActive,
75
76=== modified file 'src/privatescreen.h'
77--- src/privatescreen.h 2012-05-10 09:06:19 +0000
78+++ src/privatescreen.h 2012-05-10 09:06:19 +0000
79@@ -362,7 +362,6 @@
80 };
81
82 class EventManager :
83- public ValueHolder,
84 public GrabList
85 {
86 public:
87@@ -465,9 +464,6 @@
88 {
89 OrphanData();
90 ~OrphanData();
91- int desktopWindowCount;
92- unsigned int mapNum;
93- CompIcon *defaultIcon;
94
95 Window activeWindow;
96 Window nextActiveWindow;
97@@ -613,7 +609,7 @@
98 PrivateScreen (CompScreen *screen);
99 ~PrivateScreen ();
100
101- bool initDisplay (const char *name);
102+ bool initDisplay (const char *name, compiz::private_screen::History& history);
103
104 bool setOption (const CompString &name, CompOption::Value &value);
105
106@@ -729,17 +725,17 @@
107 void detectOutputDevices(CoreOptions& coreOptions);
108 void updateOutputDevices(CoreOptions& coreOptions);
109
110+ void setPingTimerCallback(CompTimer::CallBack const& callback)
111+ { pingTimer.setCallback(callback); }
112+
113 public:
114 Display* dpy;
115 compiz::private_screen::Extension xSync;
116 compiz::private_screen::Extension xRandr;
117 compiz::private_screen::Extension xShape;
118- compiz::private_screen::History history;
119 compiz::private_screen::ViewPort viewPort;
120 compiz::private_screen::StartupSequenceImpl startupSequence;
121- compiz::private_screen::GrabManager grabManager;
122 compiz::private_screen::EventManager eventManager;
123- compiz::private_screen::Ping ping;
124 compiz::private_screen::OrphanData orphanData;
125 compiz::private_screen::OutputDevices outputDevices;
126 compiz::private_screen::WindowManager windowManager;
127@@ -763,13 +759,13 @@
128 bool initialized;
129
130 private:
131- bool handlePingTimeout();
132-
133 CompScreen* screen;
134 compiz::private_screen::Extension xkbEvent;
135+
136 //TODO? Pull these two out as a class?
137 bool xineramaExtension;
138 std::vector<XineramaScreenInfo> screenInfo;
139+
140 SnDisplay* snDisplay;
141 char displayString_[256];
142 KeyCode escapeKeyCode;
143@@ -791,7 +787,8 @@
144 CompTimer pingTimer;
145 CompTimer edgeDelayTimer;
146 CompDelayedEdgeSettings edgeDelaySettings;
147- Window xdndWindow;compiz::private_screen::PluginManager pluginManager;
148+ Window xdndWindow;
149+ compiz::private_screen::PluginManager pluginManager;
150 };
151
152 class CompManager
153@@ -1041,6 +1038,13 @@
154 virtual void processEvents ();
155 virtual void alwaysHandleEvent (XEvent *event);
156
157+ virtual void incrementDesktopWindowCount();
158+ virtual void decrementDesktopWindowCount();
159+ virtual unsigned int nextMapNum();
160+ virtual void updatePassiveKeyGrabs () const;
161+ virtual void updatePassiveButtonGrabs(Window serverFrame);
162+ virtual unsigned int lastPing () const;
163+
164 public :
165
166 static bool showDesktop (CompAction *action,
167@@ -1124,9 +1128,18 @@
168 virtual void _matchPropertyChanged(CompWindow *);
169 virtual void _outputChangeNotify();
170
171- Window below;
172+ bool handlePingTimeout();
173+
174+ Window below;
175 CompTimer autoRaiseTimer_;
176 Window autoRaiseWindow_;
177+ int desktopWindowCount_;
178+ unsigned int mapNum;
179+ CompIcon *defaultIcon_;
180+ compiz::private_screen::GrabManager mutable grabManager;
181+ compiz::private_screen::Ping ping;
182+ compiz::private_screen::History history;
183+ ValueHolder valueHolder;
184 bool eventHandled;
185 };
186
187
188=== modified file 'src/privatescreen/tests/test-privatescreen.cpp'
189--- src/privatescreen/tests/test-privatescreen.cpp 2012-05-03 14:31:14 +0000
190+++ src/privatescreen/tests/test-privatescreen.cpp 2012-05-10 09:06:19 +0000
191@@ -173,6 +173,12 @@
192 MOCK_METHOD0(grabbed, bool ());
193 MOCK_METHOD0(snDisplay, SnDisplay * ());
194 MOCK_CONST_METHOD0(createFailed, bool ());
195+ MOCK_METHOD0(incrementDesktopWindowCount, void ());
196+ MOCK_METHOD0(decrementDesktopWindowCount, void ());
197+ MOCK_METHOD0(nextMapNum, unsigned int ());
198+ MOCK_CONST_METHOD0(updatePassiveKeyGrabs, void ());
199+ MOCK_METHOD1(updatePassiveButtonGrabs, void (Window serverFrame));
200+ MOCK_CONST_METHOD0(lastPing, unsigned int ());
201 };
202
203 class StubActivePluginsOption : public CoreOptions
204
205=== modified file 'src/screen.cpp'
206--- src/screen.cpp 2012-05-10 09:06:19 +0000
207+++ src/screen.cpp 2012-05-10 09:06:19 +0000
208@@ -641,9 +641,12 @@
209 }
210
211 bool
212-PrivateScreen::handlePingTimeout ()
213+CompScreenImpl::handlePingTimeout ()
214 {
215- return ping.handlePingTimeout(windowManager.begin(), windowManager.end(), dpy);
216+ return ping.handlePingTimeout(
217+ priv->windowManager.begin(),
218+ priv->windowManager.end(),
219+ priv->dpy);
220 }
221
222 bool
223@@ -3477,16 +3480,16 @@
224
225 if (action->type () & CompAction::BindingTypeKey)
226 {
227- if (!priv->grabManager.addPassiveKeyGrab (action->key ()))
228+ if (!grabManager.addPassiveKeyGrab (action->key ()))
229 return false;
230 }
231
232 if (action->type () & CompAction::BindingTypeButton)
233 {
234- if (!priv->grabManager.addPassiveButtonGrab (action->button ()))
235+ if (!grabManager.addPassiveButtonGrab (action->button ()))
236 {
237 if (action->type () & CompAction::BindingTypeKey)
238- priv->grabManager.removePassiveKeyGrab (action->key ());
239+ grabManager.removePassiveKeyGrab (action->key ());
240
241 return false;
242 }
243@@ -3516,10 +3519,10 @@
244 return;
245
246 if (action->type () & CompAction::BindingTypeKey)
247- priv->grabManager.removePassiveKeyGrab (action->key ());
248+ grabManager.removePassiveKeyGrab (action->key ());
249
250 if (action->type () & CompAction::BindingTypeButton)
251- priv->grabManager.removePassiveButtonGrab (action->button ());
252+ grabManager.removePassiveButtonGrab (action->button ());
253
254 if (action->edgeMask ())
255 {
256@@ -3894,7 +3897,7 @@
257
258 priv->setDesktopHints ();
259
260- priv->history.setCurrentActiveWindowHistory (priv->viewPort.vp.x (), priv->viewPort.vp.y ());
261+ history.setCurrentActiveWindowHistory (priv->viewPort.vp.x (), priv->viewPort.vp.y ());
262
263 w = findWindow (priv->orphanData.activeWindow);
264 if (w)
265@@ -3906,7 +3909,7 @@
266 /* add window to current history if it's default viewport is
267 still the current one. */
268 if (priv->viewPort.vp.x () == dvp.x () && priv->viewPort.vp.y () == dvp.y ())
269- priv->history.addToCurrentActiveWindowHistory (w->id ());
270+ history.addToCurrentActiveWindowHistory (w->id ());
271 }
272 }
273 }
274@@ -4280,7 +4283,7 @@
275 CompIcon *
276 CompScreenImpl::defaultIcon () const
277 {
278- return priv->orphanData.defaultIcon;
279+ return defaultIcon_;
280 }
281
282 bool
283@@ -4291,18 +4294,18 @@
284 void *data;
285 CompSize size;
286
287- if (priv->orphanData.defaultIcon)
288+ if (defaultIcon_)
289 {
290- delete priv->orphanData.defaultIcon;
291- priv->orphanData.defaultIcon = NULL;
292+ delete defaultIcon_;
293+ defaultIcon_ = NULL;
294 }
295
296 if (!readImageFromFile (file, pname, size, data))
297 return false;
298
299- priv->orphanData.defaultIcon = new CompIcon (size.width (), size.height ());
300+ defaultIcon_ = new CompIcon (size.width (), size.height ());
301
302- memcpy (priv->orphanData.defaultIcon->data (), data,
303+ memcpy (defaultIcon_->data (), data,
304 size.width () * size.height () * sizeof (CARD32));
305
306 free (data);
307@@ -4532,13 +4535,13 @@
308 int
309 CompScreenImpl::desktopWindowCount ()
310 {
311- return priv->orphanData.desktopWindowCount;
312+ return desktopWindowCount_;
313 }
314
315 unsigned int
316 CompScreenImpl::activeNum () const
317 {
318- return priv->history.getActiveNum();
319+ return history.getActiveNum();
320 }
321
322 CompOutput::vector &
323@@ -4574,7 +4577,7 @@
324 CompActiveWindowHistory *
325 CompScreenImpl::currentHistory ()
326 {
327- return priv->history.getCurrentHistory ();
328+ return history.getCurrentHistory ();
329 }
330
331 bool
332@@ -4648,13 +4651,21 @@
333 below(),
334 autoRaiseTimer_(),
335 autoRaiseWindow_(0),
336+ desktopWindowCount_(0),
337+ mapNum (1),
338+ defaultIcon_(0),
339+ grabManager (this),
340 eventHandled (false)
341 {
342+ ValueHolder::SetDefault (&valueHolder);
343+
344 CompPrivate p;
345 CompOption::Value::Vector vList;
346 CompPlugin *corePlugin;
347
348 priv.reset (new PrivateScreen (this));
349+ priv->setPingTimerCallback(
350+ boost::bind (&CompScreenImpl::handlePingTimeout, this));
351
352 screenInitalized = true;
353
354@@ -4699,7 +4710,7 @@
355 {
356 priv->eventManager.init();
357
358- if (priv->initDisplay(name))
359+ if (priv->initDisplay(name, history))
360 {
361 priv->optionSetCloseWindowKeyInitiate (CompScreenImpl::closeWin);
362 priv->optionSetCloseWindowButtonInitiate (CompScreenImpl::closeWin);
363@@ -4767,9 +4778,9 @@
364 }
365
366 void
367-CompScreen::updatePassiveKeyGrabs () const
368+CompScreenImpl::updatePassiveKeyGrabs () const
369 {
370- priv->grabManager.updatePassiveKeyGrabs ();
371+ grabManager.updatePassiveKeyGrabs ();
372 }
373
374 void
375@@ -4815,9 +4826,9 @@
376 }
377
378 void
379-CompScreen::updatePassiveButtonGrabs(Window serverFrame)
380+CompScreenImpl::updatePassiveButtonGrabs(Window serverFrame)
381 {
382- priv->grabManager.updatePassiveButtonGrabs(serverFrame);
383+ grabManager.updatePassiveButtonGrabs(serverFrame);
384 }
385
386 bool
387@@ -4833,26 +4844,26 @@
388 }
389
390 void
391-CompScreen::incrementDesktopWindowCount()
392+CompScreenImpl::incrementDesktopWindowCount()
393 {
394- priv->orphanData.desktopWindowCount++;
395+ desktopWindowCount_++;
396 }
397 void
398-CompScreen::decrementDesktopWindowCount()
399-{
400- priv->orphanData.desktopWindowCount--;
401-}
402-
403-unsigned int
404-CompScreen::nextMapNum()
405-{
406- return priv->orphanData.mapNum++;
407-}
408-
409-unsigned int
410-CompScreen::lastPing () const
411-{
412- return priv->ping.lastPing ();
413+CompScreenImpl::decrementDesktopWindowCount()
414+{
415+ desktopWindowCount_--;
416+}
417+
418+unsigned int
419+CompScreenImpl::nextMapNum()
420+{
421+ return mapNum++;
422+}
423+
424+unsigned int
425+CompScreenImpl::lastPing () const
426+{
427+ return ping.lastPing ();
428 }
429
430 void
431@@ -4868,7 +4879,7 @@
432
433
434 bool
435-PrivateScreen::initDisplay (const char *name)
436+PrivateScreen::initDisplay (const char *name, cps::History& history)
437 {
438 dpy = XOpenDisplay (name);
439 if (!dpy)
440@@ -5301,6 +5312,9 @@
441 CompPlugin::unload (p);
442
443 screen = NULL;
444+
445+ if (defaultIcon_)
446+ delete defaultIcon_;
447 }
448
449 cps::GrabManager::GrabManager (CompScreen *screen) :
450@@ -5329,7 +5343,6 @@
451 CoreOptions(false),
452 dpy (NULL),
453 startupSequence(this),
454- grabManager (screen),
455 eventManager (),
456 nDesktop (1),
457 currentDesktop (0),
458@@ -5357,8 +5370,6 @@
459 screenEdge[i].count = 0;
460 }
461
462- pingTimer.setCallback (
463- boost::bind (&PrivateScreen::handlePingTimeout, this));
464 }
465
466 cps::History::History() :
467@@ -5405,15 +5416,11 @@
468 lastWatchFdHandle (1),
469 grabWindow (None)
470 {
471- ValueHolder::SetDefault (static_cast<ValueHolder *> (this));
472 TimeoutHandler *dTimeoutHandler = new TimeoutHandler ();
473 TimeoutHandler::SetDefault (dTimeoutHandler);
474 }
475
476 cps::OrphanData::OrphanData() :
477- desktopWindowCount (0),
478- mapNum (1),
479- defaultIcon (0),
480 activeWindow (0),
481 nextActiveWindow(0)
482 {
483@@ -5421,8 +5428,6 @@
484
485 cps::OrphanData::~OrphanData()
486 {
487- if (defaultIcon)
488- delete defaultIcon;
489 }
490
491 cps::EventManager::~EventManager ()

Subscribers

People subscribed via source and target branches