The "class library" in the X windows system provides a collection of widgets that can be used to build applications.
Sizing and placement of these widgets is controlled by a geometry manager. widgets do not even appear on the screen unless they are controlled by a geometry manager. On the Suns in B/L 244 the default geometry manger is ovlm (overlay window manager). Other managers are available.
Here is the "Hello World" program written for X. (In ANSI C)
#include#include #define HELLO "hello world" main(int argc, char **argv) { Display *display; // X server connection Window *win; // Window ID GC gc; // Grpahics context int bw = 2 // Border width int bc = BlackPixel; // Border color int bgc = WhitePixel; // Window background color XSizeHints hints; // Window sizing hints XEvent event; // Event data Structure // Open the display display = XOpenDisplay(NULL); // Set hints for window size and position hints.x = 200; hints.y = 200; hints.width=300; hints.height=200; hints.flags= PPosition| PSize; // Create the window win = XCreateSimpleWindow(display, DefaultRootWindow(display), hints.x, hints.y, hints.width, hints.heigth, bw, bc, bgc); XSetStandardProperties(display, win, HELLO, HELLO, argv, argc, &hints); // Create a grpahics context for writing the text gc = XCreateGC(dispaly, win, NULL, NULL); // Specify events of interest (only exposure) XSelectInput(display, win, ExposureMask); XMapWindow(display, win); // Show the window // Event loop while (TRUE) { XNextEvent(display, &event); // Discard all but the most recent expose event if (event.type == Expose && event.xexpose.count == 0){ int x, y; while (XCheckTypedEvent(display, Expose, &Event)); XClearWindow(display, win); //******** Print "hello world" !! ****** XDrawImageString(display, win, gc, 50, 50 HELLO, strlen(HELLO)); } //End if } // end while exit(0); }
An Xlib program xclk
An Xt (Athena) program
Last Changed: 2 July 1995