Repository: tauri
Issue: [bug] document.visibilityState broken
Labels: type: bug,platform: Windows

### Describe the bug

I cannot seem to get the browser `visibilitychange` event to fire by any means, and whether maximized or minimized, `document.visibilityState` always has the value `"visible"`. This is on Windows 10.

There is some prior history for this issue. #6864 describes the lack of `visibilitychange` event when hiding the window behind another window, but describes the event as firing when the window is minimized and maximized. The more recent #9524 again confirms that it fires when minimized or maximized. (The author of that issue believed it should also fire when a window gains or loses focus, but that just seems to originate in confusion about [what page visibility represents](https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState).) #9246 appears to change webview visibility on minimize/maximize, and then #9465 reverts it.

This seems to trace back to [this WebView2 issue](https://github.com/MicrosoftEdge/WebView2Feedback/issues/2681). As described in [this comment](https://github.com/MicrosoftEdge/WebView2Feedback/issues/2681#issuecomment-1586686876), the issue—at least at the time—was because "Minimizing a window in WPF does not inherently change the Visibility property of its child controls." If this is the case, though, then I'm not sure how the first two issues above ever recorded `visibilitychange` events on minimize and maximize.

It seems that window occlusion has never caused the document visibility state to change in Tauri, but there has been a regression causing it to no longer update upon minimize/maximize either. `document.visibilityState` simply never appears to change anymore, and always reports itself visible.

### Reproduction

Nothing in particular is needed to reproduce this; just `cargo create-tauri-app` to create a template program and run it. You can examine the document visibility state in the web inspector.

### Expected behavior

The `visibilitychange` event should fire when `document.visibilityState` changes. This should occur whenever the document is either revealed or hidden to the user: when switching between minimized and maximized, when showing or hiding the parent tab, or when the edges of the screen and foreground windows occlude or un-occlude the document.

### Full `tauri info` output

```text
[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 127.0.2651.98
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.80.0 (051478957 2024-07-21)
    ✔ cargo: 1.80.0 (376290515 2024-07-16)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (environment override by RUSTUP_TOOLCHAIN)
    - node: 18.12.1
    - npm: 8.19.2

[-] Packages
    - tauri [RUST]: 2.0.0-rc.2
    - tauri-build [RUST]: 2.0.0-rc.2
    - wry [RUST]: 0.41.0
    - tao [RUST]: 0.28.1
    - tauri-cli [RUST]: 2.0.0-rc.3
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli [NPM]: 2.0.0-rc.3

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../src
```


### Stack trace

_No response_

### Additional context

_No response_