Cursor position calculation was not taking in to account the window client coordinates relative to the screen.