/****** w6.C ******/ #include #include #include #include #include #include int main() { Display *disp; int ScrNum; GC prGC; XEvent Evnt; Window win; int i=0,n_call=0,fonts_number; char str[100]="Hello world!", **list; // Font font; if ( (disp = XOpenDisplay (NULL)) == NULL) { printf("\n====1"); exit(1); } list = XListFonts( disp, "*", 10000, &fonts_number); 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 | ButtonPressMask); XMapWindow (disp,win); while( 1 ) { XNextEvent( disp, &Evnt); switch (Evnt.type) { case ButtonPress: goto fin; case Expose: if ( Evnt.xexpose.count!=0 ) break; prGC = XCreateGC( disp, win, 0, NULL ); //XSetFont(disp, prGC, font); XSetForeground( disp, prGC, BlackPixel(disp, 0) ); XDrawString( disp, win, prGC, 10,50, str, strlen(str) ); XFreeGC( disp, prGC ); n_call++; sprintf(str,"Hello... %d",n_call); break; case KeyPress: goto fin; } } fin: XCloseDisplay( disp ); for(i=0; i