Fix bug that cursor are drawn out of view boundary