From 5a0b45275638281e1bb2ae7d3e16b98e6470dae9 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 19 Jul 2010 11:28:50 -0700 Subject: specs/libX11: Manual cleanup pass over Ch. 1 Signed-off-by: Alan Coopersmith --- specs/libX11/CH01.xml | 583 ++++++++++++++++++++++++-------------------------- 1 file changed, 280 insertions(+), 303 deletions(-) diff --git a/specs/libX11/CH01.xml b/specs/libX11/CH01.xml index 4536b64e..7f5ea0a2 100644 --- a/specs/libX11/CH01.xml +++ b/specs/libX11/CH01.xml @@ -1,72 +1,74 @@ -Introduction to Xlib +Introduction to Xlib - -The X Window System is a network-transparent window system that was designed at MIT. X -display servers run on computers with either monochrome or color bitmap display hardware. The -server distributes user input to and accepts output requests from various client programs located -either on the same machine or elsewhere in the network. Xlib is a C subroutine library that appli- -cation programs (clients) use to interface with the window system by means of a stream connec- -tion. Although a client usually runs on the same machine as the X server it is talking to, this need -not be the case. - - -Xlib − C Language X Interface is a reference guide to the low-level C language interface to the X -Window System protocol. It is neither a tutorial nor a user’s guide to programming the X Win- -dow System. Rather, it provides a detailed description of each function in the library as well as a -discussion of the related background information. Xlib − C Language X Interface assumes a -basic understanding of a graphics window system and of the C programming language. Other -higher-level abstractions (for example, those provided by the toolkits for X) are built on top of the -Xlib library. For further information about these higher-level libraries, see the appropriate toolkit -documentation. The X Window System Protocol provides the definitive word on the behavior of -X. Although additional information appears here, the protocol document is the ruling document. - - + +The X Window System is a network-transparent window system that was +designed at MIT. X display servers run on computers with either +monochrome or color bitmap display hardware. The server distributes +user input to and accepts output requests from various client programs +located either on the same machine or elsewhere in the network. Xlib +is a C subroutine library that application programs (clients) use to +interface with the window system by means of a stream connection. +Although a client usually runs on the same machine as the X server +it is talking to, this need not be the case. + + +Xlib − C Language X Interface is a reference +guide to the low-level C language interface to the X Window System +protocol. It is neither a tutorial nor a user’s guide to programming +the X Window System. Rather, it provides a detailed description of +each function in the library as well as a discussion of the related +background information. Xlib − C Language X Interface +assumes a basic understanding of a graphics window system and of the C +programming language. Other higher-level abstractions (for example, +those provided by the toolkits for X) are built on top of the Xlib +library. For further information about these higher-level libraries, +see the appropriate toolkit documentation. +The X Window System Protocol provides the +definitive word on the behavior of X. +Although additional information appears here, the protocol document is +the ruling document. + + To provide an introduction to X programming, this chapter discusses: - - - Overview of the X Window System - Errors - Standard header files - Generic values and types - Naming and argument conventions within Xlib - Programming considerations - Character sets and encodings - Formatting conventions - + + Overview of the X Window System + Errors + Standard header files + Generic values and types + Naming and argument conventions within Xlib + Programming considerations + Character sets and encodings + Formatting conventions + + - -Overview of the X Window System - - - - - + + Overview of the X Window System + Some of the terms used in this book are unique to X, -and other terms that are common to other window systems -have different meanings in X. -You may find it helpful to refer to the glossary, +and other terms that are common to other window systems +have different meanings in X. You may find it helpful to refer to +the glossary, which is located at the end of the book. - - - + + The X Window System supports one or more screens containing overlapping windows or subwindows. -A screen is a physical monitor and hardware +Screen +A screen is a physical monitor and hardware that can be color, grayscale, or monochrome. There can be multiple screens for each display or workstation. A single X server can provide display services for any number of screens. A set of screens for a single user with one keyboard and one pointer -(usually a mouse) is called a display. - - - -Screen +(usually a mouse) is called a display. + + All the windows in an X server are arranged in strict hierarchies. -At the top of each hierarchy is a root window, +At the top of each hierarchy is a root window, which covers each of the display screens. Each root window is partially or completely covered by child windows. All windows, except for root windows, have parents. @@ -74,29 +76,27 @@ There is usually at least one window for each application program. Child window Parent Window Child windows may in turn have their own children. -In this way, -an application program can create an arbitrarily deep tree +In this way, +an application program can create an arbitrarily deep tree on each screen. X provides graphics, text, and raster operations for windows. - - - -A child window can be larger than its parent. + + +A child window can be larger than its parent. That is, part or all of the child window can extend beyond the boundaries of the parent, but all output to a window is clipped by its parent. Stacking order -If several children of a window have overlapping locations, +If several children of a window have overlapping locations, one of the children is considered to be on top of or raised over the others, thus obscuring them. Output to areas covered by other windows is suppressed by the window system unless the window has backing store. -If a window is obscured by a second window, +If a window is obscured by a second window, the second window obscures only those ancestors of the second window that are also ancestors of the first window. - - - + + Window A window has a border zero or more pixels in width, which can be any pattern (pixmap) or solid color you like. @@ -105,43 +105,40 @@ which will be repainted by the window system when uncovered. Child windows obscure their parents, and graphic operations in the parent window usually are clipped by the children. - - - + + Each window and pixmap has its own coordinate system. The coordinate system has the X axis horizontal and the Y axis vertical with the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms of pixels, and coincide with pixel centers. -For a window, +For a window, the origin is inside the border at the inside, upper-left corner. - - - -X does not guarantee to preserve the contents of windows. + + +X does not guarantee to preserve the contents of windows. When part or all of a window is hidden and then brought back onto the screen, -its contents may be lost. +its contents may be lost. The server then sends the client program an -Expose +Expose event to notify it that part or all of the window needs to be repainted. Programs must be prepared to regenerate the contents of windows on demand. - - - + + Pixmap Drawable Tile Bitmap X also provides off-screen storage of graphics objects, -called pixmaps. -Single plane (depth 1) pixmaps are sometimes referred to as bitmaps. +called pixmaps. +Single plane (depth 1) pixmaps are sometimes referred to as +bitmaps. Pixmaps can be used in most graphics functions interchangeably with windows and are used in various graphics operations to define patterns or tiles. Windows and pixmaps together are referred to as drawables. - - - + + Most of the functions in Xlib just add requests to an output buffer. These requests later execute asynchronously on the X server. Functions that return values of information stored in @@ -149,36 +146,35 @@ the server do not return (that is, they block) until an explicit reply is received or an error occurs. You can provide an error handler, which will be called when the error is reported. - - - + + XSync -If a client does not want a request to execute asynchronously, -it can follow the request with a call to +If a client does not want a request to execute asynchronously, +it can follow the request with a call to XSync, which blocks until all previously buffered asynchronous events have been sent and acted on. -As an important side effect, +As an important side effect, the output buffer in Xlib is always flushed by a call to any function that returns a value from the server or waits for input. - - - + + Resource IDs Resource IDsWindow Resource IDsFont Resource IDsPixmap +Resource IDsColormap Resource IDsCursor Resource IDsGContext Many Xlib functions will return an integer resource ID, which allows you to refer to objects stored on the X server. -These can be of type +These can be of type Window, Font, Pixmap, Colormap, Cursor, -and +and GContext, as defined in the file <X11/X.h>. @@ -194,23 +190,21 @@ Fonts and cursors are shared automatically across multiple screens. Fonts are loaded and unloaded as needed and are shared by multiple clients. Fonts are often cached in the server. Xlib provides no support for sharing graphics contexts between applications. - - - + + Event Client programs are informed of events. Events may either be side effects of a request (for example, restacking windows -generates -Expose +generates +Expose events) or completely asynchronous (for example, from the keyboard). A client program asks to be informed of events. Because other applications can send events to your application, programs must be prepared to handle (or ignore) events of all types. - - - -Input events (for example, a key pressed or the pointer moved) -arrive asynchronously from the server and are queued until they are + + +Input events (for example, a key pressed or the pointer moved) +arrive asynchronously from the server and are queued until they are requested by an explicit call (for example, XNextEvent or @@ -218,7 +212,7 @@ or In addition, some library functions (for example, XRaiseWindow) -generate +generate Expose and ConfigureRequest @@ -228,63 +222,56 @@ These events also arrive asynchronously, but the client may wish to explicitly wait for them by calling XSync after calling a function that can cause the server to generate events. - - - -Errors - - - - - -Some functions return + + + + + Errors + + +Some functions return Status, an integer error indication. If the function fails, it returns a zero. If the function returns a status of zero, it has not updated the return arguments. Status -Because C does not provide multiple return values, -many functions must return their results by writing into client-passed storage. +Because C does not provide multiple return values, +many functions must return their results by writing into client-passed storage. Errorhandling By default, errors are handled either by a standard library function or by one that you provide. Functions that return pointers to strings return NULL pointers if the string does not exist. - - - + + The X server reports protocol errors at the time that it detects them. If more than one error could be generated for a given request, the server can report any of them. - - - + + Because Xlib usually does not transmit requests to the server immediately (that is, it buffers them), errors can be reported much later than they actually occur. For debugging purposes, however, -Xlib provides a mechanism for forcing synchronous behavior +Xlib provides a mechanism for forcing synchronous behavior (see section 11.8.1). -When synchronization is enabled, +When synchronization is enabled, errors are reported as they are generated. - - - + + When Xlib detects an error, it calls an error handler, which your program can provide. If you do not provide an error handler, the error is printed, and your program terminates. - - - -Standard Header Files - - - - - + + + + + Standard Header Files + + The following include files are part of the Xlib standard: Headers @@ -315,7 +302,8 @@ This symbol is defined to have the 6 in this release of the standard. This file declares types and constants for the X protocol that are to be used by applications. It is included automatically from -<X11/Xlib.h> so application code should never need to +<X11/Xlib.h> +so application code should never need to reference this file directly. @@ -328,7 +316,7 @@ reference this file directly. Headers<X11/Xcms.h> This file contains symbols for much of the color management facilities -described in chapter 6. All functions, types, and symbols with the +described in chapter 6. All functions, types, and symbols with the prefix "Xcms", plus the Color Conversion Contexts macros, are declared in this file. <X11/Xlib.h> @@ -371,7 +359,7 @@ must be included before including this file. Files<X11/Xatom.h> Headers<X11/Xatom.h> -This file declares all predefined atoms, +This file declares all predefined atoms, which are symbols with the prefix "XA_". @@ -384,7 +372,7 @@ which are symbols with the prefix "XA_". Headers<X11/cursorfont.h> This file declares the cursor symbols for the standard cursor font, -which are listed in appendix B. +which are listed in Appendix B. All cursor symbols have the prefix "XC_". @@ -401,10 +389,25 @@ which are symbols with the prefix "XK_". The KeySyms are arranged in groups, and a preprocessor symbol controls inclusion of each group. The preprocessor symbol must be defined prior to inclusion of the file to obtain the associated values. -The preprocessor symbols are XK_MISCELLANY, XK_XKB_KEYS, XK_3270, -XK_LATIN1, XK_LATIN2, XK_LATIN3, XK_LATIN4, XK_KATAKANA, XK_ARABIC, -XK_CYRILLIC, XK_GREEK, XK_TECHNICAL, XK_SPECIAL, XK_PUBLISHING, XK_APL, -XK_HEBREW, XK_THAI, and XK_KOREAN. +The preprocessor symbols are +XK_MISCELLANY, +XK_XKB_KEYS, +XK_3270, +XK_LATIN1, +XK_LATIN2, +XK_LATIN3, +XK_LATIN4, +XK_KATAKANA, +XK_ARABIC, +XK_CYRILLIC, +XK_GREEK, +XK_TECHNICAL, +XK_SPECIAL, +XK_PUBLISHING, +XK_APL, +XK_HEBREW, +XK_THAI, and +XK_KOREAN. @@ -416,8 +419,13 @@ XK_HEBREW, XK_THAI, and XK_KOREAN. Headers<X11/keysym.h> This file defines the preprocessor symbols -XK_MISCELLANY, XK_XKB_KEYS, XK_LATIN1, XK_LATIN2, XK_LATIN3, -XK_LATIN4, and XK_GREEK +XK_MISCELLANY, +XK_XKB_KEYS, +XK_LATIN1, +XK_LATIN2, +XK_LATIN3, +XK_LATIN4, and +XK_GREEK and then includes <X11/keysymdef.h>. @@ -430,7 +438,7 @@ and then includes <X11/keysymdef.h>Headers<X11/Xlibint.h> This file declares all the functions, types, and symbols used for -extensions, which are described in appendix C. +extensions, which are described in Appendix C. This file automatically includes <X11/Xlib.h>. @@ -476,78 +484,71 @@ reference this file directly. Headers<X11/X10.h> This file declares all the functions, types, and symbols used for the -X10 compatibility functions, which are described in appendix D. +X10 compatibility functions, which are described in +Appendix D. - - + + - -Generic Values and Types - - - - - + + Generic Values and Types + + The following symbols are defined by Xlib and used throughout the manual: -Bool -True -False - +Bool +True +False Xlib defines the type Bool and the Boolean values True and False. -None +None None is the universal null resource ID or atom. -XID +XID The type XID is used for generic resource IDs. -XPointer -The type -XPointer -is defined to be char\^* and is used as a generic opaque pointer to data. +XPointer +The type XPointer is defined to be char\^* +and is used as a generic opaque pointer to data. - - -Naming and Argument Conventions within Xlib - - - - - + + + + + Naming and Argument Conventions within Xlib + + Xlib follows a number of conventions for the naming and syntax of the functions. Given that you remember what information the function requires, -these conventions are intended to make the syntax of the functions more +these conventions are intended to make the syntax of the functions more predictable. - - - + + The major naming conventions are: - @@ -635,16 +636,14 @@ the mask always precedes the pointer to the structure in the argument list. - - -Programming Considerations - - - - - + + + + + Programming Considerations + + The major programming considerations are: - @@ -682,133 +681,111 @@ What you do inside of your top-level window, however, is up to your application. For further information, see chapter 14 -and the Inter-Client Communication Conventions Manual. +and the Inter-Client Communication Conventions Manual. - - -Character Sets and Encodings - - - - - + + + + + Character Sets and Encodings + + Some of the Xlib functions make reference to specific character sets and character encodings. The following are the most common: - - - - -X Portable Character Set - - - - -A basic set of 97 characters, + + + + X Portable Character Set + +A basic set of 97 characters, which are assumed to exist in all locales supported by Xlib. This set contains the following characters: - - - - + a..z A..Z 0..9 !"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ <space>, <tab>, and <newline> - - - - + + + This set is the left/lower half of the graphic character set of ISO8859-1 plus space, tab, and newline. It is also the set of graphic characters in 7-bit ASCII plus the same three control characters. The actual encoding of these characters on the host is system dependent. - - - - -Host Portable Character Encoding - - - - + + + + + Host Portable Character Encoding + + The encoding of the X Portable Character Set on the host. The encoding itself is not defined by this standard, but the encoding must be the same in all locales supported by Xlib on the host. If a string is said to be in the Host Portable Character Encoding, then it only contains characters from the X Portable Character Set, in the host encoding. - - - - -Latin-1 - - - - + + + + + Latin-1 + + The coded character set defined by the ISO8859-1 standard. - - - - -Latin Portable Character Encoding - - - - + + + + + Latin Portable Character Encoding + + The encoding of the X Portable Character Set using the Latin-1 codepoints plus ASCII control characters. If a string is said to be in the Latin Portable Character Encoding, then it only contains characters from the X Portable Character Set, not all of Latin-1. - - - - -STRING Encoding - - - - + + + + + STRING Encoding + + Latin-1, plus tab and newline. - - - - -POSIX Portable Filename Character Set - - - - -The set of 65 characters, + + + + + POSIX Portable Filename Character Set + + +The set of 65 characters, which can be used in naming files on a POSIX-compliant host, that are correctly processed in all locales. The set is: - - - - - + a..z A..Z 0..9 ._- + + + + - - - - -Formatting Conventions - - - - - -Xlib \- C Language X Interface uses the following conventions: - - - + + + + Formatting Conventions + -Global symbols are printed in + Xlib − C Language X Interface uses the + following conventions: + + + + +Global symbols are printed in this special font. @@ -818,11 +795,11 @@ When declared and defined, function arguments are printed in italics. In the explanatory text that follows, they usually are printed in regular type. - - - - -Each function is introduced by a general discussion that + + + + +Each function is introduced by a general discussion that distinguishes it from other functions. The function declaration itself follows, and each argument is specifically explained. @@ -831,16 +808,16 @@ Xlib header files normally declare functions using function prototypes in ANSI C environments. General discussion of the function, if any is required, follows the arguments. -Where applicable, -the last paragraph of the explanation lists the possible +Where applicable, +the last paragraph of the explanation lists the possible Xlib error codes that the function can generate. For a complete discussion of the Xlib error codes, see section 11.8.2. - - - - -To eliminate any ambiguity between those arguments that you pass and those that + + + + +To eliminate any ambiguity between those arguments that you pass and those that a function returns to you, the explanations for all arguments that you pass start with the word specifies or, in the case of multiple arguments, the word specify\^. @@ -848,19 +825,19 @@ The explanations for all arguments that are returned to you start with the word returns or, in the case of multiple arguments, the word return\^. The explanations for all arguments that you can pass and are returned start with the words specifies and returns\^. - - - - -Any pointer to a structure that is used to return a value is designated as + + + + +Any pointer to a structure that is used to return a value is designated as such by the _return suffix as part of its name. All other pointers passed to these functions are used for reading only. A few arguments use pointers to structures that are used for both input and output and are indicated by using the _in_out suffix. - + + + - - - + -- cgit v1.2.3