Linux – How to list all running X applications

linuxpsscreenshotsolarisxorg

I'd like to get a list of all of the apps (across all users) on my machine that are talking to the X server. What's the most reliable way to do that? Find the socket X runs on and lsof for connections to it? I'm running both Linux and Solaris boxes, so I'd be interested in answers for both OS's.