Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.windows.x.intrinsics Frequently Asked Questions (FAQ)
Section - 47.+How to get rid of that annoying flicker during updates?

( Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Business Photos and Profiles ]


Top Document: comp.windows.x.intrinsics Frequently Asked Questions (FAQ)
Previous Document: 46. What is the preferred way of setting the application resources?
Next Document: 48.+How are created, managed, mapped, realized, etc. related?
See reader questions & answers on this topic! - Help others by sharing your knowledge
----------------------------------------------------------------------

(From Young Nicholas <td000owt@macgate.logica.com>, 3/24/95)

Flicker is caused primarily by the time taken between clearing all or part of
a widget's window and redrawing the contents (especially noticeable when the
same contents are redrawn).  In Xt-based widgets this involves a round-trip
to the server because widgets first clear their window and then wait for the
Expose event to trigger redrawing.  In heavily loaded systems or with slow
networks very significant flicker can occur.

The solution is not to wait for the Expose event but to redraw the contents
immediately after the SetValues call or equivalent.  This can be done by
calling the widget's expose() routine in the core_class part of the class
structure, defined in the widget's private header file.  You have to simulate
an Expose event but this is not hard.  Here is a code fragment using a Motif
Label widget (the commonest widget with this requirement that I have seen).

#include <LabelP.h>
...
Widget label;
XExposeEvent xeev;
...
xeev.type = Expose;
xeev.display = XtDisplay (label);
xeev.window = XtWindow (label);
xeev.x = 0;
xeev.y = 0;
XtVaGetValues (label, XmNwidth, &w, XmNheight, &h, NULL);
xeev.width = w;
xeev.height = h;
XtVaSetValues (label, XmNlabelString, "Hello world", NULL);
(XtClass (label))->core_class.expose (label, (XEvent *)&xeev, NULL);

Since the redraw is done immediately after the window is cleared by the
XtVaSetValues call the flicker is practically eliminated. The widget's
contents will still be redrawn again when the real Expose event arrives, but
this is not a problem since the window is of course not cleared again first.

If the widget is very large it might also be worth trying to optimise the
rectangle in the simulated Expose event, but that would be difficult in
general.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA