Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm interested in writing a X server in perl/Tk (unless someone can point me to an existing one). I figure that since Tk already has bindings for X events it shouldn't be too difficult to write a server to accept incoming connections and pass the incoming event stream to Tk. What I'm trying to locate is documentation on how perl and Tk communicate. I've looked through the source code for the Tk module but I can't tell where the X events are created. Any help would be appreciated. Thanks, CAK.

Replies are listed 'Best First'.
Re: Tk and X events
by kschwab (Vicar) on Aug 08, 2002 at 03:53 UTC
    I'm not sure I understand the question. It reads something like:

    I want to build a house out of a door

    Or perhaps you really want to write an X server ? There's really nothing that the Tk module would help you with there. There is a module that implments the client side of the X11 protocol. See X11::Protocol.

    Update: Ahh..I think I see the light now...

    Since Tk runs on Windows without X11, you'd like to create a canvas or something, accept the X11 client connections on port 6000, and draw on the canvas. That's a pretty imposing project, and I don't think you'll get enough speed using Tk primitives to draw with.

    There is a pretty decent, stable X11 server for Win32 out there. See Xfree86 running on Cygwin. I also stumbled into an X11 window manager written in perl ( shudder :)

      Hi there. Thanks for the reply. Sorry if I wasn't being too clear. You're right, I want to write a free X server for Win32. Here's the way I assume that the Tk module works. Tk, as originally written by John Ousterhout, was desinged to run on an X server. That is, the server would send Tk an X event to create a new screen or Tk would send the server an X event to indicate pointer position or a keypress (or maybe it's the other way around). I assume that this is still the case in perl/Tk (unless the Tk module was modified to use a different event structure just for perl, which actually might be the case in Win32). What I'm trying to discover is where these events are being created and whether or not I can insert my own stream of X events for Tk to interact with. I haven't been able to locate any documentation yet on the internals of perl/Tk. Thanks, CAK.