[Xr] What happended to the idea of getting rid of the xrs argument?

Robert Wittams robert at wittams.com
Thu Jun 5 16:41:29 PDT 2003

On Thursday 05 June 2003 19:25, Bill Spitzak wrote:

> box->draw(xrs,x,y,w,h) (which would introduce the fact that XrState
> exists into the supposedly portable fltk header files) or I have to
> use a global variable to hold the current xrs.
> I believe this is not fltk-specific, this problem is *extremely*
> common, and the end result is that everybody will have to put the xrs
> into a global variable sometime anyway.

So how the hell does fltk draw on X? Does it just pull Drawables out of 
the air? No, it stores them in global variables. If the rendering 
handle for one system is in a global variable, then its very likely 
that the handle for any other rendering system should be too... 

> Contrary to what some other people seem to think about objects here, 
>  the "box" object has NO idea what "surface" it is drawing on, and I 
>cannot believe this situation is uncommon 

How can a function affect something it can not reference?
Hint: It can't. It has to get a handle from somewhere. Either an 
argument or a global. It may access the global via another function. 
Looking at the fltk code, it seems like less pain for you to just use a 
global in this way. 

from http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/fltk/fltk/fltk/x.h

in the Drawable class, 
store an xrs. 
Switch the global in make_current, just as you do for xid. 
This really is very similar to an xid, or an HWND on win32, or whatever. 


More information about the cairo mailing list