art@dinorah.mit.EDU (Arthur B. Smith) (02/11/89)
I think I must be missing something. I seem to be spending a fair amount of my time getting around the inability to query the GC in X. Frequently I seem to need to temporarily change one aspect of the GC (e.g., change the function for an Expose event), or use one (possibly changed) value from the GC (e.g., Using the Background pixel as a temporary Foreground pixel to "erase" a pixmap), and I end up having to either use multiple GC's or keep track of the XGCValues structure I've used in calls to XChangeGC. Both of these techniques seem wasteful when I only need to know a small part of the GC for a brief time. I recognize that querying the server for the GCValues would be expensive from a communications standpoint, but it seems extreme to not offer that option at all. I've noticed that the structure that GC is a pointer to has an XGCValues structure in it, with the comment that it is a "shadow structure of values." Is it ever safe to look at that? Did I miss a macro somewhere that lets me get at that? Am I lacking some fundamental understanding of things X? Am I as confused as I think I am? art smith (art@dinorah.wustl.edu)
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (02/14/89)
The protocol doesn't provide readback for at least two reasons, but one is that GCs weren't really intended to be shared among multiple clients, and it was expected that clients would cache GC contents anyway, at least for performance. I note that the CLX interface *does* allow readback, although the necessity to do so is reduced by the ability to have scoped changes to individual attributes, e.g.: (with-gcontext (gc :line-width 1 :foreground pix) <body>) which changes two attributes during <body> and then reverts them. It's quite possible that not having readback in the C Xlib is bogus. If people want to mount a campaign with good arguments as to why this functionality should exist, please do so. I've noticed that the structure that GC is a pointer to has an XGCValues structure in it, with the comment that it is a "shadow structure of values." Is it ever safe to look at that? The GC structure is supposed to be "opaque", there is currently no guarantee that the structure will be the same in all implementations.