Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sending an "expose" X event...

789 views
Skip to first unread message

Roland Mainz

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to

Hi !

----

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

-ke...@nojunk.rahul.net-

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
In article <3972BD89...@informatik.med.uni-giessen.de>,

Roland Mainz <roland...@informatik.med.uni-giessen.de> wrote:
>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()) ?

XClearArea() is usually easier.
--
Ken Lee, http://www.rahul.net/kenton/

Derek M. Flynn

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Roland Mainz wrote:

> -ke...@nojunk.rahul.net- wrote:
> >
> > In article <3972BD89...@informatik.med.uni-giessen.de>,
> > Roland Mainz <roland...@informatik.med.uni-giessen.de> wrote:
> > >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()) ?
> >
> > XClearArea() is usually easier.
>
> Uhm, no - I don't like to clear the window - I'd like to force a
> complete redraw of the window contents.

Read the manual page for XClearArea.

-Derek


Roland Mainz

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
-ke...@nojunk.rahul.net- wrote:
>
> In article <3972BD89...@informatik.med.uni-giessen.de>,
> Roland Mainz <roland...@informatik.med.uni-giessen.de> wrote:
> >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()) ?
>
> XClearArea() is usually easier.

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...

Robert Cox

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
Roland Mainz (roland...@informatik.med.uni-giessen.de) wrote:
: 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:

/*--------------------------------------------------------------------
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 ;
}


Derek M. Flynn

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
Robert Cox wrote:

> : 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


0 new messages