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 ) {
case ExposureEvent:
while ( evt.count > ) XNextEvent( display, &evt );
break;
...
}
step-animation-forward( )
repaint( )
now = gettimeofday( );
working = now - start
if ( working > LoopTime ) {
// Report overtime
} else {
utime( LoopTime - working )
}
}
The Event Loop is
For full-featured interfaces X has
There are two important steps in the evolution of interface architectures since X
This is called the `wheel of reincarnation'.
Return to: