Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!stan!marvin!toml From: toml@marvin.Solbourne.COM (Tom LaStrange) Newsgroups: comp.windows.x Subject: Re: Can you XMapWindow and XSetInputFocus ? Message-ID: Date: 7 Jun 91 12:29:37 GMT References: <245@qt.cs.utexas.edu> Sender: toml@solbourne.com (Tom LaStrange) Organization: Solbourne Computer, Inc. Lines: 41 In-Reply-To: mayoff@cs.utexas.edu's message of 3 Jun 91 20:08:45 GMT > >Say I have a top-level window that has the input focus. I want to map > >another top-level window and set input focus to it. I want to do something > >like this: > > MapTheWindow(window); > > SetTheFocus(window); > >I do not want MapTheWindow to return until I can set input focus to the > >window, it and all of it's ancestors must be mapped. MapTheWindow cannot > >simply wait for a MapNotify event because the window manager may map the > >client window and then sometime later map its frame. In between, input focus > >cannot be set because an ancestor of the window is unmapped. MapTheWindow > >cannot wait for a VisibilityNotify event because the window may be > >completely obscured. It cannot wait for Expose events for the same reason. > > > >What I really want is an event that tracks the state of the map_state member > >of the XWindowAttributes structure. > > You *CAN* wait for VisibilityNotify. To quote Scheifler, Gettys, & > Newman, "X Window System C Library and Protocol Reference": > > When a window changes state from partially or fully obscured or not > viewable to viewable and completely unobscured, an event with > "Unobscured" is generated. When a window changes state from viewable > and completely unobscured or not viewable, to viewable and partially > obscured, an event with "PartiallyObscured" is generated. When a > window changes state from viewable and completely unobscured, from > viewable and partially obscured, or from not viewable to viewable and > fully obscured, an event with "FullyObscured" is generated. > > So, whenever a window and all its ancestors become mapped, so that it > is viewable, a VisibilityNotify is generated on that window. A detail > indicates just "how visible" the window is, but you don't seem to be > interested in that. Hence, you need simply to use the > VisibilityChangeMask in your event mask, and call XSetInputFocus > whenever you get a VisibilityNotify event. I have the case where the window starts out not visible, gets mapped and is still not visible because it is completely obscured. No VisibilityNotify events are generated. -- (I kid you not)Tom LaStrange toml@Solbourne.COM