[cairo] Cairo and multiple X11 windows

Carl Worth cworth at cworth.org
Thu Jul 31 14:51:03 PDT 2008


On Thu, 2008-07-31 at 23:19 +0200, W.Boeke wrote:
> An example of a (rather) modern toolkit is e.g. FLTK, which is used for
> a lot of projects. Here every button, every canvas is instantiating its
> own window. An that is a good thing, because X-windows is designed to be
> used this way. E.g. if a parent window contains a lot of subwindows, then
> during a redraw of the parent window only the rectangular area's between
> the subwindows are redrawn. This is fully automatic, your program does
> not have to care for that.
> X-windows works with 'graphic contexts', containing data for fonts, colors
> etc. These objects need to be assigned only once and can be used by each
> procedure that needs them.
> Also the widely used Xft anti-alias text rendering library is organized
> this way.

Yes, X does have sub-windows and clipping for them. The toolkit can
provide that clipping itself if it uses a one-big-window approach. And
I'm not claiming that a toolkit is wrong if it uses the
hierarchy-of-windows approach, (just that such a style seems out of
favor of late). It should still be quite possible to use cairo and have
things perform well with such a toolkit.

>  > But I wouldn't anticipate any real problem from using cairo with a
>  > toolkit/application that does use many windows.
> 
> I think there will be a performance problem, e.g. a statement like
> cairo_select_font_face(cr,"Georgia",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL);
> will be executed very often, with each time a search in a font database for
> the string "Georgia".

OK. That one call would be slow, yes. But that's also a "toy text API"
call. A good toolkit wouldn't use that, (even if it were using a single
window). It would instead use something like
cairo_ft_font_face_create_for_pattern and reuse that font face.

> Is someone who reads this a designer of a 'modern' toolkit, using only one
> window? How do you implement all those different buttons, sliders and menu's?

I am not. But in a single-window mode all those things can be
implemented with the toolkit simply having to provide the clipping, (and
cairo_rectangle;...;cairo_clip can even do that just fine).

I hope that helps. Please have fun with cairo!

-Carl




More information about the cairo mailing list