[comp.windows.x] help...is a window state Iconic?

oj@apollo.uucp (Ellis Oliver Jones) (02/07/88)

In article <8802062352.AA24340@devnull.sun.com>
dshr@SUN.COM (David Rosenthal) clarified
the action of window managers with regard to changing the state of
a window from iconized to normal and back again.  David pointed out a problem
with my analysis about using XGetWindowAttributes to find out
whether a window is iconized.  He wrote

>Almost all window managers will
>re-parent your top-level window to be a child of a window belonging to the
>window manager.
                
If what you're after is whether you should draw into the window
or not, XGetWindowAttributes does, in fact, 
tell you almost exactly what you need to know.
The "map_state" member of the XGetWindowAttributes structure
comes back with one of the values IsUnmapped, IsUnviewable, IsViewable.  
If your window is reparented onto a decoration
window by the window manager, and it's
iconized by an unmapped parent, that still makes your
window unviewable.  So my suggestion should still work, as long as you check for
 (xwa.map_state != IsViewable) rather than  (xwa.map_state == IsUnmapped)

VisibilityNotify events go even further towards letting you save
useless drawing.  If you solicit events with VisibilityChangeMask,
you'll get events telling you when your window has just become
fully obscured (completely covered by some non-inferior window, 
or unviewable, or Unmapped).  You'll also get events telling
you when your window has become partially obscured, or unobscured.
Unless you have backing store, there's no point in issuing drawing
requests for a fully obscured window.

If you care exactly what state the window manager
has placed your window in (as opposed to just whether it
is in a state where the user can see what you draw), you will,
of course, have to watch the (to-be-specified) WM_STATE property.

>In some cases,  resolving these problems involves experimentation...

The core protocol has a lot of very useful stuff in it for keeping track
of "raw" window state, as opposed to "window-manager" window state.  Many applications
can scrape by through watching the raw window state.

/oj