Selenium: How to check that current window (handle) is in focus?

My problem is that I want to crawl a very modern, dynamic web page. I noticed that some elements are not just dynamically loaded, they are only loaded when the window is in focus (foreground)!

How can I check with the Selenium API that a web driver window is ‘in focus’?