#Creating a new window with rust

2 messages · Page 1 of 1 (latest)

hollow gulch
#

Why is it that everything works fine inside MacOS with the code below, but after creating a window on a Windows system, the computer starts to lag and the new window doesn't open! I hope you can help me to solve this problem! Thanks! 😁

#[command]
pub fn create_window(app_handle: AppHandle, label: String, mut options: WindowConfig) {
    let window = app_handle.get_window(&label);

    if window.is_some() {
        return show_window(window.clone().unwrap());
    }

    options.label = label.clone();

    Some(
        WindowBuilder::from_config(&app_handle, options.clone())
            .build()
            .expect("failed to create window"),
    )
    .unwrap();
}

#[command]
pub fn show_window(window: Window) {
    window.show().unwrap();
    window.unminimize().unwrap();
    window.set_focus().unwrap();
}
sterile haven