How do I set the window position in the GGEZ game crate?

I've looked at the docs, but can't see a way to do this.
It seems winit::Window::set_position() is the way to go (winit and glutin being the same thing), but I can't see how to get a reference to winit::Window.

Here's the code that produces a window and game loop:

pub fn main() -> ggez::GameResult {
    /* #region  Establish access to resources folder */
    let resource_dir = if let Ok(manifest_dir) = env::var("CARGO_MANIFEST_DIR") {
        let mut path = path::PathBuf::from(manifest_dir);
        path.push("resources");
        path
    } else {
        path::PathBuf::from("./resources")
    };
    /* #endregion */

    let cb = ggez::ContextBuilder::new("super_simple with imgui", "ggez")
        .add_resource_path(resource_dir)
        .window_setup(conf::WindowSetup::default().title("super_simple with imgui"))
        .window_mode(
            conf::WindowMode::default().resizable(true).maximized(true),
        );

    let (ref mut ctx, event_loop) = &mut cb.build()?;

    let hidpi_factor = event_loop.get_primary_monitor().get_hidpi_factor() as f32;
    println!("main hidpi_factor = {}", hidpi_factor);

    let state = &mut MainState::new(ctx, hidpi_factor)?;

    event::run(ctx, event_loop, state)
}

The window does not appear to be available from ggez, since it's stored inside the GraphicsContext and that is not exposed in the public ggez Context API. You may want to file an issue in GitHub - ggez/ggez: Rust library to create a Good Game Easily about making it possible to set or adjust the window position.

I finally found a way to set the position of the ggez window!

    // Set window position here   
    let (ref mut ctx, event_loop) = &mut cb.build()?; 
    let window = graphics::window(ctx);    
    let mut pos = window.get_position().unwrap();   
    pos.x = 0.0;    
    pos.y = 0.0;    
    window.set_position(pos);

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.