As far as I know, there is no way to reliably get a process ID from an X window ID for local clients (to implement Richard's View Source idea). I would love to be wrong!
(1) Did I miss something? Can this be done now?
(2) If this can't be done now, what would it take? Could we create an X extension so that the server can supply connection info for a window, and then trace that connection info back to a specific process?
These are my first two books: X Power Tools, a thorough guide to the X Window System (O'Reilly, ISBN 9780596101954) and Fedora Linux: A Complete Guide to Red Hat's Community Distro, a practical hands-on book on Fedora (O'Reilly, ISBN 9780596526825).
Fedora Linux is also available for online reading through Safari and in downloadable PDF format from oreilly.com