Fix mouse position recording so it works when the window has been scrolled