Added window methods to request and to check focus

Alright I collected all the fixes for issue #518 in this pull request. The patches for Windows and Linux are tested and working. The Mac part is the only thing missing.