Fix setCursorPosition to use top-left origin

Fixes #1003.