From e00b6d423ef47d3021925fe0a3fc3b539f1edd65 Mon Sep 17 00:00:00 2001 From: rhysd Date: Thu, 9 Nov 2023 23:20:04 +0900 Subject: [PATCH 1/2] feat: make `HasRawWindowHandle` trait public Signed-off-by: rhysd --- .changes/rwh.md | 3 ++- README.md | 2 +- src/lib.rs | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.changes/rwh.md b/.changes/rwh.md index b234e348b..fdb9af772 100644 --- a/.changes/rwh.md +++ b/.changes/rwh.md @@ -10,8 +10,9 @@ Refactor new method to take raw window handle instead. Following are APIs got af - Position field in `FileDrop` event is now `Position` instead of `PhysicalPosition`. Users need to handle scale factor depend on the situation they have. - `Webview::inner_size` is removed. + - `HasRawWindowHandle` trait is re-exported as `wry::HasRawWindowHandle`. This also means that we removed `tao` as a dependency completely which required some changes to the Android backend: - We exposed the `android_setup` function that needs to be called once to setup necessary logic. - Previously the `android_binding!` had internal call to `tao::android_binding` but now that `tao` has been removed,sa - the macro signature has changed and you now need to call `tao::android_binding` yourself, checkout the crate documentation for more information. \ No newline at end of file + the macro signature has changed and you now need to call `tao::android_binding` yourself, checkout the crate documentation for more information. diff --git a/README.md b/README.md index de4e55370..d056753b0 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Cross-platform WebView rendering library in Rust that supports all major desktop ## Overview WRY connects the web engine on each platform and provides easy to use and unified interface to render WebView. -The webview requires a running event loop and a window type that implements `HasWindowHandle`, +The webview requires a running event loop and a window type that implements `HasRawWindowHandle`, or a gtk container widget if you need to support X11 and Wayland. You can use a windowing library like `tao` or `winit`. diff --git a/src/lib.rs b/src/lib.rs index 98dc32c5c..cbe8c98a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,13 +6,13 @@ //! Wry is a Cross-platform WebView rendering library. //! -//! The webview requires a running event loop and a window type that implements [`HasWindowHandle`], +//! The webview requires a running event loop and a window type that implements [`HasRawWindowHandle`], //! or a gtk container widget if you need to support X11 and Wayland. //! You can use a windowing library like [`tao`] or [`winit`]. //! //! ## Examples //! -//! This example leverages the [`HasWindowHandle`] and supports Windows, macOS, iOS, Android and Linux (X11 Only) +//! This example leverages the [`HasRawWindowHandle`] and supports Windows, macOS, iOS, Android and Linux (X11 Only) //! //! ```no_run //! use wry::WebViewBuilder; @@ -198,7 +198,7 @@ use android::*; target_os = "openbsd" ))] pub(crate) mod webkitgtk; -use raw_window_handle::HasRawWindowHandle; +pub use raw_window_handle::HasRawWindowHandle; #[cfg(any( target_os = "linux", target_os = "dragonfly", @@ -1184,7 +1184,7 @@ pub struct WebView { } impl WebView { - /// Create a [`WebView`] from from a type that implements [`HasWindowHandle`]. + /// Create a [`WebView`] from from a type that implements [`HasRawWindowHandle`]. /// Note that calling this directly loses /// abilities to initialize scripts, add ipc handler, and many more before starting WebView. To /// benefit from above features, create a [`WebViewBuilder`] instead. From 129575cc6f94ee9ad88efc54c86210b4b8b17113 Mon Sep 17 00:00:00 2001 From: rhysd Date: Fri, 10 Nov 2023 23:43:11 +0900 Subject: [PATCH 2/2] feat: re-export entire `raw_window_handle` module instead of `HasRawWindowHandle` trait Signed-off-by: rhysd --- .changes/rwh.md | 2 +- src/lib.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.changes/rwh.md b/.changes/rwh.md index fdb9af772..2ecfd315e 100644 --- a/.changes/rwh.md +++ b/.changes/rwh.md @@ -10,7 +10,7 @@ Refactor new method to take raw window handle instead. Following are APIs got af - Position field in `FileDrop` event is now `Position` instead of `PhysicalPosition`. Users need to handle scale factor depend on the situation they have. - `Webview::inner_size` is removed. - - `HasRawWindowHandle` trait is re-exported as `wry::HasRawWindowHandle`. + - [raw-window-handle](https://docs.rs/raw-window-handle/latest/raw_window_handle/) crate is re-exported as `wry::raw_window_handle`. This also means that we removed `tao` as a dependency completely which required some changes to the Android backend: - We exposed the `android_setup` function that needs to be called once to setup necessary logic. diff --git a/src/lib.rs b/src/lib.rs index cbe8c98a5..26d46ae7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,7 @@ //! This example leverages the [`HasRawWindowHandle`] and supports Windows, macOS, iOS, Android and Linux (X11 Only) //! //! ```no_run -//! use wry::WebViewBuilder; +//! use wry::{WebViewBuilder, raw_window_handle}; //! //! # struct T; //! # unsafe impl raw_window_handle::HasRawWindowHandle for T { @@ -67,7 +67,7 @@ //! macOS, Windows and Linux (X11 Only). //! //! ```no_run -//! use wry::WebViewBuilder; +//! use wry::{WebViewBuilder, raw_window_handle}; //! //! # struct T; //! # unsafe impl raw_window_handle::HasRawWindowHandle for T { @@ -198,7 +198,9 @@ use android::*; target_os = "openbsd" ))] pub(crate) mod webkitgtk; -pub use raw_window_handle::HasRawWindowHandle; +/// Re-exported [raw-window-handle](https://docs.rs/raw-window-handle/latest/raw_window_handle/) crate. +pub use raw_window_handle; +use raw_window_handle::HasRawWindowHandle; #[cfg(any( target_os = "linux", target_os = "dragonfly", @@ -725,7 +727,7 @@ impl<'a> WebViewBuilder<'a> { /// # Examples /// /// ```no_run - /// use wry::WebViewBuilder; + /// use wry::{WebViewBuilder, raw_window_handle}; /// /// # struct T; /// # unsafe impl raw_window_handle::HasRawWindowHandle for T {