Merge lp:~canonical-dx-team/unity/uninty.cleanup-do-a-beryl-roll into lp:unity
- uninty.cleanup-do-a-beryl-roll
- Merge into trunk
Proposed by
Sam Spilsbury
Status: | Merged |
---|---|
Approved by: | Neil J. Patel |
Approved revision: | no longer in the source branch. |
Merge reported by: | Neil J. Patel |
Merged at revision: | not available |
Proposed branch: | lp:~canonical-dx-team/unity/uninty.cleanup-do-a-beryl-roll |
Merge into: | lp:unity |
Diff against target: |
846 lines (+169/-393) 3 files modified
src/unity.cpp (+99/-224) src/unity.h (+47/-169) unityshell.xml.in (+23/-0) |
To merge this branch: | bzr merge lp:~canonical-dx-team/unity/uninty.cleanup-do-a-beryl-roll |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Review via email: mp+41873@code.launchpad.net |
Commit message
Cleanup of the unity plugin, removed unused functions, ensure that we load last, remove useless comments etc
Description of the change
Cleanup of the unity plugin, removed unused functions, ensure that we load last, remove useless comments etc
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/unity.cpp' |
2 | --- src/unity.cpp 2010-11-25 07:10:40 +0000 |
3 | +++ src/unity.cpp 2010-11-25 16:12:10 +0000 |
4 | @@ -3,6 +3,7 @@ |
5 | * |
6 | * Copyright (c) 2010 Sam Spilsbury <smspillaz@gmail.com> |
7 | * Jason Smith <jason.smith@canonical.com> |
8 | + * Copyright (c) 2010 Canonical Ltd. |
9 | * |
10 | * This program is free software; you can redistribute it and/or |
11 | * modify it under the terms of the GNU General Public License |
12 | @@ -38,31 +39,15 @@ |
13 | |
14 | #include <core/atoms.h> |
15 | |
16 | -/* You must also call this. This creates a proper vTable for a plugin name in the |
17 | - * first argument (it's a macro, so you don't need a string). This changes from |
18 | - * time to time as the vTable changes, so it is a good way of ensure plugins keep |
19 | - * current */ |
20 | - |
21 | +/* Set up vtable symbols */ |
22 | COMPIZ_PLUGIN_20090315 (unityshell, UnityPluginVTable); |
23 | |
24 | -/* This is the function that is called before the screen is 're-painted'. It is used for animation |
25 | - * and such because it gives you a time difference between when the last time the screen was repainted |
26 | - * and the current time of the execution of the functions in milliseconds). It's part of the composite |
27 | - * plugin's interface |
28 | - */ |
29 | static UnityScreen *uScreen = 0; |
30 | |
31 | void |
32 | -UnityScreen::preparePaint (int ms) |
33 | -{ |
34 | - /* At the end of every function, you must call BaseClass->functionName (args) in order to pass on |
35 | - * the call chain */ |
36 | - cScreen->preparePaint (ms); |
37 | -} |
38 | - |
39 | -void |
40 | UnityScreen::nuxPrologue () |
41 | { |
42 | + /* reset matrices */ |
43 | glPushAttrib (GL_VIEWPORT_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_COLOR_BUFFER_BIT); |
44 | |
45 | glMatrixMode (GL_PROJECTION); |
46 | @@ -110,16 +95,13 @@ |
47 | doShellRepaint = false; |
48 | } |
49 | |
50 | -/* This is the guts of the paint function. You can transform the way the entire output is painted |
51 | - * or you can just draw things on screen with openGL. The unsigned int here is a mask for painting |
52 | - * the screen, see opengl/opengl.h on how you can change it */ |
53 | - |
54 | +/* called whenever we need to repaint parts of the screen */ |
55 | bool |
56 | -UnityScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, // Some basic attribs on how the screen should be painted |
57 | - const GLMatrix &transform, // Screen transformation matrix |
58 | - const CompRegion ®ion, // Region of screen being painted |
59 | - CompOutput *output, // Output properties. Use this to the get output width and height for the output being painted |
60 | - unsigned int mask /* Some other paint properties, see opengl.h */) |
61 | +UnityScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, |
62 | + const GLMatrix &transform, |
63 | + const CompRegion ®ion, |
64 | + CompOutput *output, |
65 | + unsigned int mask) |
66 | { |
67 | bool ret; |
68 | |
69 | @@ -135,32 +117,21 @@ |
70 | return ret; |
71 | } |
72 | |
73 | -/* This is called when the output is transformed by a matrix. Basically the same, but core has |
74 | - * done a few things for us like clip planes etc */ |
75 | +/* called whenever a plugin needs to paint the entire scene |
76 | + * transformed */ |
77 | |
78 | void |
79 | -UnityScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib, // Some basic attribs on how the screen should be painted |
80 | - const GLMatrix &transform, // Screen transformation matrix |
81 | - const CompRegion ®ion, // Region of screen being painted |
82 | - CompOutput *output, // Output properties. Use this to the get output width and height for the output being painted |
83 | - unsigned int mask /* Some other paint properties, see opengl.h */) |
84 | +UnityScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib, |
85 | + const GLMatrix &transform, |
86 | + const CompRegion ®ion, |
87 | + CompOutput *output, |
88 | + unsigned int mask) |
89 | { |
90 | allowWindowPaint = false; |
91 | - /* glPaintOutput is part of the opengl plugin, so we need the GLScreen base class. */ |
92 | gScreen->glPaintOutput (attrib, transform, region, output, mask); |
93 | } |
94 | |
95 | -/* This is called after screen painting is finished. It gives you a chance to do any cleanup and or |
96 | - * call another repaint with screen->damageScreen (). It's also part of the composite plugin's |
97 | - * interface. |
98 | - */ |
99 | - |
100 | -void |
101 | -UnityScreen::donePaint () |
102 | -{ |
103 | - cScreen->donePaint (); |
104 | -} |
105 | - |
106 | +/* Grab changed nux regions and add damage rects for them */ |
107 | void |
108 | UnityScreen::damageNuxRegions () |
109 | { |
110 | @@ -184,10 +155,7 @@ |
111 | wt->ClearDrawList (); |
112 | } |
113 | |
114 | -/* This is our event handler. It directly hooks into the screen's X Event handler and allows us to handle |
115 | - * our raw X Events |
116 | - */ |
117 | - |
118 | +/* handle X Events */ |
119 | void |
120 | UnityScreen::handleEvent (XEvent *event) |
121 | { |
122 | @@ -199,43 +167,56 @@ |
123 | } |
124 | } |
125 | |
126 | + |
127 | +gboolean |
128 | +UnityScreen::initPluginActions (gpointer data) |
129 | +{ |
130 | + CompPlugin *p; |
131 | + |
132 | + p = CompPlugin::find ("expo"); |
133 | + |
134 | + if (p) |
135 | + { |
136 | + foreach (CompOption &option, p->vTable->getOptions ()) |
137 | + { |
138 | + if (option.name () == "expo_key") |
139 | + { |
140 | + CompAction *action = &option.value ().action (); |
141 | + PluginAdapter::Default ()->SetExpoAction (action); |
142 | + break; |
143 | + } |
144 | + } |
145 | + } |
146 | + |
147 | + p = CompPlugin::find ("scale"); |
148 | + |
149 | + if (p) |
150 | + { |
151 | + foreach (CompOption &option, p->vTable->getOptions ()) |
152 | + { |
153 | + if (option.name () == "initiate_all_key") |
154 | + { |
155 | + CompAction *action = &option.value ().action (); |
156 | + PluginAdapter::Default ()->SetScaleAction (action); |
157 | + break; |
158 | + } |
159 | + } |
160 | + } |
161 | + |
162 | + return FALSE; |
163 | +} |
164 | + |
165 | +/* Set up expo and scale actions on the launcher */ |
166 | bool |
167 | UnityScreen::initPluginForScreen (CompPlugin *p) |
168 | { |
169 | - if (g_strcmp0 (p->vTable->name ().c_str (), "expo") == 0) |
170 | - { |
171 | - CompOption::Vector &options = p->vTable->getOptions (); |
172 | - |
173 | - foreach (CompOption& option, options) |
174 | - { |
175 | - if (g_strcmp0 (option.name ().c_str () , "expo_key") == 0) |
176 | - { |
177 | - CompAction *expoAction = &option.value ().action (); |
178 | - |
179 | - PluginAdapter::Default ()->SetExpoAction (expoAction); |
180 | - break; |
181 | - } |
182 | - } |
183 | - } |
184 | - |
185 | - if (g_strcmp0 (p->vTable->name ().c_str (), "scale") == 0) |
186 | - { |
187 | - CompOption::Vector &options = p->vTable->getOptions (); |
188 | - |
189 | - foreach (CompOption& option, options) |
190 | - { |
191 | - if (g_strcmp0 (option.name ().c_str () , "initiate_all_key") == 0) |
192 | - { |
193 | - CompAction *scaleAction = &option.value ().action (); |
194 | - |
195 | - PluginAdapter::Default ()->SetScaleAction (scaleAction); |
196 | - break; |
197 | - } |
198 | - } |
199 | + if (p->vTable->name () == "expo" || |
200 | + p->vTable->name () == "scale") |
201 | + { |
202 | + initPluginActions ((void *) this); |
203 | } |
204 | |
205 | - screen->initPluginForScreen (p); |
206 | - return true; |
207 | + return screen->initPluginForScreen (p); |
208 | } |
209 | |
210 | void |
211 | @@ -246,29 +227,21 @@ |
212 | const gchar* |
213 | UnityScreen::GetName () |
214 | { |
215 | - return "Unity"; |
216 | -} |
217 | - |
218 | -/* This gets called whenever the window needs to be repainted. WindowPaintAttrib gives you some |
219 | - * attributes like brightness/saturation etc to play around with. GLMatrix is the window's |
220 | - * transformation matrix. the unsigned int is the mask, have a look at opengl.h on what you can do |
221 | - * with it */ |
222 | -bool |
223 | -UnityWindow::glPaint (const GLWindowPaintAttrib &attrib, // Brightness, Saturation, Opacity etc |
224 | - const GLMatrix &transform, // Transformation Matrix |
225 | - const CompRegion ®ion, // Repaint region |
226 | - unsigned int mask) // Other flags. See opengl.h |
227 | -{ |
228 | - bool ret; |
229 | - ret = gWindow->glPaint (attrib, transform, region, mask); |
230 | - return ret; |
231 | -} |
232 | - |
233 | + return "Unity"; |
234 | +} |
235 | + |
236 | +/* handle window painting in an opengl context |
237 | + * |
238 | + * we want to paint underneath other windows here, |
239 | + * so we need to find if this window is actually |
240 | + * stacked on top of one of the nux input windows |
241 | + * and if so paint nux and stop us from painting |
242 | + * other windows or on top of the whole screen */ |
243 | bool |
244 | UnityWindow::glDraw (const GLMatrix &matrix, |
245 | - GLFragment::Attrib &attrib, |
246 | - const CompRegion ®ion, |
247 | - unsigned int mask) |
248 | + GLFragment::Attrib &attrib, |
249 | + const CompRegion ®ion, |
250 | + unsigned int mask) |
251 | { |
252 | if (uScreen->doShellRepaint && uScreen->allowWindowPaint) |
253 | { |
254 | @@ -287,98 +260,8 @@ |
255 | |
256 | return ret; |
257 | } |
258 | -/* This get's called whenever a window's rect is damaged. You can do stuff here or you can adjust the damage |
259 | - * rectangle so that the window will update properly. Part of the CompositeWindowInterface. |
260 | - */ |
261 | - |
262 | -bool |
263 | -UnityWindow::damageRect (bool initial, // initial damage? |
264 | - const CompRect &rect) // The actual rect. Modifyable. |
265 | -{ |
266 | - bool ret; |
267 | - |
268 | - ret = cWindow->damageRect (initial, rect); |
269 | - |
270 | - return ret; |
271 | -} |
272 | - |
273 | -/* This is called whenever the window is focussed */ |
274 | - |
275 | -bool |
276 | -UnityWindow::focus () |
277 | -{ |
278 | - bool ret; |
279 | - |
280 | - ret = window->focus (); |
281 | - |
282 | - return ret; |
283 | -} |
284 | - |
285 | -/* This is called whenever the window is activated */ |
286 | - |
287 | -void |
288 | -UnityWindow::activate () |
289 | -{ |
290 | - window->activate (); |
291 | -} |
292 | - |
293 | -/* This is called whenever the window must be placed. You can alter the placement position by altering |
294 | - * the CompPoint & */ |
295 | - |
296 | -bool |
297 | -UnityWindow::place (CompPoint &point) |
298 | -{ |
299 | - bool ret; |
300 | - |
301 | - ret = window->place (point); |
302 | - return ret; |
303 | -} |
304 | - |
305 | -/* This is called whenever the window is moved. It tells you how far it's been moved and whether that |
306 | - * move should be immediate or animated. (Immediate is usually for a sudden move, false for that |
307 | - * usually means the user moved the window */ |
308 | - |
309 | -void |
310 | -UnityWindow::moveNotify (int dx, |
311 | - int dy, |
312 | - bool immediate) |
313 | -{ |
314 | - window->moveNotify (dx, dy, immediate); |
315 | -} |
316 | - |
317 | -/* This is called whenever the window is resized. It tells you how much the window has been resized */ |
318 | - |
319 | -void |
320 | -UnityWindow::resizeNotify (int dx, |
321 | - int dy, |
322 | - int dwidth, |
323 | - int dheight) |
324 | -{ |
325 | - window->resizeNotify (dx, dy, dwidth, dheight); |
326 | -} |
327 | - |
328 | -/* This is called when another plugin deems a window to be 'grabbed'. You can't actually 'grab' a |
329 | - * window in X, but it is useful in case you need to know when a user has grabbed a window for some reason */ |
330 | - |
331 | -void |
332 | -UnityWindow::grabNotify (int x, |
333 | - int y, |
334 | - unsigned int state, |
335 | - unsigned int mask) |
336 | -{ |
337 | - window->grabNotify (x, y, state, mask); |
338 | -} |
339 | - |
340 | -/* This is called when a window in released from a grab. See above */ |
341 | - |
342 | -void |
343 | -UnityWindow::ungrabNotify () |
344 | -{ |
345 | - window->ungrabNotify (); |
346 | -} |
347 | - |
348 | -/* This is called when another misc notification arises, such as Map/Unmap etc */ |
349 | - |
350 | + |
351 | +/* Called whenever a window is mapped, unmapped, minimized etc */ |
352 | void |
353 | UnityWindow::windowNotify (CompWindowNotify n) |
354 | { |
355 | @@ -388,7 +271,7 @@ |
356 | window->windowNotify (n); |
357 | } |
358 | |
359 | - |
360 | +/* Configure callback for the launcher window */ |
361 | void |
362 | UnityScreen::launcherWindowConfigureCallback(int WindowWidth, int WindowHeight, nux::Geometry& geo, void *user_data) |
363 | { |
364 | @@ -396,13 +279,14 @@ |
365 | geo = nux::Geometry(0, 24, geo.width, OurWindowHeight); |
366 | } |
367 | |
368 | +/* Configure callback for the panel window */ |
369 | void |
370 | UnityScreen::panelWindowConfigureCallback(int WindowWidth, int WindowHeight, nux::Geometry& geo, void *user_data) |
371 | { |
372 | geo = nux::Geometry(0, 0, WindowWidth, 24); |
373 | } |
374 | |
375 | - |
376 | +/* Start up nux after OpenGL is initialized */ |
377 | void |
378 | UnityScreen::initUnity(nux::NThread* thread, void* InitData) |
379 | { |
380 | @@ -418,6 +302,7 @@ |
381 | damageNuxRegions (); |
382 | } |
383 | |
384 | +/* Handle option changes and plug that into nux windows */ |
385 | void |
386 | UnityScreen::optionChanged (CompOption *opt, |
387 | UnityshellOptions::Options num) |
388 | @@ -436,8 +321,8 @@ |
389 | } |
390 | } |
391 | |
392 | -UnityScreen::UnityScreen (CompScreen *screen) :// The constructor takes a CompScreen *, |
393 | - PluginClassHandler <UnityScreen, CompScreen> (screen), // Initiate PluginClassHandler class template |
394 | +UnityScreen::UnityScreen (CompScreen *screen) : |
395 | + PluginClassHandler <UnityScreen, CompScreen> (screen), |
396 | screen (screen), |
397 | cScreen (CompositeScreen::get (screen)), |
398 | gScreen (GLScreen::get (screen)), |
399 | @@ -451,10 +336,10 @@ |
400 | gtk_init (NULL, NULL); |
401 | |
402 | XSetErrorHandler (old_handler); |
403 | - |
404 | - ScreenInterface::setHandler (screen); // Sets the screen function hook handler |
405 | - CompositeScreenInterface::setHandler (cScreen); // Ditto for cScreen |
406 | - GLScreenInterface::setHandler (gScreen); // Ditto for gScreen |
407 | + |
408 | + /* Wrap compiz interfaces */ |
409 | + ScreenInterface::setHandler (screen); |
410 | + GLScreenInterface::setHandler (gScreen); |
411 | |
412 | StartupNotifyService::Default ()->SetSnDisplay (screen->snDisplay (), screen->screenNum ()); |
413 | |
414 | @@ -469,22 +354,21 @@ |
415 | wt->Run (NULL); |
416 | uScreen = this; |
417 | |
418 | - debugger = new IntrospectionDBusInterface (this); |
419 | + debugger = new IntrospectionDBusInterface (this); |
420 | |
421 | PluginAdapter::Initialize (screen); |
422 | |
423 | optionSetLauncherAutohideNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2)); |
424 | optionSetLauncherFloatNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2)); |
425 | + |
426 | + g_timeout_add (0, &UnityScreen::initPluginActions, this); |
427 | } |
428 | |
429 | -/* This is the destructor. It is called when the class is destroyed. If you allocated any |
430 | - * memory or need to do some cleanup, here is where you do it. Note the tilde (~)? |
431 | - */ |
432 | - |
433 | UnityScreen::~UnityScreen () |
434 | { |
435 | } |
436 | |
437 | +/* Can't create windows until after we have initialized everything */ |
438 | gboolean UnityScreen::strutHackTimeout (gpointer data) |
439 | { |
440 | UnityScreen *self = (UnityScreen*) data; |
441 | @@ -501,6 +385,7 @@ |
442 | return FALSE; |
443 | } |
444 | |
445 | +/* Start up the launcher */ |
446 | void UnityScreen::initLauncher (nux::NThread* thread, void* InitData) |
447 | { |
448 | UnityScreen *self = (UnityScreen*) InitData; |
449 | @@ -551,36 +436,26 @@ |
450 | self->panelWindow->InputWindowEnableStruts(true); |
451 | |
452 | g_timeout_add (2000, &UnityScreen::strutHackTimeout, self); |
453 | - |
454 | - /*self->launcher->SetAutohide (true, (nux::View*) self->panelView->HomeButton ()); |
455 | - self->launcher->SetFloating (true);*/ |
456 | } |
457 | |
458 | +/* Window init */ |
459 | UnityWindow::UnityWindow (CompWindow *window) : |
460 | - PluginClassHandler <UnityWindow, CompWindow> (window), // Initiate our PrivateHandler class template |
461 | - window (window), |
462 | - cWindow (CompositeWindow::get (window)), |
463 | + PluginClassHandler <UnityWindow, CompWindow> (window), |
464 | + window (window), |
465 | gWindow (GLWindow::get (window)) |
466 | { |
467 | - WindowInterface::setHandler (window); // Sets the window function hook handler |
468 | - CompositeWindowInterface::setHandler (cWindow); // Ditto for cWindow |
469 | - GLWindowInterface::setHandler (gWindow); // Ditto for gWindow |
470 | + WindowInterface::setHandler (window); |
471 | + GLWindowInterface::setHandler (gWindow); |
472 | } |
473 | |
474 | UnityWindow::~UnityWindow () |
475 | { |
476 | } |
477 | |
478 | -/* This is the very first function compiz calls. It kicks off plugin initialization */ |
479 | - |
480 | +/* vtable init */ |
481 | bool |
482 | UnityPluginVTable::init () |
483 | { |
484 | - /* Calls to checkPluginABI check the ABI of a particular plugin to see if it is loaded |
485 | - * and in sync with your current build. If it fails the plugin will not load otherwise |
486 | - * compiz will crash. |
487 | - */ |
488 | - |
489 | if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION)) |
490 | return false; |
491 | if (!CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI)) |
492 | |
493 | === modified file 'src/unity.h' |
494 | --- src/unity.h 2010-11-25 07:10:40 +0000 |
495 | +++ src/unity.h 2010-11-25 16:12:10 +0000 |
496 | @@ -2,6 +2,7 @@ |
497 | * unity.h |
498 | * |
499 | * Copyright (c) 2008 Sam Spilsbury <smspillaz@gmail.com> |
500 | + * Copyright (c) 2010 Canonical Ltd. |
501 | * |
502 | * This program is free software; you can redistribute it and/or |
503 | * modify it under the terms of the GNU General Public License |
504 | @@ -18,27 +19,11 @@ |
505 | * not be able to re-use it if you want to use a different licence. |
506 | */ |
507 | |
508 | -/* The include path is set to /PREFIX/include/compiz in the Makefile, so you |
509 | - * don't need to worry about not being able to find compiz headers */ |
510 | - |
511 | #include <core/core.h> |
512 | - |
513 | -/* You need to include this in order to get access to the CompPrivate templates */ |
514 | - |
515 | #include <core/pluginclasshandler.h> |
516 | - |
517 | -/* Compositing is no longer built in by-default, so you need to include the interface |
518 | - * of the composite plugin. |
519 | - */ |
520 | - |
521 | #include <composite/composite.h> |
522 | - |
523 | -/* OpenGL support is now no longer built in by-default as well. You have to use the |
524 | - * interface of the opengl plugin if you want to do anything with that. */ |
525 | - |
526 | #include <opengl/opengl.h> |
527 | |
528 | -/* This is the options class header created for us automatically on build with BCOP */ |
529 | #include "unityshell_options.h" |
530 | |
531 | #include "Introspectable.h" |
532 | @@ -49,118 +34,65 @@ |
533 | #include <Nux/WindowThread.h> |
534 | #include <sigc++/sigc++.h> |
535 | |
536 | -/* This is your base screen class. This class definition can be considered the top most |
537 | - * as there is no multi-screen or multi-display support in compiz++, only one compiz |
538 | - * instance per screen. |
539 | - */ |
540 | - |
541 | +/* base screen class */ |
542 | class UnityScreen : |
543 | - public Introspectable, |
544 | + public Introspectable, |
545 | public sigc::trackable, |
546 | - /* You should inherit the ScreenInterface class if you want to dynamically hook |
547 | - * screen-level core functions. */ |
548 | public ScreenInterface, |
549 | - /* Same goes for screen functions in the composite plugin */ |
550 | public CompositeScreenInterface, |
551 | - /* And opengl plugin */ |
552 | public GLScreenInterface, |
553 | - /* This sets up a privates handler, where you can access an instance of your class for |
554 | - * every CompScreen object (same goes for UnityWindow and CompWindow). It adds the |
555 | - * member function ::get, which will allow you get an instance of this class from a |
556 | - * CompScreen * object. Oh, and the memory management is done for you now ^_^ |
557 | - */ |
558 | public PluginClassHandler <UnityScreen, CompScreen>, |
559 | - /* And finally, because we are using BCOP to generate our options, it creates a class |
560 | - * with a bunch of getters and setters that are added to out class when we inherit it. Yay. |
561 | - */ |
562 | public UnityshellOptions |
563 | { |
564 | |
565 | public: |
566 | |
567 | - /* Lets get into buisness. This is the constructor, it replaces the initScreen, initEtc |
568 | - * things that used to be in compiz and is called automatically when an instance of this |
569 | - * class is created. Notice how it is the same name as the class name. It has to be that way. |
570 | - */ |
571 | - |
572 | + /* Init */ |
573 | UnityScreen (CompScreen *s); |
574 | |
575 | - /* This is the destructor. It is called when the class is destroyed. If you allocated any |
576 | - * memory or need to do some cleanup, here is where you do it. Note the tilde (~)? |
577 | - */ |
578 | - |
579 | + /* Cleanup */ |
580 | ~UnityScreen (); |
581 | |
582 | - /* We store CompositeScreen, GLScreen, and CompScreen to avoid unecessary calls to ::get */ |
583 | + /* We store these to avoid unecessary calls to ::get */ |
584 | CompScreen *screen; |
585 | CompositeScreen *cScreen; |
586 | GLScreen *gScreen; |
587 | |
588 | - /* Now. Because we imported ScreenInterface and CompositeScreenInterface, we get all the |
589 | - * core functions in there for free. Here's the twist. Those functions are stored as 'virtual', |
590 | - * so they can be overridden. That is what we do here. So instead of a core function being called, |
591 | - * our own is |
592 | - */ |
593 | - |
594 | - /* This is the function that is called before the screen is 're-painted'. It is used for animation |
595 | - * and such because it gives you a time difference between when the last time the screen was repainted |
596 | - * and the current time of the execution of the functions in milliseconds). It's part of the composite |
597 | - * plugin's interface |
598 | - */ |
599 | - |
600 | - void |
601 | - preparePaint (int); |
602 | - |
603 | - /* This is the guts of the paint function. You can transform the way the entire output is painted |
604 | - * or you can just draw things on screen with openGL. The unsigned int here is a mask for painting |
605 | - * the screen, see opengl/opengl.h on how you can change it */ |
606 | - |
607 | + /* prepares nux for drawing */ |
608 | void |
609 | nuxPrologue (); |
610 | - |
611 | + |
612 | + /* pops nux draw stack */ |
613 | void |
614 | nuxEpilogue (); |
615 | - |
616 | - void |
617 | - paintDisplay (const CompRegion ®ion); |
618 | - |
619 | - bool |
620 | - glPaintOutput (const GLScreenPaintAttrib &, |
621 | - const GLMatrix &, const CompRegion &, |
622 | - CompOutput *, unsigned int); |
623 | - |
624 | - /* This is called when the output is transformed by a matrix. Basically the same, but core has |
625 | - * done a few things for us like clip planes etc */ |
626 | - |
627 | - void |
628 | - glPaintTransformedOutput (const GLScreenPaintAttrib &, |
629 | - const GLMatrix &, const CompRegion &, |
630 | - CompOutput *, unsigned int); |
631 | - |
632 | - |
633 | - /* This is called after screen painting is finished. It gives you a chance to do any cleanup and or |
634 | - * call another repaint with screen->damageScreen (). It's also part of the composite plugin's |
635 | - * interface. |
636 | - */ |
637 | - |
638 | - void |
639 | - donePaint (); |
640 | - |
641 | - /* This is our event handler. It directly hooks into the screen's X Event handler and allows us to handle |
642 | - * our raw X Events |
643 | - */ |
644 | - |
645 | - void |
646 | - handleEvent (XEvent *); |
647 | - |
648 | + |
649 | + /* nux draw wrapper */ |
650 | + void paintDisplay (const CompRegion ®ion); |
651 | + |
652 | + /* paint on top of all windows if we could not find a window |
653 | + * to paint underneath */ |
654 | + bool glPaintOutput (const GLScreenPaintAttrib &, |
655 | + const GLMatrix &, |
656 | + const CompRegion &, |
657 | + CompOutput *, |
658 | + unsigned int); |
659 | + |
660 | + /* paint in the special case that the output is transformed */ |
661 | + void glPaintTransformedOutput (const GLScreenPaintAttrib &, |
662 | + const GLMatrix &, |
663 | + const CompRegion &, |
664 | + CompOutput *, |
665 | + unsigned int); |
666 | + |
667 | + /* handle X11 events */ |
668 | + void handleEvent (XEvent *); |
669 | + |
670 | + /* handle option changes and change settings inside of the |
671 | + * panel and dock views */ |
672 | void optionChanged (CompOption *, Options num); |
673 | |
674 | - |
675 | - bool |
676 | - initPluginForScreen (CompPlugin *p); |
677 | - |
678 | - bool doShellRepaint; |
679 | - bool allowWindowPaint; |
680 | + /* init plugin actions for screen */ |
681 | + bool initPluginForScreen (CompPlugin *p); |
682 | |
683 | protected: |
684 | |
685 | @@ -169,6 +101,9 @@ |
686 | void AddProperties (GVariantBuilder *builder); |
687 | |
688 | private: |
689 | + |
690 | + static gboolean |
691 | + initPluginActions (gpointer data); |
692 | |
693 | static void |
694 | initLauncher (nux::NThread* thread, void* InitData); |
695 | @@ -200,13 +135,15 @@ |
696 | nux::Geometry lastTooltipArea; |
697 | IntrospectionDBusInterface *debugger; |
698 | |
699 | - friend class UnityWindow; |
700 | + /* handle paint order */ |
701 | + bool doShellRepaint; |
702 | + bool allowWindowPaint; |
703 | + |
704 | + friend class UnityWindow; |
705 | }; |
706 | |
707 | class UnityWindow : |
708 | - /* Same for Unity Screen, inherit interfaces, private handlers, options */ |
709 | public WindowInterface, |
710 | - public CompositeWindowInterface, |
711 | public GLWindowInterface, |
712 | public PluginClassHandler <UnityWindow, CompWindow> |
713 | { |
714 | @@ -214,77 +151,23 @@ |
715 | public: |
716 | |
717 | /* Constructors, destructors etc */ |
718 | - |
719 | UnityWindow (CompWindow *); |
720 | ~UnityWindow (); |
721 | |
722 | - /* We store CompositeWindow, GLWindow, and CompWindow to avoid unecessary calls to ::get */ |
723 | CompWindow *window; |
724 | - CompositeWindow *cWindow; |
725 | - GLWindow *gWindow; |
726 | - |
727 | - /* This gets called whenever the window needs to be repainted. WindowPaintAttrib gives you some |
728 | - * attributes like brightness/saturation etc to play around with. GLMatrix is the window's |
729 | - * transformation matrix. the unsigned int is the mask, have a look at opengl.h on what you can do |
730 | - * with it */ |
731 | - |
732 | - bool |
733 | - glPaint (const GLWindowPaintAttrib &, const GLMatrix &, |
734 | - const CompRegion &, unsigned int); |
735 | + GLWindow *gWindow; |
736 | |
737 | + /* basic window draw function */ |
738 | bool |
739 | glDraw (const GLMatrix &matrix, |
740 | GLFragment::Attrib &attrib, |
741 | const CompRegion ®ion, |
742 | unsigned int mask); |
743 | |
744 | - /* This get's called whenever a window's rect is damaged. You can do stuff here or you can adjust the damage |
745 | - * rectangle so that the window will update properly. Part of the CompositeWindowInterface. |
746 | - */ |
747 | - |
748 | - bool |
749 | - damageRect (bool, const CompRect &); |
750 | - |
751 | - /* This is called whenever the window is focussed */ |
752 | - bool |
753 | - focus (); |
754 | - |
755 | - /* This is called whenever the window is activated */ |
756 | - void |
757 | - activate (); |
758 | - |
759 | - /* This is called whenever the window must be placed. You can alter the placement position by altering |
760 | - * the CompPoint & */ |
761 | - bool |
762 | - place (CompPoint &); |
763 | - |
764 | - /* This is called whenever the window is moved. It tells you how far it's been moved and whether that |
765 | - * move should be immediate or animated. (Immediate is usually for a sudden move, false for that |
766 | - * usually means the user moved the window */ |
767 | - void |
768 | - moveNotify (int, int, bool); |
769 | - |
770 | - /* This is called whenever the window is resized. It tells you how much the window has been resized */ |
771 | - void |
772 | - resizeNotify (int, int, int, int); |
773 | - |
774 | - /* This is called when another plugin deems a window to be 'grabbed'. You can't actually 'grab' a |
775 | - * window in X, but it is useful in case you need to know when a user has grabbed a window for some reason */ |
776 | - void |
777 | - grabNotify (int, int, unsigned int, unsigned int); |
778 | - |
779 | - /* This is called when a window in released from a grab. See above */ |
780 | - void |
781 | - ungrabNotify (); |
782 | - |
783 | - /* This is called when another misc notification arises, such as Map/Unmap etc */ |
784 | - void |
785 | - windowNotify (CompWindowNotify); |
786 | + void windowNotify (CompWindowNotify n); |
787 | |
788 | }; |
789 | |
790 | -/* Most plugins set up macros to access their Screen and Window classes based on a CompScreen * or CompWindow * */ |
791 | - |
792 | #define EX_SCREEN (screen) \ |
793 | UnityScreen *es = UnityScreen::get (screen); |
794 | |
795 | @@ -295,15 +178,10 @@ |
796 | */ |
797 | |
798 | class UnityPluginVTable : |
799 | - /* Inheriting CompPlugin::VTableForScreenAndWindow <ScreenClass, WindowClass> |
800 | - * automatically does most of the vTable setup for you */ |
801 | public CompPlugin::VTableForScreenAndWindow<UnityScreen, UnityWindow> |
802 | { |
803 | public: |
804 | |
805 | - /* You MUST have this function. Compiz calls this function first off and that |
806 | - * is what kick-starts your initialization procedure. It must be named |
807 | - * _exactly_ init too */ |
808 | - |
809 | + /* kickstart initialization */ |
810 | bool init (); |
811 | }; |
812 | |
813 | === modified file 'unityshell.xml.in' |
814 | --- unityshell.xml.in 2010-11-12 10:58:04 +0000 |
815 | +++ unityshell.xml.in 2010-11-25 16:12:10 +0000 |
816 | @@ -5,7 +5,30 @@ |
817 | <_long>Plugin to draw the Unity Shell</_long> |
818 | <deps> |
819 | <relation type="after"> |
820 | + <plugin>bailer</plugin> |
821 | + <plugin>detection</plugin> |
822 | + <plugin>composite</plugin> |
823 | + <plugin>opengl</plugin> |
824 | + <plugin>mousepoll</plugin> |
825 | + <plugin>move</plugin> |
826 | + <plugin>resize</plugin> |
827 | <plugin>decor</plugin> |
828 | + <plugin>compiztoolbox</plugin> |
829 | + <plugin>place</plugin> |
830 | + <plugin>session</plugin> |
831 | + <plugin>animation</plugin> |
832 | + <plugin>regex</plugin> |
833 | + <plugin>cube</plugin> |
834 | + <plugin>rotate</plugin> |
835 | + <plugin>cubeaddon</plugin> |
836 | + <plugin>gnomecompat</plugin> |
837 | + <plugin>vpswitch</plugin> |
838 | + <plugin>fade</plugin> |
839 | + <plugin>staticswitcher</plugin> |
840 | + <plugin>scale</plugin> |
841 | + <plugin>expo</plugin> |
842 | + <plugin>ezoom</plugin> |
843 | + <plugin>wall</plugin> |
844 | </relation> |
845 | <requirement> |
846 | <plugin>opengl</plugin> |
+1