On Wednesday, April 9, 2008 at 09:27:32 (+0930) Jonathan Woithe writes:
 > Currently the PLXcairoDrawableInfo structure used to pass an external X
 > drawable in to the xcairo driver is private to cairo.h.  This means that
 > anyone using this feature must define their own structure to do this which
 > opens up the possibility that they could get the field ordering wrong.  It
 > also makes it much harder for us to update the structure in future if this
 > were ever an issue since it would force all users of external X drawables
 > to find their structure definitions and change them.  If an error were made
 > the compiler would not pick it up and this could lead to some very odd
 > symptoms.
 > 
 > The patch below (against svn rev 8364) addresses this by moving the
 > definition of PLXcairoDrawableInfo from drivers/cairo.c into
 > include/plplot.h.  It is still protected by the PLD_xcairo so at least in
 > theory its presence should not cause any trouble when plplot is compiled on
 > a system without X windows. However, I do not profess to be an expert in
 > this area so I'll defer to the judgement of others.  Is this a reasonable
 > solution to the problem?
 > 
 > Even if this particular solution is not adopted I think we need to come up
 > with some way of making PLXcairoDrawableInfo visible to users.

Here's the proposed code to be added to plplot.h:

 > +/* 
 > + * Structure for passing external drawables to xcairo devices via
 > + * the PLESC_DEVINIT escape function.
 > + */
 > +#if defined(PLD_xcairo)
 > +#include <X11/X.h>
 > +#include <X11/Xlib.h>
 > +typedef struct {
 > +  Display *display;
 > +  Drawable drawable;
 > +} PLXcairoDrawableInfo;
 > +#endif

We've managed to keep X11 and other driver-specific headers out of plplot.h
for a long time, and I hesitate to start now.  Although a particular
plplot distribution may have PLD_xcairo defined, that doesn't mean the user
has any need for it.  In which case you are sucking in a lot of unnecessary
stuff to all user code that includes plplot.h.

So I'd prefer an alternate solution, something along the lines of one of:

1. Given that this kind of capability may be useful and/or desired for more
than one driver, generalize the concept.  The pointer could be a (void *),
easy enough.  The Drawable on my system resolves to:

X.h:typedef XID Drawable;
Xdefs.h:typedef unsigned long XID;

so an unsigned long would do the trick.  Then cast accordingly in the
driver.

This approach has been generally followed in the past with colors, input
events, event handlers, etc.  But it can be tricky.

2. Give up on the idea of genericity for everything and go with a separate
X-windows specific plplot include file, e.g. plplotX.h.  This is tempting
since you could add as many convenient definitions as you wished.  I've
almost done this on several occasions.  But resisted the temptation since
I thought the generic solution was a better way to go, when practical.

-- 
Maurice LeBrun

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to