From 14e3cf17cd590356d8b602c9c306dc6d3f60e63b Mon Sep 17 00:00:00 2001 From: rhysd Date: Fri, 29 Sep 2023 23:41:08 +0900 Subject: [PATCH 1/6] chore(doc): Add documentation for `WebView::inner_size` --- src/webview/mod.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/webview/mod.rs b/src/webview/mod.rs index cab04b443..c4ab40f15 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -1034,6 +1034,27 @@ impl WebView { self.webview.is_devtools_open() } + /// Gets the physical size of the webview’s client area. + /// + /// [`Window::inner_size`] does not work on some platforms. This method can be a replacement of the method. + /// + /// ```no_run + /// use wry::{ + /// application::{ + /// event_loop::EventLoop, + /// window::WindowBuilder + /// }, + /// webview::WebViewBuilder, + /// }; + /// let event_loop = EventLoop::new(); + /// let window = WindowBuilder::new().build(&event_loop).unwrap(); + /// let webview = WebViewBuilder::new(window).unwrap() + /// + /// // This may return the incorrect window size. + /// println!("{:?}", webview.window().inner_size()); + /// // Instead, this always returns the correct window size. + /// println!("{:?}", webview.inner_size()); + /// ``` pub fn inner_size(&self) -> PhysicalSize { #[cfg(target_os = "macos")] { From 8507866d229bf826ed3ce8635d9f2bdff2e29eea Mon Sep 17 00:00:00 2001 From: rhysd Date: Fri, 29 Sep 2023 23:42:33 +0900 Subject: [PATCH 2/6] fix(doc): Fix indent in code example of `WebViewBuilder::with_asynchronous_custom_protocol` document --- src/webview/mod.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/webview/mod.rs b/src/webview/mod.rs index c4ab40f15..0dcdc6f63 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -513,17 +513,17 @@ impl<'a> WebViewBuilder<'a> { /// let window = WindowBuilder::new() /// .build(&event_loop) /// .unwrap(); - /// WebViewBuilder::new(window) - /// .unwrap() - /// .with_asynchronous_custom_protocol("wry".into(), |request, responder| { - /// // here you can use a tokio task, thread pool or anything - /// // to do heavy computation to resolve your request - /// // e.g. downloading files, opening the camera... - /// std::thread::spawn(move || { - /// std::thread::sleep(std::time::Duration::from_secs(2)); - /// responder.respond(http::Response::builder().body(Vec::new()).unwrap()); - /// }); + /// WebViewBuilder::new(window) + /// .unwrap() + /// .with_asynchronous_custom_protocol("wry".into(), |request, responder| { + /// // here you can use a tokio task, thread pool or anything + /// // to do heavy computation to resolve your request + /// // e.g. downloading files, opening the camera... + /// std::thread::spawn(move || { + /// std::thread::sleep(std::time::Duration::from_secs(2)); + /// responder.respond(http::Response::builder().body(Vec::new()).unwrap()); /// }); + /// }); /// ``` #[cfg(feature = "protocol")] pub fn with_asynchronous_custom_protocol(mut self, name: String, handler: F) -> Self From 8e96c669483d13fcd2f21217e5c9854958010f39 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Fri, 29 Sep 2023 18:58:52 +0300 Subject: [PATCH 3/6] Update src/webview/mod.rs --- src/webview/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/webview/mod.rs b/src/webview/mod.rs index 0dcdc6f63..0263f7f43 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -1034,9 +1034,9 @@ impl WebView { self.webview.is_devtools_open() } - /// Gets the physical size of the webview’s client area. - /// - /// [`Window::inner_size`] does not work on some platforms. This method can be a replacement of the method. + /// Gets the physical size of the webview’s client area. This is + /// a drop-in replacement for [`Window::inner_size`] because on some platforms + /// (currently, only macOS), it will return an incorrect size. /// /// ```no_run /// use wry::{ @@ -1050,7 +1050,7 @@ impl WebView { /// let window = WindowBuilder::new().build(&event_loop).unwrap(); /// let webview = WebViewBuilder::new(window).unwrap() /// - /// // This may return the incorrect window size. + /// // This returns incorrect window size on macOS. /// println!("{:?}", webview.window().inner_size()); /// // Instead, this always returns the correct window size. /// println!("{:?}", webview.inner_size()); From 9368c82fb169cdceedf8d1a808b42db9ac17db68 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Fri, 29 Sep 2023 19:00:36 +0300 Subject: [PATCH 4/6] Update mod.rs --- src/webview/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webview/mod.rs b/src/webview/mod.rs index 0263f7f43..fede6b6c2 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -1034,7 +1034,7 @@ impl WebView { self.webview.is_devtools_open() } - /// Gets the physical size of the webview’s client area. This is + /// Gets the physical size of the webview’s client area. This is /// a drop-in replacement for [`Window::inner_size`] because on some platforms /// (currently, only macOS), it will return an incorrect size. /// From d438ac0be762561f3ecf0e544f5c1361a9d2f757 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Fri, 29 Sep 2023 19:04:51 +0300 Subject: [PATCH 5/6] Update src/webview/mod.rs --- src/webview/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webview/mod.rs b/src/webview/mod.rs index fede6b6c2..a7d45bd1e 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -1048,7 +1048,7 @@ impl WebView { /// }; /// let event_loop = EventLoop::new(); /// let window = WindowBuilder::new().build(&event_loop).unwrap(); - /// let webview = WebViewBuilder::new(window).unwrap() + /// let webview = WebViewBuilder::new(window).unwrap(); /// /// // This returns incorrect window size on macOS. /// println!("{:?}", webview.window().inner_size()); From 9c7a9f429b53baad3baa8b8c604189270931fced Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Fri, 29 Sep 2023 19:47:31 +0300 Subject: [PATCH 6/6] Update src/webview/mod.rs --- src/webview/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/webview/mod.rs b/src/webview/mod.rs index a7d45bd1e..ab0bac48b 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -1048,7 +1048,10 @@ impl WebView { /// }; /// let event_loop = EventLoop::new(); /// let window = WindowBuilder::new().build(&event_loop).unwrap(); - /// let webview = WebViewBuilder::new(window).unwrap(); + /// let webview = WebViewBuilder::new(window) + /// .unwrap() + /// .build() + /// .unwrap(); /// /// // This returns incorrect window size on macOS. /// println!("{:?}", webview.window().inner_size());