Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!dont-send-mail-to-path-lines From: mouse@lightning.mcrcim.mcgill.EDU (der Mouse) Newsgroups: comp.windows.x Subject: Re: Emacs 18.57 X focus/cursor weirdness with twm R4? Message-ID: <9103060559.AA04928@lightning.McRCIM.McGill.EDU> Date: 6 Mar 91 05:59:43 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 59 > I've noticed a change in the way emacs interacts with R4 twm. In > particular, when getting and giving up focus, the block cursor will > not always change color correctly. For a program to determine whether or not it has keyboard focus is not a trivial matter. As far as I can tell, the program must ask for EnterNotify/LeaveNotify events on its own window and FocusIn/FocusOut events on both its window and the root window, and keep a state variable to tell whether or not PointerRoot focus is in use. The algorithm is, basically: EnterNotify: if PointerRoot focus is in use, we now have focus. LeaveNotify: if PointerRoot focus is in use, we now don't have focus. FocusIn: if mode is neither NotifyNormal nor NotifyWhileGrabbed, or detail is NotifyInferior, ignore the event entirely. else, if the window is the root, if detail is NotifyPointerRoot, PointerRoot focus is now in use. if detail is NotifyDetailNone, PointerRoot focus is now not in use. else, if the window is the our top-level window, we now have focus. FocusOut: if mode is neither NotifyNormal nor NotifyWhileGrabbed, or detail is NotifyInferior, ignore the event entirely. else, if the window is the root, if detail is NotifyPointerRoot, PointerRoot focus is now not in use. else, if the window is the our top-level window, we now don't have focus. If anyone can construct a case which breaks this, or if someone can point out any unnecessary complexity, I'd love to hear about it.... > [D]oing the same thing to the xterm window does not mess up its > cursor block. This is because xterm ignores the Focus(In/Out) events > and just toggles its cursor solidness on (Enter/Leave)Notify events > (see xterm's misc.c file). It can't be quite that simple. On the rare occasions when I run xterm, I see its cursor track focus correctly whether or not that focus is related to the pointer position. (My window manager doesn't do focus-follows-pointer.) In particular, merely entering the window with the pointer does not highlight the cursor when focus is not thereby transferred, and correspondingly for leaving the window. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu