XSendEvent() Not working!! Hints on how to debug?!

XSendEvent() Not working!! Hints on how to debug?!

Post by sasa » Sat, 13 Mar 1999 04:00:00



I am trying to perform the following exercize the following in X event
handling:

I have an xterm window open with id = 0x300000d

Now I want to write a piece of code that simulates the keyboard by sending
keys to this xterm. The effect I am hoping is that characters will appear
in the xterm window.

Here's the jist of my code:

-----------

{
  /* I have display and window available at this point */

  long emask=(KeyPressMask|KeyReleaseMask);

  XSelectInput (display, window, emask);

  {
        XKeyPressedEvent evnt;

        evnt.serial = 0;
        evnt.send_event = 1;
        evnt.display = display;
        evnt.window = window;
        evnt.root = 0x25;
        evnt.subwindow = 0;
        evnt.time = CURRENT_TIME;
        evnt.x = 0;
        evnt.y = 0;
        evnt.x_root = 0;
        evnt.y_root = 0;
        evnt.state = 0;
        evnt.keycode = 40; /* I am typing an A */
        evnt.same_screen = 1;

        evnt.type = KeyPress;              
        status  = XSendEvent(display, window, (Bool)1, emask, (XEvent *)&evnt);

        evnt.type = KeyRelease;
        status  = XSendEvent(display, window, (Bool)1, emask, (XEvent *)&evnt);
    }

Quote:}

I would appreciate hints on how to debug this problem. I basically don't get
anythinig in my Xterm window.

Please email back if you can.

Thanks.

Si

 
 
 

1. XSendEvent : how does it work?

Hi.

I'm trying to develop a game using only XLib. I need to have some kind
of synchronization. For that I tought of using a second process which
simply sends some event for the main process to respond to. I tried
sending the "ClientMessage" event with something like this :

second_process()
{
   XClientMessageEvent ev;

   while(1)
   {
      XSendEvent(dpy, win1 , True, eventmask, (XEvent *)&ev);
      usleep(33333);
   }

but the main loop doesn't seem to receive any event. The main loop looks
like this :

while(1)
{
   XNextEvent(dpy,&event);
   switch (event.type)
   {
      case Expose:
         XClearWindow(dpy,win1);
      break;
      case KeyPress:
         XDestroyWindow(dpy, win1);
         XCloseDisplay(dpy);
         exit(0);
      default:
         XDrawString(dpy, win1, gc, 20, 40, "Other Event", 11);
      break;
   }

What am I doing wrong ?

Thank you in advance for your help ...

---------------------
JF Boily

---------------------

2. ava-1502 ISA scsi controller

3. Help: KDE apps. not responding to XSendEvent

4. How do I detect xterm from a shell?

5. Help: Apps. not responding to XSendEvent()

6. Fatal server error... cannot open /dev/tty0 (No such file or directory)

7. need a hint for debugging a select problem with pthreads

8. RedHat Linux 7.0: LILO hangs

9. Hints for debugging segmentation fault in malloc

10. to debug or not to debug (was Re: Hiring Unix programming interns - writing an online quiz)

11. Internet with Debug works, with PPP dialer not

12. HELP: ksh "trap DEBUG" not working

13. X+iBCS+WP60 hints on how to make it work