PhScrs
Photon Screensavers
For QNX Photon 2, QNX RTOS 6

SourceForge Logo

PhScrsE - PhScrs Screensaver Embedder Demo

When I started this project my first objective was gaining some experience with Photon and its toolkit. Usually I hate doing useless things so what about doing a screensaver? Why only one? Why don't write a little library? For those like me that have many years of experience with X11, Photon is very easy to understand but not as well documented. Especially if you want to use the underlyings of the api.

One of the cooler things that can be done with PhScrs is embed any screensaver into any region. By specifying a region ID the library gets some infos about this region (size and extents) and covers it with an opaque one that will be used as a normal drawing area. Since the specified region will be set as parent of the new one, the application that owns the specified region can effectively control where the drawing will appear and when. Also, when the parent region will be destroyed, the screensaver itself will exit with an error since its drawing area will be automatically destroyed.

Developing an "embedder" is quite simple. PhScrsE can be used as a guideline. It's developed using PhAb and can be downloaded from the standard download page or by cvs.

The only importat thing to rember when setting up an "embedder" is to set up correcly the widget that will contain the screensaver. You can use any widget (In PhScrsE I used a PtRaw) but you must rembeder to set Pt_REGION in the Flags. In this way the widget will use a private region instead of drawing on the same region as the parent. When Pt_REGION is set, you can use PtWidgetRid(...) to obtain the region id of a widget an pass it is an -r argument of any screensaver.

PhScrsE was developed to resemble the savercfg tool used by QNX RTOS 6. You can select a screensaver or enter its path directly (remember that only PhScrs Screensaver can be embedded, any other screensaver will ignore the -r switch and run in fullscreen mode), enter its options (by pressing the Infos button a new dialog will apprear with the contents of use screensaver) and start/stop it by toggling the Active button.

The main work of setting up the command line and starting the screensaver is done in the toggle_scr(...) function. You can look directly at it. You must also remember that you can't change "on the fly" the settings of a screensaver since these are specified on the command line. You can safely edit these in the option text box, but to apply them you must deactivate-reactivate the screensaver.

I'll don't discuss here the magics of the about box. Feel free to let me know if it was usefull.