Newsgroups: comp.windows.x
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines
From: mouse@lightning.mcrcim.mcgill.EDU (der Mouse)
Subject: Re:  Setting input focus to terminal window
Message-ID: <9103240831.AA05524@lightning.McRCIM.McGill.EDU>
Sender: daemon@athena.mit.edu (Mr Background)
Organization: The Internet
Date: 24 Mar 91 08:31:32 GMT
Lines: 51

(In passing, something seems to be wrong with your local news software.
In particular, your From: line was
	From: pete@jwgibbs.cchem (Pete Goodeve)
which is pretty much useless.  I guessed the berkeley.edu from the
Organization: line.)

> There's something I'm missing regarding the management of keyboard
> focus in the presence of a manager.  I have a program in which I want
> to switch focus back to the terminal window from which the program is
> running

There may be no such window.  The program could have been started from
a remote machine via rsh or from a window manager menu.  Or it could
have been started from a terminal emulator which has since been shut
down.  Or the emulator could be iconified, etc (you get the idea).

> (away from the work window the program itself has created) so that
> the user can type in some new parameters; the switch is triggered by
> some event in the main window (mouse-click or key-press).

The proper solution is, as you say, to do it via some window in your
own application.  (Whether this window is a popup or not is more or
less irrelevant to the issue of setting focus.)

> My expectation was that I could do XGetInputFocus BEFORE I opened any
> window from the program, and acquire the ID of the terminal window,
> as that must surely be the one with the current focus, no?

If it exists, it probably is, at that time.  This is not certain,
though; input focus could be PointerRoot rather than a window.

> Then, when the program wanted K/B input, it would simply issue
> XSetInputFocus to that window until input was complete.

> Well, I get a window ID alright, but trying to change the focus to it
> has absolutely no effect!

More likely it does what you want it to, but the window manager
immediately sets it back to where its keyboard focus policy indicates
it should be.

> Also the ID I get doesn't seem to be that of the terminal window
> itself, but rather its window-manager-decorated parent!

Quite possibly.  It seems slightly odd to me, but I can't really call
it wrong.

					der Mouse

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