Simplify the mouse grabbing/relative mode setting code.