Added a method to query the currently focused window.

This will help writing the 'on_destroynotify' handler (since it needs to
muck around with the focused window). Also, a new test confirms that the
new method works properly.