Fixed the multiple window closing issue, where the two multiwindow examples weren't working. (#3499)
* fixed window when multiple windows not closing * fixed window when multiple windows not closing * fixed accidental includes * polished * fix last window closing hiding app and rc hardcount * find the suspect strong count holders and fix them * Use the proper type alias * fmt --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
36522cf3ea
commit
25a64d97c0
6 files changed
+45
-19
No files matched your search
@@ -20,7 +20,7 @@ use tao::{
|
||||
dpi::PhysicalSize,
|
||||
event::Event,
|
||||
event_loop::{ControlFlow, EventLoop, EventLoopBuilder, EventLoopProxy, EventLoopWindowTarget},
|
||||
window::WindowId,
|
||||
window::{Window, WindowId},
|
||||
};
|
||||
|
||||
/// The single top-level object that manages all the running windows, assets, shortcuts, etc
|
||||
@@ -198,11 +198,14 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
LastWindowHides if self.webviews.len() > 1 => {
|
||||
self.webviews.remove(&id);
|
||||
}
|
||||
|
||||
LastWindowHides => {
|
||||
let Some(webview) = self.webviews.get(&id) else {
|
||||
return;
|
||||
};
|
||||
hide_app_window(&webview.desktop_context.webview);
|
||||
if let Some(webview) = self.webviews.get(&id) {
|
||||
hide_last_window(&webview.desktop_context.window);
|
||||
}
|
||||
}
|
||||
|
||||
CloseWindow => {
|
||||
@@ -529,9 +532,13 @@ struct PreservedWindowState {
|
||||
monitor: String,
|
||||
}
|
||||
|
||||
/// Different hide implementations per platform
|
||||
/// Hide the last window when using LastWindowHides.
|
||||
///
|
||||
/// On macOS, if we use `set_visibility(false)` on the window, it will hide the window but not show
|
||||
/// it again when the user switches back to the app. `NSApplication::hide:` has the correct behaviour,
|
||||
/// so we need to special case it.
|
||||
#[allow(unused)]
|
||||
pub fn hide_app_window(window: &wry::WebView) {
|
||||
fn hide_last_window(window: &Window) {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
use tao::platform::windows::WindowExtWindows;
|
||||
|
||||
Reference in new issue
Block a user