b'\n_START_ARTICLE_\nXlib\n_START_SECTION_\nDatov\xc3\xa9 typy\n_START_PARAGRAPH_\nHlavn\xc3\xadm datov\xc3\xbdm typem v Xlibu je Display a typy identifik\xc3\xa1tor\xc5\xaf. Neform\xc3\xa1ln\xc4\x9b je Display fyzick\xc3\xa9 nebo virtu\xc3\xa1ln\xc3\xad za\xc5\x99\xc3\xadzen\xc3\xad, kde se prov\xc3\xa1d\xc3\xad ve\xc5\xa1ker\xc3\xa9 grafick\xc3\xa9 operace. Struktura typu Display v Xlib knihovn\xc4\x9b obsahuje informace o samotn\xc3\xa9m zobrazov\xc3\xa1n\xc3\xad, ale co je d\xc5\xafle\xc5\xbeit\xc4\x9bj\xc5\xa1\xc3\xad, obsahuje i informace t\xc3\xbdkaj\xc3\xadc\xc3\xad se toku informac\xc3\xad mezi klientem a serverem. Nap\xc5\x99\xc3\xadklad v Unixov\xc3\xa9m opera\xc4\x8dn\xc3\xadm syst\xc3\xa9mu obsahuj typ Display soubor ovl\xc3\xa1daj\xc3\xadc\xc3\xad socket grafick\xc3\xa9 karty. Typy Window, Pixmap, Font, Colormap a dal\xc5\xa1\xc3\xad jsou identifik\xc3\xa1tory, kter\xc3\xa9 jsou 32bitov\xc3\xa1 cel\xc3\xa1 \xc4\x8d\xc3\xadsla (typ integer). Klient si vytvo\xc5\x99\xc3\xad okno t\xc3\xadm, \xc5\xbee ode\xc5\xa1le po\xc5\xbeadavek na server, kter\xc3\xbd pak okno vytvo\xc5\x99\xc3\xad. Toto je v\xc5\xa1e provedeno pomoc\xc3\xad vol\xc3\xa1n\xc3\xad funkc\xc3\xad z knihovny Xlib, kter\xc3\xa1 vrac\xc3\xad identifik\xc3\xa1tory. Tyto identifik\xc3\xa1tory mohou b\xc3\xbdt pou\xc5\xbeity na vy\xc5\xbe\xc3\xa1d\xc3\xa1n\xc3\xad klienta op\xc4\x9bt na stejn\xc3\xa9m okn\xc4\x9b.\n_START_SECTION_\nProtokoly a ud\xc3\xa1losti\n_START_PARAGRAPH_\nXlib funkce, kter\xc3\xa9 odes\xc3\xadlaj\xc3\xad po\xc5\xbeadavek na server, obvykle nepos\xc3\xadlaj\xc3\xad tyto po\xc5\xbeadavky ihned, ale ukl\xc3\xa1daj\xc3\xad je do vyrovn\xc3\xa1vac\xc3\xad pam\xc4\x9bti (request buffer). Term\xc3\xadn po\xc5\xbeadavek znamen\xc3\xa1 v tomto p\xc5\x99\xc3\xadpad\xc4\x9b \xc5\xbe\xc3\xa1dost, kter\xc3\xa1 je rovnou od klienta p\xc5\x99esm\xc4\x9brov\xc3\xa1na na server. Request buffer m\xc5\xaf\xc5\xbee ve sv\xc3\xa9 pam\xc4\x9bti obsahovat v\xc4\x9bt\xc5\xa1inou v\xc5\xa1echny druhy po\xc5\xbeadavk\xc5\xaf, a to nejen ty, kter\xc3\xa9 maj\xc3\xad viditeln\xc3\xbd dopad na obrazovce. Request buffer tak\xc3\xa9 zaru\xc4\x8duje, \xc5\xbee v\xc5\xa1echny \xc5\xbe\xc3\xa1dosti budou odesl\xc3\xa1ny v\xc4\x8das na server, dokud nebudou zavol\xc3\xa1ny funkce XSync nebo XFlush, kter\xc3\xa9 po\xc5\xbeaduj\xc3\xad n\xc3\xa1vratov\xc3\xa9 hodnoty od serveru (tyto funkce jsou blokov\xc3\xa1ny dokud nejsou v\xc5\xa1echny odpov\xc4\x9bdi odesl\xc3\xa1ny). Xlib ukl\xc3\xa1d\xc3\xa1 p\xc5\x99ijat\xc3\xa9 ud\xc3\xa1losti do fronty. Klientsk\xc3\xa1 aplikace m\xc5\xaf\xc5\xbee prohled\xc3\xa1vat a z\xc3\xadsk\xc3\xa1vat ud\xc3\xa1losti z fronty. Zat\xc3\xadmco X server odes\xc3\xadl\xc3\xa1 ud\xc3\xa1losti asynchronn\xc4\x9b, aplikace vyu\xc5\xbe\xc3\xadvaj\xc3\xadc\xc3\xad knihovny Xlib po\xc5\xbeaduje nutn\xc4\x9b explicitn\xc3\xad vol\xc3\xa1n\xc3\xad funkc\xc3\xad Xlib pro p\xc5\x99\xc3\xadstup k ud\xc3\xa1lostem stoj\xc3\xadc\xc3\xadch ve front\xc4\x9b. N\xc4\x9bkter\xc3\xa9 ud\xc3\xa1losti lze zablokovat, av\xc5\xa1ak v tom p\xc5\x99\xc3\xadpad\xc4\x9b dojde k vypr\xc3\xa1zdn\xc4\x9bn\xc3\xad Request bufferu.\n_START_SECTION_\nP\xc5\x99\xc3\xadklad\n_START_PARAGRAPH_\nN\xc3\xa1sleduj\xc3\xadc\xc3\xad program demonstruje vytvo\xc5\x99en\xc3\xad okna s mal\xc3\xbdm \xc4\x8dern\xc3\xbdch \xc4\x8dtvercem uvnit\xc5\x99:_NEWLINE_ /*   Simple Xlib application drawing a box in a window.   gcc input.c -o output -lX11 */_NEWLINE__NEWLINE_ #include <X11/Xlib.h>_NEWLINE_ #include <stdio.h>_NEWLINE_ #include <stdlib.h>_NEWLINE_ #include <string.h>_NEWLINE__NEWLINE_ int main(void) {_NEWLINE_   Display *d;_NEWLINE_   Window w;_NEWLINE_   XEvent e;_NEWLINE_   char *msg = "Hello, World!";_NEWLINE_   int s;_NEWLINE__NEWLINE_                        /* open connection with the server */_NEWLINE_   d = XOpenDisplay(NULL);_NEWLINE_   if (d == NULL) {_NEWLINE_     fprintf(stderr, "Cannot open display\\n");_NEWLINE_     exit(1);_NEWLINE_   }_NEWLINE__NEWLINE_   s = DefaultScreen(d);_NEWLINE__NEWLINE_                        /* create window */_NEWLINE_   w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 200, 200, 1,_NEWLINE_                           BlackPixel(d, s), WhitePixel(d, s));_NEWLINE__NEWLINE_                        /* select kind of events we are interested in */_NEWLINE_   XSelectInput(d, w, ExposureMask | KeyPressMask);_NEWLINE__NEWLINE_                        /* map (show) the window */_NEWLINE_   XMapWindow(d, w);_NEWLINE__NEWLINE_                        /* event loop */_NEWLINE_   while (1) {_NEWLINE_     XNextEvent(d, &e);_NEWLINE_                        /* draw or redraw the window */_NEWLINE_     if (e.type == Expose) {_NEWLINE_       XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);_NEWLINE_       XDrawString(d, w, DefaultGC(d, s), 50, 50, msg, strlen(msg));_NEWLINE_     }_NEWLINE_                        /* exit on key press */_NEWLINE_     if (e.type == KeyPress)_NEWLINE_       break;_NEWLINE_   }_NEWLINE__NEWLINE_                        /* close connection to server */_NEWLINE_   XCloseDisplay(d);_NEWLINE__NEWLINE_   return 0;_NEWLINE_ }'