Search code examples
cunixx11ghostscriptstdio

How to route X11 Keyboard events into stdin like ghostscript does?


I'm trying to write a clone of ghostscript and I can't figure out how they make it so you can type into the graphics window, and the keystrokes show up in the terminal window as though you'd typed them there to begin with. So having received the KeyRelease Event, can I stuff the char into stdin somehow, to be read with normal filereading code? Or do I have to make my own internal buffer in front of stdin so I can hack new chars into it? Or is ther some simple way to map keyboard events from my application window to Xterm?

I'm willing to do the work, but I don't even know what I'm looking for here. Help?!!


Solution

  • Eureka!

    in the file gdevxini.c

    435             wm_hints.flags = InputHint;
    436             wm_hints.input = False;
    437             XSetWMHints(xdev->dpy, xdev->win, &wm_hints);       /* avoid input focus */
    

    Edit: Now that I know what it looks like, I was able to find some documentation:

    The input member is used to communicate to the window manager the input focus model used by the application.... Applications that never expect any keyboard input ... should set this member to False. --X Window System: C Library and Protocol Reference, p.282