Skip to content

Commit

Permalink
fix(core): revert fix visibility change (#9246) (#9465)
Browse files Browse the repository at this point in the history
* Revert "fix(windows): changing WebView visibility on hide/show/minimize (#9246)"

This reverts commit 5bd47b4.

* Change files

* change file

* Update revert-fix-visibility-change.md
  • Loading branch information
Legend-Master committed Apr 15, 2024
1 parent f1674fc commit f22ea29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .changes/revert-fix-visibility-change.md
@@ -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.
29 changes: 3 additions & 26 deletions core/tauri-runtime-wry/src/lib.rs
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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)
Expand All @@ -3381,9 +3373,6 @@ fn handle_event_loop<T: UserEvent>(
}
}
}
#[cfg(windows)]
let _ =
set_webview_visibility(&webviews, window.is_visible() && !window.is_minimized());
}
}
_ => {}
Expand Down Expand Up @@ -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(())
}

0 comments on commit f22ea29

Please sign in to comment.