fix(core): revert fix visibility change (#9246) (#9465)

* Revert "fix(windows): changing WebView visibility on hide/show/minimize (#9246)"

This reverts commit 5bd47b4467.

* Change files

* change file

* Update revert-fix-visibility-change.md
This commit is contained in:
Tony 2024-04-15 17:50:11 +08:00 committed by GitHub
parent f1674fce6d
commit f22ea29986
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 26 deletions

View File

@ -0,0 +1,5 @@
---
"tauri-runtime-wry": patch:bug
---
Revert the [fix](https://github.com/tauri-apps/tauri/pull/9246) for webview's visibility doesn't change with the app window on Windows as it caused white flashes on show/restore.

View File

@ -2699,16 +2699,8 @@ fn handle_user_message<T: UserEvent>(
WindowMessage::Unmaximize => window.set_maximized(false),
WindowMessage::Minimize => window.set_minimized(true),
WindowMessage::Unminimize => window.set_minimized(false),
WindowMessage::Show => {
window.set_visible(true);
#[cfg(windows)]
let _ = set_webview_visibility(&webviews, !window.is_minimized());
}
WindowMessage::Hide => {
window.set_visible(false);
#[cfg(windows)]
let _ = set_webview_visibility(&webviews, false);
}
WindowMessage::Show => window.set_visible(true),
WindowMessage::Hide => window.set_visible(false),
WindowMessage::Close => {
panic!("cannot handle `WindowMessage::Close` on the main thread")
}
@ -3369,7 +3361,7 @@ fn handle_event_loop<T: UserEvent>(
.map(|w| (w.inner.clone(), w.webviews.clone()))
{
let size = size.to_logical::<f32>(window.scale_factor());
for webview in &webviews {
for webview in webviews {
if let Some(b) = &*webview.bounds.lock().unwrap() {
if let Err(e) = webview.set_bounds(wry::Rect {
position: LogicalPosition::new(size.width * b.x_rate, size.height * b.y_rate)
@ -3381,9 +3373,6 @@ fn handle_event_loop<T: UserEvent>(
}
}
}
#[cfg(windows)]
let _ =
set_webview_visibility(&webviews, window.is_visible() && !window.is_minimized());
}
}
_ => {}
@ -4156,15 +4145,3 @@ fn clear_window_surface(
let _ = buffer.present();
}
}
#[cfg(windows)]
fn set_webview_visibility(
webviews: &[WebviewWrapper],
is_visible: bool,
) -> windows::core::Result<()> {
for webview in webviews {
let controller = webview.controller();
unsafe { controller.SetIsVisible(is_visible) }?;
}
Ok(())
}