cs349 - s10 - Lecture 3

CS349 - Implementing User Interfaces - Spring 2010

Public Service Annoucements

  1. Course notes
  2. Assignments

Lecture 3 - Xlib Graphics

Basic Abstraction

Surface to draw on

Pointing device

Sharing the Hardware

Multiple applications using one resource need synchronization. Notice that the display is extended in both space and time.

BWS supplies overlapping windows

How should windows be controlled? By the user, of course.

Providing Windows in X

  1. Open the display
  2. Create a window
  3. Provide the window with a graphics context
  4. Select the input to be provided
  5. Map the window to the screen

The Graphics Model of X

  1. A set of commands that draw items on the display
  2. A graphics context

Better graphics models exist today, but all are descended from X

Graphics Tricks

Repainting the Canvas

Do all repainting in one function, so that you have the program structure

Initialize( );
while ( true ) {
    if ( ( evt = get-next-event( ) ) ) == ERROR ) exit( );
        switch ( evt.type ) {
        case XXX:
        repaint( );

To repaint

  1. Clear the screen
  2. Use the painter's algorithm
  3. Flush the buffer

Two performance killers

Expose events

Expose events are usually created in clusters, often big clusters

The count field is zero only if the next event is not an expose event

Return to: