Re: XForms: Canvas vs Free form

Steve Lamont (
Fri, 14 Nov 97 06:17:05 PST

To subscribers of the xforms list from (Steve Lamont) :

> I tried to use a canvas for drawing, but it was too slow, because it
> always caught expose event when a window was moved on it.
> The free form was very quick.It didn't catch expose.
> Sholud I use it , or it has any drawback ?

Actually, there shouldn't be that much difference in the number of
redraws you have to do. XForms simply turns the X Expose events into
its own FL_DRAW events.

It would depend upon what your application wants to draw. If all of
your drawing needs are reasonably satisfied by the standard fl_drw_*()
functions, then the Free object (I assume this is to what you're
referring) should be perfect.

If you're drawing your graphics with some other API, OpenGL/Mesa,
PHIGS, or are just "pushing pixels" by drawing Pixmaps directly to the
screen then you may need to use a Canvas object since it basically
just hands you a Window in which to draw.

Bear in mind that you can do some Expose event compression as I
mentioned in an earlier posting. The XExposeEvent structure contains
a member called `count' which tells you how many more Expose events
are pending. If this number is greater than zero, you might just
consider ignoring the event, since there will be more events delivered
almost immediately.

I'm not sure offhand whether XForms is doing Expose event compression
when it determines whether a Free object is to be redrawn but this may
be the source of some of the perceived difference.

Note also that you can save yourself a lot of redrawing effort in a
Canvas object if you draw your image to a Pixmap and then attach the
Pixmap to the Canvas's Window as a background Pixmap. When you do
this, the server will take care of redrawing the Pixmap for you. This
eliminates any round trips to the server from the application. Refer
to the Xlib functions XSetWindowBackgroundPixmap() or
XChangeWindowAttributes() for detail on how to do this.

If you provide a little more detail on your application, this would
help in answering your question.

To unsubscribe, send the message "unsubscribe" to or see
Xforms Home Page:
List Archive: