cs349 - s10 - Lecture 6

CS349 - Implementing User Interfaces - Spring 2010

Public Service Annoucements

  1. Assignment 1

Lecture 6 - Inializing Xlib Interfaces


display = XOpenDisplay( "" )  // Argument is the display (e.g. citrine:0.0)
screen = DefaultScreen( display )
    bg = WhitePixel( display, screen )
    fg = BlackPixel( display, screen )
//
initSizeHints ( ..., &sizeHints )
window = XCreateSimpleWindow( display,
         DefaultRootWindow( display ),
         hint.s, hint.y, hint.width, hint.height,
         borderwidth, bordercolour, bg )
XSetStandardProperties( display, window, name, iconName, iconPixmap, argv, argc, &sizeHints )
gc = XCreateGC( diplay, window, valuemask, values )
    XSetBackground( display, gc, bg )
    XSetForeground( display, gc, fg )
XSelectInput( display, window, ButtonPressMask | KeyPressMask | ExposureMask )
XMapRaised( display, window )
// Now ready to start the event loop
while( true ) {
    start = gettimeofday( );
    if ( XEventsQueued( display, QueuedAlready ) > 0 ) {
        XNextEvent( display, &evt )
        switch ( evt.type ) {
        ...
        }
    animate( )
    repaint( )
    now = gettimeofday( );
    working = now - start
    if ( working > LoopTime ) {
        // Report overtime
    } else {
         utime( LoopTime - working )
    }
}


Return to: