----
Can anyone here post a small example how to force a complete "redraw" of
a X window (or parts of it) via manually sending an "expose" event (via
XSendEvent()) ?
Thanks !
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) Roland...@informatik.med.uni-giessen.de
\__\/\/__/ gis...@informatik.med.uni-giessen.de
/O /==\ O\ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
(;O/ \/ \O;) TEL +49 641 99-13193 FAX +49 641 99-41359
XClearArea() is usually easier.
--
Ken Lee, http://www.rahul.net/kenton/
Read the manual page for XClearArea.
-Derek
Uhm, no - I don't like to clear the window - I'd like to force a
complete redraw of the window contents.
I'd like to write a demonstrator for libXp/Xprt which uses the Mozilla
GTK widget. The idea is stupid and simple:
XpStartPage(), render_mozilla_display(), XpEndPage() - and the whole
page get's printed...
This isn't exactly that, but will do for an Xt Widget:
/*--------------------------------------------------------------------
force an immediate expose for the widget
----------------------------------------------------------------------*/
#include <X11/IntrinsicP.h>
void expose_widget( Widget w )
{
XExposeEvent xev;
Dimension ww , hh ;
if( ! XtIsRealized(w) ) return ;
if( ! XtIsManaged(w) ) return ;
xev.window = XtWindow(w) ; if( xev.window == (Window) NULL ) return ;
xev.type = Expose ;
xev.display = XtDisplay(w) ;
xev.x = xev.y = 0 ;
XtVaGetValues( w, XmNwidth, &ww, XmNheight, &hh, NULL ) ;
if( ww <= 0 || hh <= 0 ) return ;
xev.width = ww ; xev.height = hh ;
(XtClass (w))->core_class.expose( w, (XEvent *)&xev, NULL ) ;
XFlush( XtDisplay(w) ) ;
return ;
}
> : Can anyone here post a small example how to force a complete "redraw" of
> : a X window (or parts of it) via manually sending an "expose" event (via
> : XSendEvent()) ?
>
> This isn't exactly that, but will do for an Xt Widget:
Blarg. I believe this should have a disclaimer indicating that it is the
completely wrong way to do it. You shouldn't ever (need to) directly call
function pointers in the widget. But with one line changed, you can do it
in a less implementation dependent manner:
Substitute:
> (XtClass (w))->core_class.expose( w, (XEvent *)&xev, NULL ) ;
with (warning: unchecked)
XSendEvent (XtDisplay (w), XtWindow (w), True, ExposureMask, &xev);
or (as Kenton suggested [again unchecked]):
XClearArea (XtDisplay (w), XtWindow (w), 0, 0, width, height, True);
and in each case you can substitute the Display * and Window if you already
have them (ie if you aren't using Xt):
XSendEvent (dpy, window, True, ExposureMask, &xev);
XClearArea (dpy, window, 0, 0, width, height, True);
-Derek