Appendix D: Compatibility Functions

The X Version 11 and X Version 10 functions discussed in this appendix are obsolete, have been superseded by newer X Version 11 functions, and are maintained for compatibility reasons only.

X Version 11 Compatibility Functions

You can use the X Version 11 compatibility functions to:

Setting Standard Properties

To specify a minimum set of properties describing the simplest application, use XSetStandardProperties().

Setting and Getting Window Sizing Hints

Xlib provides functions that you can use to set or get window sizing hints. The functions discussed in this section use the flags and the XSizeHints structure, as defined in the X11/Xutil.h header file, and use the WM_NORMAL_HINTS property.

To set the size hints for a given window in its normal state, use XSetNormalHints().

To return the size hints for a window in its normal state, use XGetNormalHints().

The next two functions set and read the WM_ZOOM_HINTS property.

To set the zoom hints for a window, use XSetZoomHints()

To read the zoom hints for a window, use XGetZoomHints().

To set the value of any property of type WM_SIZE_HINTS, use XSetSizeHints().

To read the value of any property of type WM_SIZE_HINTS, use XGetSizeHints().

Getting and Setting an XStandardColormap Structure

To get the XStandardColormap structure associated with one of the described atoms, use XGetStandardColormap().

To set a standard colormap, use XSetStandardColormap().

Parsing Window Geometry

To parse window geometry given a user-specified position and a default position, use XGeometry().

Obtaining the X Environment Defaults

The XGetDefault() function provides a primitive interface to the resource manager facilities discussed in chapter "Resource Manager Functions". It is only useful in very simple applications.

X Version 10 Compatibility Functions

You can use the X Version 10 compatibility functions to:

Drawing and Filling Polygons and Curves

Xlib provides functions that you can use to draw or fill arbitrary polygons or curves. These functions are provided mainly for compatibility with X Version 10 and have no server support. That is, they call other Xlib functions, not the server directly. Thus, if you just have straight lines to draw, using XDrawLines() or XDrawSegments() is much faster.

The functions discussed here provide all the functionality of the X Version 10 functions XDraw(), XDrawFilled(), XDrawPatterned(), XDrawDashed(), and XDrawTiled(). They are as compatible as possible given X Version 11's new line drawing functions. One thing to note, however, is that VertexDrawLastPoint() is no longer supported. Also, the error status returned is the opposite of what it was under X Version 10 (this is the X Version 11 standard error status). XAppendVertex() and XClearVertexFlag() from X Version 10 also are not supported.

Just how the graphics context you use is set up actually determines whether you get dashes or not, and so on. Lines are properly joined if they connect and include the closing of a closed figure (see XDrawLines()). The functions discussed here fail (return zero) only if they run out of memory or are passed a Vertex list that has a Vertex with VertexStartClosed set that is not followed by a Vertex with VertexEndClosed set.

To achieve the effects of the X Version 10 XDraw(), XDrawDashed(), and XDrawPatterned(), use XDraw().

To achieve the effects of the X Version 10 XDrawTiled() and XDrawFilled(), use XDrawFilled()

Associating User Data with a Value

These functions have been superseded by the context management functions (see "Using the Context Manager"). It is often necessary to associate arbitrary information with resource IDs. Xlib provides the XAssocTable functions that you can use to make such an association. Application programs often need to be able to easily refer to their own data structures when an event arrives. The XAssocTable system provides users of the X library with a method for associating their own data structures with X resources ( Pixmaps, Fonts, Windows, and so on).

An XAssocTable can be used to type X resources. For example, the user may want to have three or four types of windows, each with different properties. This can be accomplished by associating each X window ID with a pointer to a window property data structure defined by the user. A generic type has been defined in the X library for resource IDs. It is called an XID.

There are a few guidelines that should be observed when using an XAssocTable:

To return a pointer to a new XAssocTable , use XCreateAssocTable().

To create an entry in a given XAssocTable, use XMakeAssoc().

To obtain data from a given XAssocTable, use XLookUpAssoc().

To delete an entry from a given XAssocTable, use XDeleteAssoc().

To free the memory associated with a given XAssocTable, use XDestroyAssocTable().

Next: Glossary

Christophe Tronche, ch@tronche.com