Skip to Content
XLIB Programming Manual, Rel. 5, Third Edition
book

XLIB Programming Manual, Rel. 5, Third Edition

by Adrian Nye
June 1994
Intermediate to advanced
821 pages
24h 40m
English
O'Reilly Media, Inc.
Content preview from XLIB Programming Manual, Rel. 5, Third Edition

5.10 Querying the Graphics Context

When you call a number of the GC convenience routines, such as XSetForeground() and XSetLineAttributes(), you might expect each to generate a separate protocol request to change the GC. But this is not what happens. Xlib saves up the changes in an internal structure and makes a single request to the server just before the GC is actually used by a drawing request.

The type GC is a pointer to this internal structure. All Xlib routines use a pointer to this internal structure, not a integer ID, as we have previously implied. However, this fact does not impact how you write Xlib code at all. In practice, a pointer to an opaque structure and an integer ID such as a window ID are treated exactly the same.

In R4, the XGetGCValues() function has been added to allow clients to read Xlib’s cache of the fields in each GC. This can save an application from having to maintain its own cache of GC values, when it needs to change the GC in several different places in ways that depend on the current contents.

Note that XGetGCValues() is not a true round-trip query to the server—there is no protocol request that actually asks the server for these values. This has good and bad consequences. The good part is that XGetGCValues() is fast because it is not subject to network delays. The bad side is that the values in Xlib’s cache do not include the default values for certain of the GC members. The tile, stipple, and font fields contain invalid IDs when XGetGCValues() is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Xlib Reference Manual for Version 11 of the X Window System

Xlib Reference Manual for Version 11 of the X Window System

Adrian Nye

Publisher Resources

ISBN: 9780596806187Supplemental ContentCatalog PageErrata