[comp.windows.x] Window visibility question

epstein@trwacs.UUCP (Jeremy Epstein) (05/02/90)

I'm looking for a way to calculate which portions of a window are
visible and which are obscured.  I know that expose events will
tell me what I need to redraw, but I need to know when the window
becomes obscured, *not* when it is exposed.

Is there any mechanism in X11R4 to do this?  I've come up with some
hacky solutions (see below), as well as some ideas for extensions
to the protocol, but nothing simple or elegant.




Some ideas I've come up with (perhaps there's a refinement that would
make one of these reasonable?):

(1)	Visibility events provide some assistance, however they only record
	state changes between three states (totally visible, partially visible,
	and totally obscured), plus they don't report what areas are obscured.
	One possible solution is to extend visibility events so they report
	all partial obscuring, and add the (x,y,width,height) values of what
	was obscured.  Then using visibility events with expose events would
	be sufficient.

(2)	Another possibility is to periodically do XQueryTree() operations,
	and examine the placement and geometry of all windows higher in the
	stacking order.  This makes it fairly easy to figure out what areas
	are obscured.  The converse (what areas are visible) is somewhat
	more difficult, but still possible.  However, it still doesn't solve
	the problem of when to do the XQueryTree() operations, since there's
	no notification of new window creation.

(3)	By setting up for CreateWindow and MapWindow events I could be
	notified of all windows which are created, and then use the
	XQueryTree method as described above.  Of course, I'd probably also
	need to track resizing, window destruction, configuration, etc.

Any better solutions, please????
-- 
Jeremy Epstein
epstein@trwacs.uu.net
TRW Systems Division
703-876-8776

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (05/03/90)

    I'm looking for a way to calculate which portions of a window are
    visible and which are obscured.

Set your background to None and do a ClearArea, asking for exposures.
If you want to avoid real exposures during the interim, you'll have
to use GrabServer.

mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) (05/03/90)

> I'm looking for a way to calculate which portions of a window are
> visible and which are obscured.

> (3) By setting up for CreateWindow and MapWindow events I could be
>     notified of all windows which are created,

I don't really have any better solution, but I will note that I have a
program that (among other things) tracks the position-and-size of those
portions of the root window that are visible; this may be of some help,
as a starting point if nothing else.

If you want a copy, it's available for anonymous ftp from 132.206.1.1,
in X/xdrift.c.  (It probably won't build as-is; get
X/mterm.src/mterm.aux if you want help building it as it stands.)

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

karlton@sgi.com (Philip L. Karlton) (05/03/90)

In article <206@trwacs.UUCP>, epstein@trwacs.UUCP (Jeremy Epstein) writes:
|> I'm looking for a way to calculate which portions of a window are
|> visible and which are obscured.  I know that expose events will
|> tell me what I need to redraw, but I need to know when the window
|> becomes obscured, *not* when it is exposed.

I must be in a bit of strange mood to even suggest this, but you could always
just set the background of the window to None and then do a ClearArea of the
entire window requesting exposure events. Of course the true state of
the window
could have changed by the time you process your first Exposure event.

PK
--
Phil Karlton                            karlton@wpd.sgi.com