• Immutable Page
  • Info
  • Attachments

Wrappable Functions

Compiz provides an interface for plugins to 'hook' core functions so that they can perform their own operations when these functions are called. This is the basis to how compiz plugins works. By using this interface you can handle events (input) and draw stuff on screen (output) or do whatever you want. Below is a list of functions which can be hooked and typically what plugins do in them:



ScreenInterface::handleEvent (XEvent *)

In the handleEvent function, you are given an XEvent * structure which compiz receives when it checks for new X Events. Here you can check for input or check if window properties have changed. There are a whole range and different events and it would be superfluous to list them here - instead look into this function for other plugins to see what kind of events they handle.

Typically, you might update some internal variables here depending on what event happened.

Screen Wrappable Functions

All these functions apply to an instance of compiz running on some X screen. In 0.8, a handful of these are actually on the display level, but this is being deprecated



CompositeScreenInterface::preparePaint (int)

In this function, all calculations that happen prior to painting the screen happen. You are given the number of seconds since the last time the screen was painted - this is used mainly for animation.



CompositeScreenInteface::paint (CompOutput::ptrList &outputs)

This is rarely used. Here, you would modify which outputs are painted and how they are painted (fullscreen, etc)



GLScreenInterface::glPaintOutput (const GLScreenPaintAttrib &, const GLMatrix &, const CompRegion &, CompOutput *, unsigned int)

This is where output happens. If you need to draw something or modify the paint attributes of _all_ windows on the screen, this is where it happens.

Modifying the paint attributes of the screen

The ScreenPaintAttrib and GLScreenPaintAttrib contain information about the general paint attributes to the screen such as brightness, saturation and opacity. Usually you don't need to touch anything else here

The GLMatrix and CompTransform objects are 4x4 3D transformation matricies similar to the ones used by OpenGL. If you know math, it should be fairly obvious how they work so no need for a math lesson here. There are some internal functions such as rotate, translate and scale here to do some common matrix operations.

They are both const so to use them you need to copy them into a variable first, then modify and then put them back into the call chain.

Drawing stuff on screen

The compiz OpenGL context is ready for use at this point so you are free to use OpenGL to draw stuff on screen. The first thing you need to do though, is set a GLBegin () and GLEnd () to whenever you want to draw stuff. Also, you need to load the screen transformation matrix and make sure that is on-screen. To do that, use something like:


GLMatrix sTranform = transform;
sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);

glBegin ();
glLoadMatrixf (sTransform.getMatrix ());
glEnd ();

Another thing to remember is that all painting happens bottom-to-front, i.e everything that is painted first has things that are painted last painted on top of it. So, if you want to paint something underneath windows (don't know why, because most likely the desktop window will be on top), you would draw your stuff before you pass on control in the call-chain. In most cases you would want to draw stuff after you do this.

Paint flags

Another important part of this paint procedure is that there are a number of variables that control how painting works. Some of these are important to set when painting windows.

Development/zero-nine/InterfacesList (last edited 2010-07-25 12:04:47 by 124-169-107-122)