add with_on_window_ready to allow modifying window before webview (#4919)

* wip

* cleanups
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2025-11-05 17:00:58 -03:00
1 parent 06c5a4499f
commit 6a50f1ba84
6 files changed
+63 -40

No files matched your search

+19 -3
View File
@@ -1,8 +1,11 @@
use dioxus_core::LaunchConfig;
use std::borrow::Cow;
use dioxus_core::{LaunchConfig, VirtualDom};
use std::path::PathBuf;
use tao::event_loop::{EventLoop, EventLoopWindowTarget};
use std::{borrow::Cow, sync::Arc};
use tao::window::{Icon, WindowBuilder};
use tao::{
event_loop::{EventLoop, EventLoopWindowTarget},
window::Window,
};
use wry::http::{Request as HttpRequest, Response as HttpResponse};
use wry::{RequestAsyncResponder, WebViewId};
@@ -64,6 +67,9 @@ pub struct Config {
pub(crate) window_close_behavior: WindowCloseBehaviour,
pub(crate) custom_event_handler: Option<CustomEventHandler>,
pub(crate) disable_file_drop_handler: bool,
#[allow(clippy::type_complexity)]
pub(crate) on_window: Option<Box<dyn FnMut(Arc<Window>, &mut VirtualDom) + 'static>>,
}
impl LaunchConfig for Config {}
@@ -111,6 +117,7 @@ impl Config {
window_close_behavior: WindowCloseBehaviour::WindowCloses,
custom_event_handler: None,
disable_file_drop_handler: false,
on_window: None,
}
}
@@ -296,6 +303,15 @@ impl Config {
}
self
}
/// Allows modifying the window and virtual dom right after they are built, but before the webview is created.
///
/// This is important for z-ordering textures in child windows. Note that this callback runs on
/// every window creation, so it's up to you to
pub fn with_on_window(mut self, f: impl FnMut(Arc<Window>, &mut VirtualDom) + 'static) -> Self {
self.on_window = Some(Box::new(f));
self
}
}
impl Default for Config {