home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!uwm.edu!wupost!darwin.sura.net!ra!hightop!humphrey
- From: humphrey@hightop.nrl.navy.mil (Jeff Humphrey [Jeffus])
- Newsgroups: comp.windows.x
- Subject: Xlib Bug ?
- Message-ID: <BxB0nz.1nx@ra.nrl.navy.mil>
- Date: 6 Nov 92 17:02:22 GMT
- Article-I.D.: ra.BxB0nz.1nx
- Sender: usenet@ra.nrl.navy.mil
- Organization: Naval Research Labs (Washington DC)
- Lines: 86
- Originator: humphrey@hightop
-
-
- Problem:
- A program I recently wrote worked fine except for one thing. When
- recieving key events, the program wouldn't catch them if you initially
- placed the base window over the root window of the display. I thought
- it might have just been my code, so I tried out a few other programs.
- 'xev' would do the same thing ... that is to say ... If I run 'xev'
- and place the window in the root window (completely .. not overlapping
- any other windows), then 'xev' will not display key events. Instead
- of catching them, they go to the window which I ran 'xev' from.
- More confusing ... if I run 'xev' and put it over a window OR put it
- in the root window and iconify then reopen it ... it works fine.
- Thinking that the problem might then be part of my environment, I
- used someone elses account to test it out. It was still messed up.
- Now I thought it was the setup of X-Windows on my machine, so I
- went to another facility and tried it there ... still now luck.
- The window still didn't catch events until it was closed and reopened.
-
- Question:
- Can anyone verify whether or not this is ...
- A) A bug in two X programs and the one I wrote
- B) Incorrect machine setup on two completely seperate systems
- C) A bug in X
- Can anyone mimic this problem on their machine ?
-
- Test:
- Following is the code I used to determine whether or not I was
- getting KeyPress events or not. Compile and run the program under
- the following conditions ...
- A) Place the window completely on the root window initially. Type
- on the window ... Possible results ...
- a) The program works fine ... You get a bunch of lines saying
- 'Got KeyPress' on your xterm (or whatever)
- b) The program is hosed up and you get everything you type
- on the xterm.
- B) If you fall into the second catagory above, close the window and
- reopen it. Now try it ... Did you get the 'Got KeyPress' response
- now ?
- C) Re-run the program and place the window initially over one of your
- xterms ... Did you get 'Got KeyPress' ? I did ...
-
- /*** INCLUDED TEST PROGRAM THING ***/
-
- #include <X11/Xlib.h>
- int main (argc,argv)
- int argc;
- char **argv;
- /***************************/
- /* cc -o prog prog.c -lX11 */
- /***************************/
- {
- Display *display;
- Window window;
- int screen;
- XEvent event;
-
- if ((display = XOpenDisplay ("")) == (Display *) NULL)
- { printf ("Can't open display\n"); exit (1); }
- screen = DefaultScreen (display);
- window = XCreateSimpleWindow (display,RootWindow (display,screen),
- 10,10,160,160,3,
- BlackPixel (display,screen),
- WhitePixel (display,screen));
- XSelectInput (display,window,KeyPressMask);
- XMapWindow (display,window);
- XFlush (display);
- for (;;)
- {
- XNextEvent (display,&event);
- switch (event.type) {
- case (KeyPress):
- printf ("Got KeyPress\n");
- break;
- default: break;
- }
- }
- }
-
- /*** END INCLUDED TEST PROGRAM THING ***/
-
- Thanks in advance for any info ...
- --
- _ ___ ___ _ _ ____
- | | / _ \ / __| | | | ___| #include "standard.disclaimer" <- IMHO
- | |__| |_| | |__| |_| |___ | humphrey@hightop.nrl.navy.mil (703)960-1000
- |____|\___/ \___|\___/|____| @Naval Research Labs (202)404-8241
-