tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.4k stars 2.58k forks source link

[bug] WebviewWindowBuilder fullscreen() and size() don't work. #11307

Open Barafu opened 1 month ago

Barafu commented 1 month ago

Describe the bug

I tries to cover all monitors with fullscreen windows to display graphs on them. I have multiple monitors with different resolutions, framerates and scale factors. However, the approach from examples works only for the primary monitor. The windows on secondary monitors stay small, borderless and in random positions.

However, setting windows to fullscreen after the window was built works.

P.S. While we are here, please #[derive(PatialEq)] on tauri::window::Monitor.

Reproduction

This does not work: windows on secondary monitors remain small.
Uncomment the commented line to make it work.

tauri::Builder::default()
            .setup(move |app| {
                // Build the primary window
                let primary_window = tauri::WebviewWindowBuilder::new(
                    app,
                    "primary",
                    tauri::WebviewUrl::App("index.html".into()),
                )
                .fullscreen(true)
                .build()?;

                if need_multiscreen {
                    let monitors = primary_window.available_monitors()?;
                    let primary_monitor = primary_window.current_monitor()?.unwrap();
                    for (i, monitor) in monitors.iter().enumerate() {
                        if !compare_monitors(&primary_monitor, monitor) {
                            dbg!(&monitor);
                            let label = format!("extra{}", i);
                            let pos = calculate_window_position(monitor);
                            let secondary_window =
                                tauri::WebviewWindowBuilder::new(
                                    app,
                                    label,
                                    tauri::WebviewUrl::App("index.html".into()),
                                )
                                .position(pos.0, pos.1)
                                .fullscreen(true)
                                .build()?;
                            // Uncomment here
                            // let secondary_window =
                            //    tauri::WebviewWindowBuilder::new(
                            //       app,
                            //        label,
                            //        tauri::WebviewUrl::App("index.html".into()),
                            //   )
                            //    .position(pos.0, pos.1)
                            //    .build()?;
                            // secondary_window.set_fullscreen(true);
                        }
                    }
                }
                std::result::Result::Ok(())
            })
            .run(tauri::generate_context!())
            .expect("error while running app");
        Ok(())

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22631 x86_64 (X64)
    ✔ WebView2: 129.0.2792.79
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.81.0 (eeb90cda1 2024-09-04)
    ✔ cargo: 1.81.0 (2dbb1af80 2024-08-20)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 22.9.0
    - npm: 10.8.3

[-] Packages
    - tauri 🦀: 2.0.2
    - tauri-build 🦀: 2.0.1
    - wry 🦀: 0.44.1
    - tao 🦀: 0.30.3
    - tauri-cli 🦀: 2.0.2

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../src

Stack trace

No response

Additional context

No response

amrbashir commented 1 week ago

can you retest with latest 2.1.0 release and see if the issue still exists?