[compiz] re-work option initialization

David Reveman davidr at novell.com
Fri Mar 30 03:41:43 PDT 2007


On Thu, 2007-03-29 at 16:56 +0100, Mike Dransfield wrote:
> David Reveman wrote:
> > Dennis Kasprzyk and I have been discussing some changes to how options
> > are initialized.
> >
> > Problems with how options are currently initialized.
> >
> > 1. Helper functions are not used to initialize options, which means that
> > if we make a change to the option structure, all option initialization
> > code needs to be updated. Using helper functions will also reduces the
> > amount of duplicate code.
> >   
> 
> Maybe we could create a whole library of extra helper
> functions.  That way some people could do it without
> the helpers, or you can use them for speed of development.

Yes, it's probably a good idea to just go ahead and create a libcompiz
that plugins can choose to link to.

> 
> > 2. No convenient way to get the initial value of an option once it's
> > been modified.
> >   
> 
> No, this was my problem when writing ini.

Yes, I put it in the list of current problems as I remembered it from
the ini discussions. If we're changing things, it makes sense to make
sure that this gets fixed as well.

> 
> The way I see it is that gconf should be able to revert to
> the default easily, ini might need some work.
> 
> > Here's our current idea for how we can solve these issues:
> >
> > Add
> >
> > typedef Bool (*InitPlugin(Display|Screen)OptionProc) (CompOption *o,
> >                                                       int        index);
> >
> > or
> >
> > typedef Bool (*InitPlugin(Display|Screen)OptionsProc) (CompOption **o);
> >   
> 
> 
> Are these to replace the current getOptions items
> in the vtable?  Or are they more of a 'reset option' function?

No these are just additional functions that are used to initialize
options. The existing Get/SetPluginOption functions are still used to
get/set option values. However, we should also update the get/set
functions to accept an index if we select the init option function
prototype with an index. 

Example:

for (i = 0; i < p->vTable->nScreenOption; i++)
{
     CompOption op;

     (*p->vTable->initScreenOption) (p, i, &op);

     /* 'op' is is now initialized with default values for screen option 'i' */
}

> 
> Would it be possible to add a reference back to the plugin
> as well so that plugin loaders can handle options for other
> plugins?

Yes, it should be:

typedef Bool (*InitPlugin(Display|Screen)OptionProc) (CompPlugin *plugin,
                                                      CompOption *option,
                                                      int        index);

- David



More information about the compiz mailing list