[comp.windows.x] Help with sending events to other clients

cjmchale@cs.tcd.ie (Ciaran McHale) (06/27/90)

In article <4408@milton.u.washington.edu> johnston@milton.u.washington.edu (Craig Johnston) writes:
>[ problem about trying to get XSendEvent() to work ]
>
>  tgtwinID = 0x12345;    /* hard coded for this example */
>
>    switch( myevent.type )
>    {
>      case KeyPress:
>      case KeyRelease:
>          sendevent = &myevent;
>          status = XSendEvent( mydisplay, tgtwinID, False, 0, sendevent);
>          break;
>          .
>          .
>          .
>    }
>  } 
>
>    I'm getting all the keystrokes and I'm fairly sure I'm using the correct
>value for the target window ID, but the xterm client acts like it is not
>receiving the events I send it.
>
>
>    Any suggestions would be welcome.  Am I even on the right track?
>
>    Thanks,   Craig Johnston  (johnston@milton.acs.washington.edu)

Your problem is that you need to set the window field in the structure
that you're sending. Otherwise the receiving client will get the
event and will ignore it becuase it doesn't have any window which
matches the window field in the event structure. Change your code to
the following:


>      case KeyPress:
>      case KeyRelease:
	   myevent.xany.window = tgtwinID; /* Destination Window */
>          sendevent = &myevent;
>          status = XSendEvent( mydisplay, tgtwinID, False, 0, sendevent);

A simple solution to a problem that many people (including myself)
have fallen prey to.

Ciaran.
-- 
Ciaran McHale
Department of Computer Science, Trinity College, Dublin 2, Ireland.
Telephone: +353-1-772941 ext 1538    FAX: +353-1-772204   Telex: 93782 TCD EI
email: cjmchale@cs.tcd.ie	or	cjmchale%cs.tcd.ie@cunyvm.cuny.edu