[comp.windows.x] Finding out if you're Iconified

bpistr@ciba-geigy.ch (Joseph C Pistritto) (09/19/90)

I need to find out if my application is iconified (either by
the user or automatically by another program), or actually
being displayed on the screen.

At the moment, I'm doing this by examining the 'map_state' of
the window associated with toplevel shell of the application.
When this goes to 'IsUnmapped', then I assume I've been iconified
and stop doing some heavy work to update the screen.  When it
returns to any other state, I start working again.

I'm interested in knowing if there is a more 'politically correct'
way of finding out whether I'm iconified.

I'm using MWM & X11R4.

Please reply directly to me, as I don't see this list regularly.
                                                -jcp-
--
Joseph C. Pistritto (bpistr@ciba-geigy.ch, jcp@brl.mil)
 Ciba Geigy AG, R1241.1.01, Postfach CH4002, Basel, Switzerland
 Tel: +41 61 697 6155 (work) +41 61 692 1728 (home)   GMT+2hrs!

kaleb@thyme.jpl.nasa.gov (Kaleb Keithley) (09/19/90)

In article <9009190847.AA25606@zit.cigy.> bpistr@ciba-geigy.ch (Joseph C Pistritto) writes:
>I need to find out if my application is iconified (either by
>the user or automatically by another program), or actually
>being displayed on the screen.
>
>I'm interested in knowing if there is a more 'politically correct'
>way of finding out whether I'm iconified.
>

I don't know about "politically correct," but you could add an EventHandler
to field the UnmapNotify event that is generated when the window is iconified.
And the inverse event, MapNotify when the window is uniconfied.

I also thought that the VisibilityNotify event might do what you want, however
the "unobscured" event is generated when uniconifying, but the "obscured" 
event is not when iconifying.  Humhhhh, I wonder if this is a bug?  Does
iconfication qualify as "obscured?"

-- 
Kaleb Keithley                      Jet Propeller Labs
kaleb@thyme.jpl.nasa.gov

"So that's what an invisible barrier looks like!"

dshr@eng.sun.COM (David Rosenthal) (09/20/90)

> I need to find out if my application is iconified (either by
> the user or automatically by another program), or actually
> being displayed on the screen.

RTFM.  In this case,  section 4.1.4 of the ICCCM is the FM to R.  Pages 519
to 521 of the Digital Press 2nd edition.

In fact,  what you want has nothing to do with being iconified.  You
want to know if the window is worth going to the expense of updating.
It isn't worth doing so if the window is in normal state but buried
under other windows so as to be invisible.  See the last paragraph of
section 4.1.4 about VisibilityNotify.

	David.

mouse@LARRY.MCRCIM.MCGILL.EDU (09/20/90)

>> I need to find out if my application is iconified (either by the
>> user or automatically by another program), or actually being
>> displayed on the screen.

Those are not the only possibilities.  For example, it could be
uniconified but completely off-screen (with tvtwm and other "virtual
desktop" window managers, this is even likely).

> I also thought that the VisibilityNotify event might do what you
> want, however the "unobscured" event is generated when uniconifying,
> but the "obscured" event is not when iconifying.  Humhhhh, I wonder
> if this is a bug?  Does iconfication qualify as "obscured?"

From the Xlib document:

	8.4.6.10.  VisibilityNotify Events
	
	The X server can report VisibilityNotify events to clients
	wanting any change in the visibility of the specified window.
	A region of a window is visible if someone looking at the
	screen can actually see it.
...
	The X server ignores all of a window's subwindows when
	determining the visibility state of the window and processes
	VisibilityNotify events according to the following:
	
	o    When the window changes state from partially obscured,
	     fully obscured, or not viewable to viewable and completely
	     unobscured, [...] VisibilityUnobscured.
	
	o    When the window changes state from viewable and completely
	     unobscured or not viewable to viewable and partially
	     obscured, [...] VisibilityPartiallyObscured.
	
	o    When the window changes state from viewable and completely
	     unobscured, viewable and partially obscured, or not
	     viewable to viewable and fully obscured, [...]
	     VisibilityFullyObscured.

Nothing about changes to non-viewable states, so no, it's not a bug.
IMO it's a misfeature, though.  Unmapping certainly changes a window's
visibility, as defined in the first paragraph quoted above.

					der Mouse

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