andrew@ee.su.oz.au (Andrew Ho) (02/26/91)
Hi, I am writing an X-window application. The application should read all the keyboard events no matter whether the mouse is inside or outside the application window. What x-routines and events do I have to use ? Thanks for any pointers !!! andrew@ee.su.oz.au
mouse@lightning.mcrcim.mcgill.EDU (02/28/91)
> I am writing an X-window application. The application should read > all the keyboard events no matter whether the mouse is inside or > outside the application window. What x-routines and events do I have > to use ? (What's the position of the mouse got to do with it? Not everybody uses real-estate-driven focus, y'know!) There are two answers to this. One is to say "you don't want to". Normally, the choice of which application keystrokes are to be delivered to should be left up to the window manager as proxy for the user. Trying to override this is, at best, ill-behaved - to put it another way, don't think you know better than the window manager where keystrokes should go, because you probably don't. If you think you want all keystrokes even when the user has chosen to use focus-follows-pointer, you are probably trying to solve the wrong problem. The other is to grab the keyboard. This is appropriate only when you really must freeze all (keyboard) interaction by that user with other clients for the duration of the operation in question; an example might be a program reading a password, where the grab is used to ensure that no other client is spying on the keystrokes; there really are very few cases where this is the right answer. (Most cases where it appears to be can be better handled with passive grabs.) Why do you think you want all keystrokes? I am much better at suggesting solutions when I know more about the problem. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu