| McDonalds | Escrow | Pepsi | Boeing | Chevron | Cirque Du Soleil | FIFA | PayPal | Citigroup | Verizon | Dun & Bradstreet | Anime International |
|
|
|
Xlib
Xlib is an X Window System protocol client library in the C programming language. It contains functions for interacting with an X server. These functions allow programmers to write programs without knowing the details of the protocol. Few applications use Xlib directly; rather, they employ other libraries that use Xlib functions to provide widget toolkits: Xlib and other libraries using it
Xlib appeared around 1985, and is currently used in GUIs for many Unix-like operating systems. The XCB library is an attempt to replace Xlib.
Data typesThe main types of data in Xlib are the Informally, a display is a physical or virtual device where graphical operations are done. The Windows, colormaps, etc. are managed by the server, which means that the data about their actual implementation is all stored in the server. The client operates on these objects by using their identifiers. The client cannot directly operate on an object, but can only request the server to perform the operation specifying the identifier of the object. The types The identifiers are unique to the server. Most of them can be used by different applications to refer to the same objects. For example, two applications connecting with the same server use the same identifier to refer to the same window. These two applications use two different channels, and therefore have two different Display structures; however, when they request operations on the same identifier, these operations will be done on the same object. Protocol and eventsThe Xlib functions that send requests to the server usually do not send these requests immediately but store them in a buffer, called the output buffer. The term output in this case refers to the output from the client that is directed to the server: the output buffer can contain all kinds of requests to the server, not only those having a visible effect on the screen. The output buffer is guaranteed to be flushed (i.e., all requests done so far are sent to the server) after a call to the functions Xlib stores the received events in a queue. The client application can inspect and retrieve events from the queue. While the X server sends events asynchronously, applications using the Xlib library are required to explicitly call Xlib functions for accessing the events in the queue. Some of these functions may block; in this case, they also flush the output buffer. Errors are instead received and treated asynchronously: the application can provide an error handler that will be called whenever an error message from the server is received. The content of a window is not guaranteed to be preserved if the window of one of its parts are made not visible. In this case, the application are sent an FunctionsThe functions in the Xlib library can be grouped in:
ExampleThe following program creates a window with a little black square in it. /* Simple Xlib application drawing a box in a window. */ #include <X11/Xlib.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { Display *d; int s; Window w; XEvent e; /* open connection with the server */ d=XOpenDisplay(NULL); if(d==NULL) { printf("Cannot open displayn"); exit(1); } s=DefaultScreen(d); /* create window */ w=XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1, BlackPixel(d, s), WhitePixel(d, s)); /* select kind of events we are interested in */ XSelectInput(d, w, ExposureMask | KeyPressMask); /* map (show) the window */ XMapWindow(d, w); /* event loop */ while(1) { XNextEvent(d, &e); /* draw or redraw the window */ if(e.type==Expose) { XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10); XDrawString(d, w, DefaultGC(d, s), 50, 50, "Hello, World!",strlen("Hello, World!")); } /* exit on key press */ if(e.type==KeyPress) break; } /* close connection to server */ XCloseDisplay(d); return 0; } The client creates a connection with the server by calling The square is drawn by calling The drawing of the window content is therefore made inside the loop handling the events. Before entering this loop, the events the application is interested into are selected, in this case with Other librariesXlib does not provide support for buttons, menus, scrollbar, etc. Such widgets are provided by other libraries, which in turn use Xlib. There are two kinds of such libraries:
Applications using any of these widget libraries typically specify the content of the window before entering the main loop and do not need to explicitly handle The XCB library is an alternative to Xlib. Its two main aims are: reduction in library size and direct access to the X11 protocol. A modification of Xlib has been produced to use XCB as a low-level layer. References
See alsoExternal links
Latest
Comment:
Add Your Comment:
We welcome your Comment on this story.Comments are submitted for possible publication on the conditiin that they may be edited.Please provide your full name.We also require a working email address-not for publication,but for verification.The location field is optional. Read our Publication guidelines. |
Sponsored Links
Search Tools
Todays Top Searches
List Your Business
Receive hundreds of new customers for your business
ABSOLUTELY FREE!
Listing your business in Chemist Crawler, the leading Chemist Search Engine and Directory Online is the best way to reach your target niche audience. List now to ensure your business is found.
Client Testimonials
Chemist Crawler has delivered what they promised. My company shows up at the top of most relevant searches, people call me from that listing, and my business sales and web traffic have increased David - Anime International,Inc. Read More |
|||||||||||||||
Help us improve Chemist Crawler Encyclopedia Search - Send Your Feedback
Search for Encyclopedia right from your Chemist Crawler Toolbar. Its easy.Try it.
| ||||||||||||||||