<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1" title="Xlib - Page 13 - Wikipedia">
<p>
<a accesskey="1" href="page.php?w=Xlib&amp;p=12">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Xlib&amp;p=14">3.Next</a>
</p>
<p>square in it:<syntaxhighlight lang=C>/*    Simple Xlib application for creating a window and drawing a box in it.    gcc input.c -o output -lX11<br/>
*/ <br/>
#include <X11/Xlib.h><br/>
#include <stdio.h><br/>
#include <stdlib.h><br/>
#include <string.h> int main(void){    Display *display;    Window window;    XEvent event;    char *msg = "Hello, World!";    int s;     // open connection to the server    display = XOpenDisplay(NULL);    if (display == NULL)    {        fprintf(stderr, "Cannot open display\n");        exit(1);    }     s = DefaultScreen(display);     // create window    window = XCreateSimpleWindow(display, RootWindow(display, s), 10, 10, 200, 200, 1,                                 BlackPixel(display, s), WhitePixel(display, s));     // select kind of events we are interested in    XSelectInput(display, window, ExposureMask | KeyPressMask);     // map (show) the window    XMapWindow(display, window);     // event loop    for (;;)    {        XNextEvent(display, &event);         // draw or redraw the window        if (event.type == Expose)        {            XFillRectangle(display, window, DefaultGC(display, s), 20, 20, 10, 10);            XDrawString(display, window, DefaultGC(display, s), 50, 50, msg, strlen(msg));        }        // exit on key press        if (event.type == KeyPress)            break;    }     // close connection to the server    XCloseDisplay(display);     return 0; }</string.h></stdlib.h></stdio.h></x11/xlib.h></syntaxhighlight></p><p>
<a accesskey="1" href="page.php?w=Xlib&amp;p=12">1.Previous</a><br />
<a accesskey="3" href="page.php?w=Xlib&amp;p=14">3.Next</a>
</p>

<do type="prev" label="Search">
        <go href="search.wml"/>
</do>

</card>
</wml>
