X Window Programming/XLib/Library Conventions
Appearance
Library Conventions
[edit | edit source]Xlib follows a number of conventions to make it easier to use and remember.
The major conventions are:
- To differentiate the X symbols from the other symbols, the library uses mixed case for external symbol names. It leaves lowercase for variables and all uppercase for user macros, as per existing convention.
- All Xlib functions, user-visible data structures, and anything that a user might dereference begins with a capital X.
- Macros and other symbols do not begin with a capital X. To distinguish them from all user symbols, each word in the macro is capitalized.
- The beginnings of all function names and symbols are capitalized.
- All elements of a data structure are in lowercase. Compound words, where needed, are constructed with underscores (_).
- The display argument, where used, is always first in the argument list.
- All resource objects, where used, occur at the beginning of the argument list immediately after the display argument.
- When a graphics context is present together with another type of resource (most commonly, a drawable), the graphics context occurs in the argument list after the other resource. Drawables outrank all other resources.
- Source arguments always precede the destination arguments in the argument list.
- The x argument always precedes the y argument in the argument list, and the width argument always precedes the height argument in the argument list.
- Where the x, y, width, and height arguments are used together, the x and y arguments always precede the width and height arguments.
- Where a mask is accompanied with a structure, the mask always precedes the pointer to the structure in the argument list.