Bugfix: Setting correct current window

Fixed a bug that caused an incorrect current window pointer when enter
key has been typed