diff --git a/packages/desktop/src/ipc.rs b/packages/desktop/src/ipc.rs index fcf5a0e4e..e78114f68 100644 --- a/packages/desktop/src/ipc.rs +++ b/packages/desktop/src/ipc.rs @@ -18,12 +18,7 @@ pub enum UserWindowEvent { Ipc { id: WindowId, msg: IpcMessage }, /// Handle a hotreload event, basically telling us to update our templates - #[cfg(all( - feature = "devtools", - debug_assertions, - not(target_os = "android"), - not(target_os = "ios") - ))] + #[cfg(all(feature = "devtools", debug_assertions))] HotReloadEvent(dioxus_devtools::DevserverMsg), /// Create a new window diff --git a/packages/desktop/src/webview.rs b/packages/desktop/src/webview.rs index 6bc05c901..d09cae6ce 100644 --- a/packages/desktop/src/webview.rs +++ b/packages/desktop/src/webview.rs @@ -1,17 +1,17 @@ +use crate::document::DesktopDocument; use crate::element::DesktopElement; use crate::file_upload::DesktopFileDragEvent; use crate::menubar::DioxusMenu; 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, DesktopContext, DesktopService, }; use dioxus_core::{Runtime, ScopeId, VirtualDom}; 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 std::cell::OnceCell; use std::sync::Arc; @@ -90,7 +90,7 @@ impl WebviewEdits { // check for a mounted event placeholder and replace it with a desktop specific element let as_any = match data { 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))) } dioxus_html::EventData::Drag(ref drag) => { @@ -147,9 +147,15 @@ impl WebviewInstance { ) -> WebviewInstance { 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 @@ -391,3 +397,18 @@ impl WebviewInstance { .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 } + } +} diff --git a/packages/interpreter/src/write_native_mutations.rs b/packages/interpreter/src/write_native_mutations.rs index 93d072724..afb5d33e0 100644 --- a/packages/interpreter/src/write_native_mutations.rs +++ b/packages/interpreter/src/write_native_mutations.rs @@ -192,23 +192,3 @@ impl WriteMutations for MutationState { self.channel.push_root(id.0 as _); } } - -/// A synchronous response to a browser event which may prevent the default browser's action -#[cfg_attr(feature = "serialize", derive(serde::Serialize))] -#[derive(Default)] -pub struct SynchronousEventResponse { - #[cfg(feature = "serialize")] - #[serde(rename = "preventDefault")] - prevent_default: bool, -} - -impl SynchronousEventResponse { - /// Create a new SynchronousEventResponse - #[allow(unused)] - pub fn new(prevent_default: bool) -> Self { - Self { - #[cfg(feature = "serialize")] - prevent_default, - } - } -}