/****** w3.C ******/ #include #include #include #include #include #include int main() { Display *disp; int ScrNum; GC prGC; XEvent Evnt; Window win; char str[100]="Hello world!"; if ( (disp = XOpenDisplay (NULL)) == NULL) { printf("\n====1"); exit(1); } ScrNum = DefaultScreen( disp ); win = XCreateSimpleWindow( disp, RootWindow( disp, ScrNum), 0, 0, 100, 100, 2, BlackPixel( disp, ScrNum), WhitePixel( disp, ScrNum) ); XSelectInput( disp, win, ExposureMask|KeyPressMask ); XMapWindow (disp,win); while( 1 ) { XNextEvent( disp, &Evnt); switch (Evnt.type) { case Expose: if ( Evnt.xexpose.count!=0 ) break; prGC = XCreateGC( disp, win, 0, NULL ); XSetForeground( disp, prGC, BlackPixel(disp, 0) ); XDrawString( disp, win, prGC, 10,50, str, strlen(str) ); XFreeGC( disp, prGC ); break; case KeyPress: goto fin; } } fin: XCloseDisplay( disp ); return 0; }