Improvement to the mouse-grab system