|
@@ -1,17 +1,17 @@
|
|
|
|
+use crate::document::DesktopDocument;
|
|
use crate::element::DesktopElement;
|
|
use crate::element::DesktopElement;
|
|
use crate::file_upload::DesktopFileDragEvent;
|
|
use crate::file_upload::DesktopFileDragEvent;
|
|
use crate::menubar::DioxusMenu;
|
|
use crate::menubar::DioxusMenu;
|
|
use crate::{
|
|
use crate::{
|
|
- app::SharedContext, assets::AssetHandlerRegistry, document::DesktopDocument, edits::WryQueue,
|
|
|
|
|
|
+ app::SharedContext, assets::AssetHandlerRegistry, edits::WryQueue,
|
|
file_upload::NativeFileHover, ipc::UserWindowEvent, protocol, waker::tao_waker, Config,
|
|
file_upload::NativeFileHover, ipc::UserWindowEvent, protocol, waker::tao_waker, Config,
|
|
DesktopContext, DesktopService,
|
|
DesktopContext, DesktopService,
|
|
};
|
|
};
|
|
use dioxus_core::{Runtime, ScopeId, VirtualDom};
|
|
use dioxus_core::{Runtime, ScopeId, VirtualDom};
|
|
use dioxus_hooks::to_owned;
|
|
use dioxus_hooks::to_owned;
|
|
-use dioxus_html::document::Document;
|
|
|
|
-use dioxus_html::native_bind::NativeFileEngine;
|
|
|
|
-use dioxus_html::{HasFileData, HtmlEvent, PlatformEventData};
|
|
|
|
-use dioxus_interpreter_js::SynchronousEventResponse;
|
|
|
|
|
|
+use dioxus_html::{
|
|
|
|
+ native_bind::NativeFileEngine, prelude::Document, HasFileData, HtmlEvent, PlatformEventData,
|
|
|
|
+};
|
|
use futures_util::{pin_mut, FutureExt};
|
|
use futures_util::{pin_mut, FutureExt};
|
|
use std::cell::OnceCell;
|
|
use std::cell::OnceCell;
|
|
use std::sync::Arc;
|
|
use std::sync::Arc;
|
|
@@ -90,7 +90,7 @@ impl WebviewEdits {
|
|
// check for a mounted event placeholder and replace it with a desktop specific element
|
|
// check for a mounted event placeholder and replace it with a desktop specific element
|
|
let as_any = match data {
|
|
let as_any = match data {
|
|
dioxus_html::EventData::Mounted => {
|
|
dioxus_html::EventData::Mounted => {
|
|
- let element = DesktopElement::new(element, desktop_context.clone(), query);
|
|
|
|
|
|
+ let element = DesktopElement::new(element, desktop_context.clone(), query.clone());
|
|
Rc::new(PlatformEventData::new(Box::new(element)))
|
|
Rc::new(PlatformEventData::new(Box::new(element)))
|
|
}
|
|
}
|
|
dioxus_html::EventData::Drag(ref drag) => {
|
|
dioxus_html::EventData::Drag(ref drag) => {
|
|
@@ -147,9 +147,15 @@ impl WebviewInstance {
|
|
) -> WebviewInstance {
|
|
) -> WebviewInstance {
|
|
let mut window = cfg.window.clone();
|
|
let mut window = cfg.window.clone();
|
|
|
|
|
|
- // tao makes small windows for some reason, make them bigger
|
|
|
|
- if cfg.window.window.inner_size.is_none() {
|
|
|
|
- window = window.with_inner_size(tao::dpi::LogicalSize::new(800.0, 600.0));
|
|
|
|
|
|
+ // tao makes small windows for some reason, make them bigger on desktop
|
|
|
|
+ //
|
|
|
|
+ // on mobile, we want them to be `None` so tao makes them the size of the screen. Otherwise we
|
|
|
|
+ // get a window that is not the size of the screen and weird black bars.
|
|
|
|
+ #[cfg(not(any(target_os = "ios", target_os = "android")))]
|
|
|
|
+ {
|
|
|
|
+ if cfg.window.window.inner_size.is_none() {
|
|
|
|
+ window = window.with_inner_size(tao::dpi::LogicalSize::new(800.0, 600.0));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// We assume that if the icon is None in cfg, then the user just didnt set it
|
|
// We assume that if the icon is None in cfg, then the user just didnt set it
|
|
@@ -391,3 +397,18 @@ impl WebviewInstance {
|
|
.evaluate_script("window.interpreter.kickAllStylesheetsOnPage()");
|
|
.evaluate_script("window.interpreter.kickAllStylesheetsOnPage()");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/// A synchronous response to a browser event which may prevent the default browser's action
|
|
|
|
+#[derive(serde::Serialize, Default)]
|
|
|
|
+pub struct SynchronousEventResponse {
|
|
|
|
+ #[serde(rename = "preventDefault")]
|
|
|
|
+ prevent_default: bool,
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+impl SynchronousEventResponse {
|
|
|
|
+ /// Create a new SynchronousEventResponse
|
|
|
|
+ #[allow(unused)]
|
|
|
|
+ pub fn new(prevent_default: bool) -> Self {
|
|
|
|
+ Self { prevent_default }
|
|
|
|
+ }
|
|
|
|
+}
|