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

[bug] Tauri v2 MacOS: Window Snapping Issue tauri.conf.json vs Custom Rust Windows #10225

Closed
tance77 opened this issue Jul 8, 2024 · 3 comments · Fixed by #10297
Closed

[bug] Tauri v2 MacOS: Window Snapping Issue tauri.conf.json vs Custom Rust Windows #10225

tance77 opened this issue Jul 8, 2024 · 3 comments · Fixed by #10297
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@tance77
Copy link

tance77 commented Jul 8, 2024

Describe the bug

When creating your window in Tauri with the following code :

fn open_main_window(handle: &App) -> WebviewWindow {
        let main_window = WebviewWindowBuilder::new(handle, "main", WebviewUrl::App("index.html".into()))
            .title("test")
            .resizable(true)
            .fullscreen(false)
            .min_inner_size(650.00, 500.00)
            .decorations(true)
            .inner_size(1280.00, 800.00)
            .build()
            .expect("Error building main window.");

        main_window.open_devtools();
        return main_window;
}

When the app starts and the window appears, resizing the window to be taller than it is wide and snapping it to a section of the screen with the developer console taking up most of the height will cause the Webview to move off-screen. The issue persists until the app is terminated in the terminal.

However, this does not happen when the window is created in the tauri.conf.js file.

Minimal reproduction repository

https://github.com/tance77/tauri-v2-mac-os-snap-bug

I also think this issue is related as well

#6927

Demo Video

Screen.Recording.2024-07-08.at.4.13.44.PM.mov

Full tauri info output

- OS: Mac OS 14.5.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.79.0 (129f3b996 2024-06-10)
    ✔ cargo: 1.79.0 (ffa9cf99a 2024-06-03)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.10.0
    - pnpm: 8.10.2
    - npm: 10.2.3
    - bun: 1.0.11

[-] Packages
    - tauri [RUST]: 2.0.0-beta.14
    - tauri-build [RUST]: 2.0.0-beta.11
    - wry [RUST]: 0.39.0
    - tao [RUST]: 0.27.0
    - tauri-cli [RUST]: 1.2.3
    - @tauri-apps/api [NPM]: 2.0.0-beta.7
    - @tauri-apps/cli [NPM]: 2.0.0-beta.12

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite
@tance77 tance77 added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jul 8, 2024
@tance77 tance77 changed the title [bug] Tauri v2 MacOS Snap to Screen Section / Magnet Bug tauri.conf.json vs creating your own window in rust [bug] Tauri v2 MacOS: Window Snapping Discrepancies (Configuration vs Custom Rust Windows) Jul 9, 2024
@tance77 tance77 changed the title [bug] Tauri v2 MacOS: Window Snapping Discrepancies (Configuration vs Custom Rust Windows) [bug] Tauri v2 MacOS: Window Snapping Issue (Configuration vs Custom Rust Windows) Jul 9, 2024
@tance77 tance77 changed the title [bug] Tauri v2 MacOS: Window Snapping Issue (Configuration vs Custom Rust Windows) [bug] Tauri v2 MacOS: Window Snapping Issue tauri.conf.json vs Custom Rust Windows Jul 9, 2024
@pewsheen
Copy link
Contributor

pewsheen commented Jul 15, 2024

Hi! I am able to fix the issue by setting window_builder.title_bar_style(tauri::TitleBarStyle::Visible).build(). Could you try this one with your WebviewWindowBuilder?

If this works, maybe we should set the value by default.

@tance77
Copy link
Author

tance77 commented Jul 15, 2024

@pewsheen Yeah, that does seem to fix it. Why does that fix it? What does setting the title bar style to be visible do?

@pewsheen
Copy link
Contributor

I don't actually know what happened 👀 . I found that's the difference when creating the window by config. It sometimes depends on how the OS manages the underlying logic, and it's usually a black box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants