Troubleshooting high CPU activity in the WindowServer process

Check out the man page for perfdiagnose. This tool is purpose-made for diagnosing exactly this sort of issue, where a simpler tool like Activity Monitor can only show you symptoms.

The output from perfdiagnose is not intended for end-users, but for developers and teams at Apple. If you're not able to make any sense of the logs it produces, your best bet is to attach them to a bug report submitted to Apple.