Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window.set_minimized not work on macOS #3537

Open
gqf2008 opened this issue Mar 1, 2024 · 1 comment
Open

Window.set_minimized not work on macOS #3537

gqf2008 opened this issue Mar 1, 2024 · 1 comment

Comments

@gqf2008
Copy link

gqf2008 commented Mar 1, 2024

code


let event_loop = EventLoop::new().unwrap();

    let window = WindowBuilder::new()
        .with_title("A fantastic window!")
        .with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
        .with_decorations(true)
        .with_fullsize_content_view(true)
        .with_titlebar_transparent(true)
        .build(&event_loop)
        .unwrap();
    window.set_decorations(false);

    window.set_minimized(true);
    event_loop.run(move |event, elwt| {
        println!("{event:?}");
    })

@madsmtm
Copy link
Member

madsmtm commented Mar 1, 2024

Try moving the window creation inside Event::NewEvents(StartCause::Init), like so:

fn main() {
    let event_loop = EventLoop::new().unwrap();

    let mut window = None;
    event_loop.run(move |event, elwt| {
        println!("{event:?}");
        match event {
            Event::StartCause(NewEvents::Init) => {
                window = Some({
                    let window = WindowBuilder::new()
                            .with_title("A fantastic window!")
                            .with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
                            .with_decorations(true)
                            .with_fullsize_content_view(true)
                            .with_titlebar_transparent(true)
                            .build(&event_loop)
                            .unwrap();
                    window.set_decorations(false);
                    window.set_minimized(true);
                    window
                });
            }
            _ => {}
        }
    })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants