slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.56k stars 604 forks source link

set_fullscreen(false) is invalid #5424

Open whq-003 opened 4 months ago

whq-003 commented 4 months ago

I can use set_fullscreen(true) to set the window in full mode, but can't use set_fullscreen(false) return the normal mode. My system is Windows 11, and the language is Rust.

main.rs:

#![windows_subsystem = "windows"]

slint::include_modules!();

pub fn main() {
    let app = App::new().unwrap();

    let mut prev_is_fullscreen = false;

    {
        let app_weak = app.as_weak();
        app.on_fullscreen(move || {
            let main_window = app_weak.unwrap();
            prev_is_fullscreen = !prev_is_fullscreen;
            main_window.window().set_fullscreen(prev_is_fullscreen);
        });
    }

    let _ = app.run();
}

scene.slint:

import { Button, HorizontalBox, VerticalBox} from "std-widgets.slint";

export component App inherits Window {
    preferred-width: 800px;
    preferred-height: 600px;
    title: "Simple Player";
    icon: @image-url("../assets/logo.png");
    callback fullscreen();
    HorizontalLayout {
        Rectangle {
            background: #ffffff00;
            Button {
                width: 40px;
                icon: @image-url("../assets/full.png");
                clicked => {
                    root.fullscreen()
                }
            }
        }
    }
}
ogoffart commented 4 months ago

Thanks for filing an issue.

(I couldn't reproduce on X11, so I assume it is windows specific)

whq-003 commented 3 months ago

Thanks for filing an issue.

(I couldn't reproduce on X11, so I assume it is windows specific)

I reproduced it on MacOs 10.15.7...