xtrace | trace communication between X client and server | Mehr ...
What strace is for system calls, xtrace is for X11 connections: you hook it between one or more X11 clients and an X server and it prints the requests going from client to server and the replies, events and errors going the other way.