• Immutable Page
  • Info
  • Attachments

Virtually all plugins need to store some data of some sort, and in most cases it has to be attached to a core structure. An example of this would be storing the progress of an animation when transforming the screen or the opacity of a window in the Fading Windows plugin.

To achieve this, plugins can request an index for access to base.privates in a CompDisplay, CompScreen and CompWindow. The displayPrivateIndex is stored in a file-scope of plugins, usually visible at the top of a plugin's code. The plugin's initDisplay () will request this index and allocate memory for the structure, then attach the structure to d->base.privates[displayPrivateIndex] (which is a union, so d->base.privates[displayPrivateIndex].ptr).

For the other indexes, the same process applies, except the screenPrivateIndex is usually stored in the plugin's Display structure, and the windowPrivateIndex in the plugin's Screen structure.

Most plugins set up macros to access these functions, usually called PLUGINNAME_DISPLAY (CompDisplay *d), for instance, which would result in a PluginnameDisplay *pd; variable, where the p is the initial of the plugin.

The Desktop Cube and Rotate Cube plugins also gained the capability to access each other's structures, which other plugins can use too. This is achieved by a core function that allows a plugin to request a displayPrivateIndex of another plugin; the rest is a matter of sharing a header.

Development/PluginStructures (last edited 2008-03-30 18:34:19 by localhost)