Interprocess Communication (X11-Client --> X11-=Client)

Glynn Clements glynn at gclements.plus.com
Tue Feb 22 18:32:26 PST 2005


kcox at onebox.com wrote:

> I have a somewhat difficult question (at least for me). I am trying to
> send characters to an X11 client process without that process being in
> focus. For example:
> 
> X11 Clients:
> 1: Small dumb program running in ATerm
> 2: An intance of Eterm.   
> 
> How do I get the program in ATerm to output characters in the Eterm window?
> 
> My first thought was to start sending keystrokes to the X11 server. 
> However those keystrokes will only get dumped into the window that is
> in focus. Any remotely close ideas are dutifly appreciated. If I'm
> barking on the wrong list please let me know.

How does 1 know where it's supposed to send the characters?

You can use XSendEvent() to send KeyPress events to a specific window,
but you need to know the window's XID. If you don't have this, you can
enumerate the window tree down from the root window(s) using
XQueryTree() and search for a window which matches certain criteria
(e.g. having a suitable value for the WM_NAME property).

However, I don't know about eterm, but xterm may or may not accept
"sent" events (events with the send_event flag set) depending upon the
state of the "Allow SendEvents" menu option (allowing sent events can
be considered a security risk).

-- 
Glynn Clements <glynn at gclements.plus.com>



More information about the xorg mailing list