Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!ccut!wnoc-tyo-news!astemgw!choshi!frf!ichida From: ichida@pt1.ncl.omron.co.jp (ICHIDA.T) Newsgroups: comp.windows.open-look Subject: Re: Keyboard Input and olwm (XLib) Message-ID: Date: 13 Mar 91 01:08:52 GMT References: <1991Mar11.142805.16777@mack.uit.no> Sender: news@frf.omron.co.jp Reply-To: ichida@pt1.ncl.omron.co.jp Organization: OMRON Co., Kyoto, 617 Japan. Lines: 64 In-reply-to: frodek@forit.forut.no's message of 11 Mar 91 23:28:05 JST In article <1991Mar11.142805.16777@mack.uit.no> frodek@forit.forut.no (Frode Kileng) writes: > When a key is pushed the window manager beeps so it seems that > the windowmanager receives the input but will not send it to my > application. I faced same problem. When program needs key-input, program must set window manager hints defined in ICCCM. I created following example program. Please watch marked lines.(specified as '<-'). <<< test.c >>> #include #include #include void main() { Display *display; Window window; GC gc; int screen; XEvent event; XWMHints wm_hints; <- display = XOpenDisplay(NULL); screen = XDefaultScreen(display); window = XCreateSimpleWindow(display, RootWindow(display, screen), 100, 100, 500, 500, 5, BlackPixel(display, screen), WhitePixel(display, screen)); XSelectInput(display, window, KeyPressMask | ExposureMask); gc = DefaultGC(display, screen); wm_hints.flags = InputHint; <- wm_hints.input = True; <- XSetWMHints(display, window, &wm_hints); <- XMapWindow(display, window); for (;;) { XNextEvent(display, &event); switch (event.type) { case KeyPress: puts("key pressed"); break; case Expose: XDrawRectangle(display, window, gc, 10, 10, 480, 480); break; default: puts("other event"); break; } } } --- OMRON Corporation Toshihiko Ichida. Mail: ichida@pt1.ncl.omron.co.jp