[Xcb-commit] tutorial.mdwn
XCB site
xcb at freedesktop.org
Sun Nov 11 18:50:03 PST 2007
tutorial.mdwn | 38 +++++++++++++++-----------------------
1 file changed, 15 insertions(+), 23 deletions(-)
New commits:
commit 02e155297766222f0ec43aef3c0c8c573097e15b
Author: brian.thomas.will <brian.thomas.will at gmail.com>
Date: Sun Nov 11 18:50:01 2007 -0800
refactored section 6 ("open and close connection") for clarity
diff --git a/tutorial.mdwn b/tutorial.mdwn
index 06f9d57..a90c7bd 100644
--- a/tutorial.mdwn
+++ b/tutorial.mdwn
@@ -281,36 +281,28 @@ Compiling XCB-based programs requires linking them with the XCB library. This is
# 6. Opening and closing the connection to an X server
-An X program first needs to open the connection to the X server. There is a function that opens a connection. It requires the display name, or NULL. In the latter case, the display name will be the one in the environment variable DISPLAY.
+An X program first needs to open the connection to the X server, using xcb_connect():
- xcb_connection_t *xcb_connect (const char *displayname,
- int *screenp);
+ xcb_connection_t *xcb_connect (const char *displayname, // if NULL, uses the DISPLAY environment variable
+ int *screenp ); // returns the screen number of the connection; can provide NULL if you don't care
-The second parameter returns the screen number used for the connection. The returned structure describes an XCB connection and is opaque. Here is how the connection can be opened:
-
- #include <xcb/xcb.h>
-
- int
- main ()
- {
- xcb_connection_t *c;
-
- /* Open the connection to the X server. Use the DISPLAY environment variable as the default display name */
- c = xcb_connect (NULL, NULL);
+To close a connection, it suffices to use:
+
+ void xcb_disconnect (xcb_connection_t *c);
+
+So for example:
- return 0;
- }
+ #include <xcb/xcb.h>
- To close a connection, it suffices to use:
+ ...
- void xcb_disconnect (xcb_connection_t *c);
+ xcb_connection_t *c = xcb_connect (NULL, NULL);
+ xcb_disconnect (c);
-Comparison Xlib/XCB
+Comparison Xlib/XCB:
-* XOpenDisplay ()
-* xcb_connect ()
-* XCloseDisplay ()
-* xcb_disconnect ()
+* XOpenDisplay () => xcb_connect ()
+* XCloseDisplay () => xcb_disconnect ()
# 7. Checking basic information about a connection
More information about the xcb-commit
mailing list