Problem dumping the contents of a window to a file with xwd in automated test

Ludovic Brenta ludovic at ludovic-brenta.org
Tue Sep 2 10:48:24 PDT 2008


Hello,

We are encountering problems running automated tests that compare a
window snapshot with a template.  In those tests, we use xwd as an
external
process to dump the window image to a file and then compare it with the
template file.

The problem is that, sometimes but not always, the window is not
completely redrawn when we call xwd.  With logging, we noticed that the
window sometimes receives Expose events _after_ we call xwd; in those
cases, our automated test fails because the snapshot is different from
the template file.

We tried various tricks to ensure all events in the X queue are
processed before we call xwd.  The current (non-working) design is:

MANAGE   -- Make window visible
POPUP    -- Raise window to foreground
NOTIFY   -- Indicate that changes have been asked, increment counter
DISPATCH -- Dispatch and process events, decrement counter
DUMP     -- Dump window when counter is zero

The NOTIFY procedure sends a PropertyNotify event with a bespoke atom to
the window being dumped and increments a counter.

The DISPATCH procedure loops and dispatches all events in the X input
queue until it receives the PropertyNotify with the atom and no other
events are pending.  It then decrements the counter.

We are quite unhappy with this solution, which is not only ugly but also
unreliable.  We are wondering whether there might be a better solution.

The window to dump contains a menu bar and a work area with several
forms, and one or more drawing areas as children.  Those drawing areas
contain
event handlers for Expose, (Structure)Notify and Resize events.  What we
need is that all these event handlers run before we call xwd.

Note that we also tried to run our tests under 'xscope' but this seems to
hide the problem, perhaps because 'xscope' slows down the execution.  In
other words, the problem disappears when we run under xcscoe.

We would be grateful if anyone could help us in understanding X behavior.

Also, it would be very nice if we could use xwd in-process rather than as
a separate process (i.e. if there were an API called
XDumpWindowImageToFile).  Also, we would rather not maintain our own fork
of xwd for the rest of eternity; we would like this to be part of X.org.
Who should we talk to if we wanted to hire someone to implement this
feature in a future release of X.org?

Thanks for your concern.

Best Regards.

-- 
Ludovic Brenta.



More information about the xorg mailing list