You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: mouse.rs
    path of file: ./repos/ggez/src/input
    
    the code of the file until where you have to start completion: //! Mouse utility functions.

use crate::context::Context;
use crate::error::GameError;
use crate::error::GameResult;
use std::collections::HashSet;
use winit::dpi;
pub use winit::event::MouseButton;
use winit::window::CursorGrabMode;
pub use winit::window::Cursor
    
pub fn set_cursor_grabbed(ctx: &mut Context, grabbed: bool) -> GameResult {
    ctx.mouse.cursor_grabbed = grabbed;
    ctx.gfx
        .window
        .set_cursor_grab(if grabbed {
            if cfg!(target_os = "macos") {
                CursorGrabMode::Locked
            } else {
                CursorGrabMode::Confined
            }
        } else {
            CursorGrabMode::None
        })
        .map_err(|e| GameError::WindowError(e.to_string()))
}