Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!pa.dec.com!nntpd.lkg.dec.com!engage!3d.enet.dec.com!davis From: davis@3d.enet.dec.com (Peter Davis) Newsgroups: comp.windows.x Subject: Grabbing keys Message-ID: <1991May22.200531.364@engage.pko.dec.com> Date: 22 May 91 19:58:43 GMT Sender: newsdaemon@engage.pko.dec.com (USENET News Daemon) Organization: Digital Equipment Corporation Lines: 23 I'm trying to write a program that will grab a few keys and handle events from them. This program will not have a window of its own, but I want it to grab events from the specified keys regardless of where the focus is. NB: Before anyone starts flaming about what a bad practice this is, it's just a hack program that I'm going to run on my own system. Anyway, I think it should be possible to just do something like: Display *disp = XOpenDisplay (NULL); XGrabKey (disp, XKeysymToKeycode (disp, XK_Left), AnyModifier, RootWindow (disp, DefaultScreen (disp)), True, GrabModeAsync, GrabModeAsync); However, when I do this, the program crashes inside XNextEvent when I type one of the grabbed keys. Am I allowed to specify the root window as my grab_window? Is there something else I need to do to accomplish this? Thanks. -pd