cs349 - s10 - Lecture 2

CS349 - Implementing User Interfaces - Spring 2010

Public Service Annoucements

  1. Course notes
  2. Assignments

Lecture 2 - Graphics Abstractions for User Interfaces


An operating system provides, among other things, an abstraction of the hardware in the form of

When there is a user interface, this includes the hardware that provides the interface

The base window system (BWS) provides the lowest level abstraction, which consists of

  1. a display screen divided into a rectangular array of pixels, which includes
  2. an audio device, which includes
  3. a collection of button devices
  4. a collection of pointing devices, each of which includes

The input devices, the last two, have an interesting feature

And one problematic feature


To avoid the necessity for polling

most BWSs abstract input into a time-ordered sequence of events, usually called the event queue.

Data structure

typedef struct{
     int time;
     Type type;
     Whatever parameters;
} Event;


evt = get-next-event( );

The Event Loop

Basic code structure

evt = get-next-event( ) {
    switch( evt.type ) {
    case KEYSTROKE:
        if ( evt.parameters.byte == 'q' ) exit( 0 );

This is made for an object-oriented programming style, which is why we like Java.


X is a BWS based on a network. That is,

Many properties of X are the side effects of reducing communication bandwidth between the X-server and its clients.

Return to: