Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!mayoff From: mayoff@cs.utexas.edu (Robert Mayoff) Newsgroups: comp.windows.x Subject: Re: Can you XMapWindow and XSetInputFocus ? Message-ID: <245@qt.cs.utexas.edu> Date: 3 Jun 91 20:08:45 GMT References: Organization: Dept of Computer Sciences, UTexas, Austin Lines: 39 In article toml@marvin.Solbourne.COM (Tom LaStrange) writes: >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. -- /_ rob /_ Fun things to do with UNIX (#118 in a series): / tail -f super.grow | cat /etc/motd - >> super.grow