Direct: Direct Screen Access example

Description

Direct demonstrates the window server's direct screen area (CDirectScreenAccess) interface.

The example has an engine, CLifeEngine, for the famous "Game of Life" algorithm, which generates grids of cells, each update being derived by simple rules from the previous generation. The initial configuration of the cells is random.

The UI simply has little user interaction. It simply draws the current grid using CDirectScreenAccess, and requests the engine to generate the next update. The UI classes are:

  • CDirectDisplayLife: the object that draws the grid through a CDirectScreenAccess, and which implements the API's MDirectScreenAccess callback interface, so that the window server can indicate when conditions (e.g. overlaying windows) change

  • CExampleAppView: the application's window, which owns the CDirectDisplayLife object

  • CExampleAppUi: handles commands and calls the view appropriately

Download

Click on the following link to download the example: Direct.zip

Click: browse to view the example code.

Usage

Commands are given to the example through its Lifemenu. The commands are:

  • Start: starts or restarts the life display

  • Test overlay: simulates a window from another program being placed partially over the display area. The display area is then clipped appropriately, so that the upper window is not overwritten

Note for developers

While the DSA is in operation, the client should not make any call to the Window Server (WSERV) that will affect the visible area of the window in which the DSA is taking place. If this happens, it will cause a temporary deadlock (since the client will be waiting for WSERV to make the requested window rearrangement, and WSERV will be waiting for the client to acknowledge that the DSA has aborted).