Fix merge errors

This commit is contained in:
Jonathan Kelley committed 2023-06-30 12:48:25 -07:00
1 parent dfb05540c3
commit 6512c153dd
4 files changed
+17 -17

No files matched your search

+1 -1
View File
@@ -1,5 +1,4 @@
use dioxus::prelude::*; use dioxus::prelude::*;
use dioxus_desktop::tao::keyboard::ModifiersState;
use dioxus_desktop::use_global_shortcut; use dioxus_desktop::use_global_shortcut;
fn main() { fn main() {
@@ -8,6 +7,7 @@ fn main() {
fn app(cx: Scope) -> Element { fn app(cx: Scope) -> Element {
let toggled = use_state(cx, || false); let toggled = use_state(cx, || false);
use_global_shortcut(cx, "ctrl+s", { use_global_shortcut(cx, "ctrl+s", {
to_owned![toggled]; to_owned![toggled];
move || toggled.modify(|t| !*t) move || toggled.modify(|t| !*t)
+1
View File
@@ -72,6 +72,7 @@ pub struct DesktopService {
pub(crate) views: Rc<RefCell<Vec<*mut objc::runtime::Object>>>, pub(crate) views: Rc<RefCell<Vec<*mut objc::runtime::Object>>>,
} }
/// A handle to the [`DesktopService`] that can be passed around.
pub type DesktopContext = Rc<DesktopService>; pub type DesktopContext = Rc<DesktopService>;
/// A smart pointer to the current window. /// A smart pointer to the current window.
+6 -9
View File
@@ -1,20 +1,17 @@
use std::rc::Rc;
use dioxus_core::ElementId; use dioxus_core::ElementId;
use dioxus_html::{geometry::euclid::Rect, MountedResult, RenderedElementBacking}; use dioxus_html::{geometry::euclid::Rect, MountedResult, RenderedElementBacking};
use wry::webview::WebView;
use crate::query::QueryEngine; use crate::{desktop_context::DesktopContext, query::QueryEngine};
/// A mounted element passed to onmounted events /// A mounted element passed to onmounted events
pub struct DesktopElement { pub struct DesktopElement {
id: ElementId, id: ElementId,
webview: Rc<WebView>, webview: DesktopContext,
query: QueryEngine, query: QueryEngine,
} }
impl DesktopElement { impl DesktopElement {
pub(crate) fn new(id: ElementId, webview: Rc<WebView>, query: QueryEngine) -> Self { pub(crate) fn new(id: ElementId, webview: DesktopContext, query: QueryEngine) -> Self {
Self { id, webview, query } Self { id, webview, query }
} }
} }
@@ -37,7 +34,7 @@ impl RenderedElementBacking for DesktopElement {
let fut = self let fut = self
.query .query
.new_query::<Option<Rect<f64, f64>>>(&script, &self.webview) .new_query::<Option<Rect<f64, f64>>>(&script, &self.webview.webview)
.resolve(); .resolve();
Box::pin(async move { Box::pin(async move {
match fut.await { match fut.await {
@@ -64,7 +61,7 @@ impl RenderedElementBacking for DesktopElement {
let fut = self let fut = self
.query .query
.new_query::<bool>(&script, &self.webview) .new_query::<bool>(&script, &self.webview.webview)
.resolve(); .resolve();
Box::pin(async move { Box::pin(async move {
match fut.await { match fut.await {
@@ -90,7 +87,7 @@ impl RenderedElementBacking for DesktopElement {
let fut = self let fut = self
.query .query
.new_query::<bool>(&script, &self.webview) .new_query::<bool>(&script, &self.webview.webview)
.resolve(); .resolve();
Box::pin(async move { Box::pin(async move {
+9 -7
View File
@@ -18,12 +18,11 @@ mod webview;
use crate::query::QueryResult; use crate::query::QueryResult;
pub use cfg::Config; pub use cfg::Config;
pub use desktop_context::DesktopContext;
pub use desktop_context::{ pub use desktop_context::{
use_window, use_wry_event_handler, DesktopService, WryEventHandler, WryEventHandlerId, use_window, use_wry_event_handler, DesktopService, WryEventHandler, WryEventHandlerId,
}; };
use desktop_context::{ use desktop_context::{EventData, UserWindowEvent, WebviewQueue, WindowEventHandlers};
DesktopContext, EventData, UserWindowEvent, WebviewQueue, WindowEventHandlers,
};
use dioxus_core::*; use dioxus_core::*;
use dioxus_html::MountedData; use dioxus_html::MountedData;
use dioxus_html::{native_bind::NativeFileEngine, FormData, HtmlEvent}; use dioxus_html::{native_bind::NativeFileEngine, FormData, HtmlEvent};
@@ -253,9 +252,11 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
.base_scope() .base_scope()
.consume_context::<DesktopContext>() .consume_context::<DesktopContext>()
.unwrap() .unwrap()
.query; .query
.clone();
let element = DesktopElement::new(element, view.webview.clone(), query); let element =
DesktopElement::new(element, view.desktop_context.clone(), query);
Rc::new(MountedData::new(element)) Rc::new(MountedData::new(element))
} else { } else {
@@ -278,7 +279,8 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
.base_scope() .base_scope()
.consume_context::<DesktopContext>() .consume_context::<DesktopContext>()
.unwrap() .unwrap()
.query; .query
.clone();
query.send(result); query.send(result);
} }
@@ -324,7 +326,7 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
view.dom.handle_event(event_name, data, id, event_bubbles); view.dom.handle_event(event_name, data, id, event_bubbles);
} }
send_edits(view.dom.render_immediate(), &view.webview); send_edits(view.dom.render_immediate(), &view.desktop_context.webview);
} }
} }