I embedded a X11 app (xterm) in a Motif window. All seems to work fine, but if I press a key when the pointer isn't above the embedded app, it doesn't get it. Trying to fix this, I changed the main loop of the main app. Now it's like this:
XEvent ev;
for (;;)
{
XtAppNextEvent (app, &ev);
/* If the event is a keypress, send it to
* the xterm window. Else, dispatch it.
*/
Window *xtW = NULL, parent, _root;
unsigned int noC;
if (ev.type == KeyPress || ev.type == KeyRelease)
{
#ifdef DEBUG
fprintf (stderr, "Key event\n");
#endif
while (xtW == NULL)
XQueryTree (XtDisplay (drawW), XtWindow (drawW), &_root,
&parent, &xtW, &noC);
XSendEvent (XtDisplay (drawW), *xtW, True,
(KeyPressMask | KeyReleaseMask), &ev);
XFlush (XtDisplay (drawW));
#ifdef DEBUG
fprintf (stderr, "sent key event\n");
#endif
}
else
XtDispatchEvent (&ev);
}
When I press a key outside embedded xterm the debug line being printed, but xterm doesn't print the key I sent.
How can I fix this? If needed, I'll post the code.
--mghis