mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-08-17 03:40:23 +03:00
chore(deps): update wry to 0.36 (#8795)
* chore(deps): update wry to 0.36 * rwh 0.6 * remove raw_window_handle usage * fix build * fix windows test
This commit is contained in:
parent
dd7571a780
commit
2f55bfecbf
7
.changes/rwh-06.md
Normal file
7
.changes/rwh-06.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
"tauri": patch:breaking
|
||||
"tauri-runtime": patch:breaking
|
||||
"tauri-runtime-wry": patch:breaking
|
||||
---
|
||||
|
||||
Update raw-window-handle to 0.6.
|
5
.changes/wry-0.36.md
Normal file
5
.changes/wry-0.36.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-runtime-wry": patch:deps
|
||||
---
|
||||
|
||||
Update `wry` to 0.36.
|
@ -13,11 +13,11 @@ edition = { workspace = true }
|
||||
rust-version = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
wry = { version = "0.35.2", default-features = false, features = [ "file-drop", "protocol", "os-webview" ] }
|
||||
tao = { version = "0.25", default-features = false, features = [ "rwh_05", "rwh_06" ] }
|
||||
wry = { version = "0.36", default-features = false, features = [ "file-drop", "protocol", "os-webview" ] }
|
||||
tao = { version = "0.25", default-features = false, features = [ "rwh_06" ] }
|
||||
tauri-runtime = { version = "2.0.0-beta.1", path = "../tauri-runtime" }
|
||||
tauri-utils = { version = "2.0.0-beta.1", path = "../tauri-utils" }
|
||||
raw-window-handle = "0.5"
|
||||
raw-window-handle = "0.6"
|
||||
http = "0.2"
|
||||
tracing = { version = "0.1", optional = true }
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png"
|
||||
)]
|
||||
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle};
|
||||
use raw_window_handle::{DisplayHandle, HasDisplayHandle, HasWindowHandle};
|
||||
use tauri_runtime::{
|
||||
monitor::Monitor,
|
||||
webview::{DetachedWebview, DownloadEvent, PendingWebview, WebviewIpcHandler},
|
||||
@ -1077,8 +1077,8 @@ pub struct GtkBox(pub gtk::Box);
|
||||
#[allow(clippy::non_send_fields_in_send_ty)]
|
||||
unsafe impl Send for GtkBox {}
|
||||
|
||||
pub struct RawWindowHandle(pub raw_window_handle::RawWindowHandle);
|
||||
unsafe impl Send for RawWindowHandle {}
|
||||
pub struct SendRawWindowHandle(pub raw_window_handle::RawWindowHandle);
|
||||
unsafe impl Send for SendRawWindowHandle {}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[derive(Debug, Clone)]
|
||||
@ -1125,7 +1125,7 @@ pub enum WindowMessage {
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
GtkBox(Sender<GtkBox>),
|
||||
RawWindowHandle(Sender<RawWindowHandle>),
|
||||
RawWindowHandle(Sender<std::result::Result<SendRawWindowHandle, raw_window_handle::HandleError>>),
|
||||
Theme(Sender<Theme>),
|
||||
// Setters
|
||||
Center,
|
||||
@ -1400,6 +1400,12 @@ pub struct WryWindowDispatcher<T: UserEvent> {
|
||||
#[allow(clippy::non_send_fields_in_send_ty)]
|
||||
unsafe impl<T: UserEvent> Sync for WryWindowDispatcher<T> {}
|
||||
|
||||
fn get_raw_window_handle<T: UserEvent>(
|
||||
dispatcher: &WryWindowDispatcher<T>,
|
||||
) -> Result<std::result::Result<SendRawWindowHandle, raw_window_handle::HandleError>> {
|
||||
window_getter!(dispatcher, WindowMessage::RawWindowHandle)
|
||||
}
|
||||
|
||||
impl<T: UserEvent> WindowDispatch<T> for WryWindowDispatcher<T> {
|
||||
type Runtime = Wry<T>;
|
||||
type WindowBuilder = WindowBuilderWrapper;
|
||||
@ -1531,8 +1537,12 @@ impl<T: UserEvent> WindowDispatch<T> for WryWindowDispatcher<T> {
|
||||
window_getter!(self, WindowMessage::GtkBox).map(|w| w.0)
|
||||
}
|
||||
|
||||
fn raw_window_handle(&self) -> Result<raw_window_handle::RawWindowHandle> {
|
||||
window_getter!(self, WindowMessage::RawWindowHandle).map(|w| w.0)
|
||||
fn window_handle(
|
||||
&self,
|
||||
) -> std::result::Result<raw_window_handle::WindowHandle<'_>, raw_window_handle::HandleError> {
|
||||
get_raw_window_handle(self)
|
||||
.map_err(|_| raw_window_handle::HandleError::Unavailable)
|
||||
.and_then(|r| r.map(|h| unsafe { raw_window_handle::WindowHandle::borrow_raw(h.0) }))
|
||||
}
|
||||
|
||||
// Setters
|
||||
@ -2046,8 +2056,8 @@ impl<T: UserEvent> RuntimeHandle<T> for WryHandle<T> {
|
||||
send_user_message(&self.context, Message::Task(Box::new(f)))
|
||||
}
|
||||
|
||||
fn raw_display_handle(&self) -> RawDisplayHandle {
|
||||
self.context.main_thread.window_target.raw_display_handle()
|
||||
fn display_handle(&self) -> std::result::Result<DisplayHandle, raw_window_handle::HandleError> {
|
||||
self.context.main_thread.window_target.display_handle()
|
||||
}
|
||||
|
||||
fn primary_monitor(&self) -> Option<Monitor> {
|
||||
@ -2547,7 +2557,11 @@ fn handle_user_message<T: UserEvent>(
|
||||
.send(GtkBox(window.default_vbox().unwrap().clone()))
|
||||
.unwrap(),
|
||||
WindowMessage::RawWindowHandle(tx) => tx
|
||||
.send(RawWindowHandle(window.raw_window_handle()))
|
||||
.send(
|
||||
window
|
||||
.window_handle()
|
||||
.map(|h| SendRawWindowHandle(h.as_raw())),
|
||||
)
|
||||
.unwrap(),
|
||||
WindowMessage::Theme(tx) => {
|
||||
tx.send(map_theme(&window.theme())).unwrap();
|
||||
|
@ -31,7 +31,7 @@ serde_json = "1.0"
|
||||
thiserror = "1.0"
|
||||
tauri-utils = { version = "2.0.0-beta.1", path = "../tauri-utils" }
|
||||
http = "0.2.4"
|
||||
raw-window-handle = "0.5"
|
||||
raw-window-handle = "0.6"
|
||||
url = { version = "2" }
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
|
@ -12,7 +12,7 @@
|
||||
)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
use raw_window_handle::RawDisplayHandle;
|
||||
use raw_window_handle::DisplayHandle;
|
||||
use serde::Deserialize;
|
||||
use std::{fmt::Debug, sync::mpsc::Sender};
|
||||
use tauri_utils::{ProgressBarState, Theme};
|
||||
@ -233,7 +233,7 @@ pub trait RuntimeHandle<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 'st
|
||||
/// Run a task on the main thread.
|
||||
fn run_on_main_thread<F: FnOnce() + Send + 'static>(&self, f: F) -> Result<()>;
|
||||
|
||||
fn raw_display_handle(&self) -> RawDisplayHandle;
|
||||
fn display_handle(&self) -> std::result::Result<DisplayHandle, raw_window_handle::HandleError>;
|
||||
|
||||
fn primary_monitor(&self) -> Option<Monitor>;
|
||||
fn available_monitors(&self) -> Vec<Monitor>;
|
||||
@ -525,7 +525,9 @@ pub trait WindowDispatch<T: UserEvent>: Debug + Clone + Send + Sync + Sized + 's
|
||||
fn default_vbox(&self) -> Result<gtk::Box>;
|
||||
|
||||
/// Raw window handle.
|
||||
fn raw_window_handle(&self) -> Result<raw_window_handle::RawWindowHandle>;
|
||||
fn window_handle(
|
||||
&self,
|
||||
) -> std::result::Result<raw_window_handle::WindowHandle<'_>, raw_window_handle::HandleError>;
|
||||
|
||||
/// Returns the current window theme.
|
||||
fn theme(&self) -> Result<Theme>;
|
||||
|
@ -62,7 +62,7 @@ dirs-next = "2.0"
|
||||
percent-encoding = "2.3"
|
||||
reqwest = { version = "0.11", default-features = false, features = [ "json", "stream" ] }
|
||||
bytes = { version = "1", features = [ "serde" ] }
|
||||
raw-window-handle = "0.5"
|
||||
raw-window-handle = "0.6"
|
||||
glob = "0.3"
|
||||
mime = "0.3"
|
||||
data-url = { version = "0.3", optional = true }
|
||||
@ -86,11 +86,11 @@ webkit2gtk = { version = "=2.0.1", features = [ "v2_38" ] }
|
||||
embed_plist = "1.2"
|
||||
cocoa = "0.25"
|
||||
objc = "0.2"
|
||||
window-vibrancy = "0.4"
|
||||
window-vibrancy = "0.5"
|
||||
|
||||
[target."cfg(windows)".dependencies]
|
||||
webview2-com = "0.28"
|
||||
window-vibrancy = "0.4"
|
||||
window-vibrancy = "0.5"
|
||||
|
||||
[target."cfg(windows)".dependencies.windows]
|
||||
version = "0.52"
|
||||
|
@ -28,7 +28,7 @@ use crate::{
|
||||
use crate::menu::{Menu, MenuEvent};
|
||||
#[cfg(all(desktop, feature = "tray-icon"))]
|
||||
use crate::tray::{TrayIcon, TrayIconBuilder, TrayIconEvent, TrayIconId};
|
||||
use raw_window_handle::HasRawDisplayHandle;
|
||||
use raw_window_handle::HasDisplayHandle;
|
||||
use serialize_to_javascript::{default_template, DefaultTemplate, Template};
|
||||
use tauri_macros::default_runtime;
|
||||
#[cfg(desktop)]
|
||||
@ -1730,15 +1730,19 @@ fn init_app_menu<R: Runtime>(menu: &Menu<R>) -> crate::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
unsafe impl<R: Runtime> HasRawDisplayHandle for AppHandle<R> {
|
||||
fn raw_display_handle(&self) -> raw_window_handle::RawDisplayHandle {
|
||||
self.runtime_handle.raw_display_handle()
|
||||
impl<R: Runtime> HasDisplayHandle for AppHandle<R> {
|
||||
fn display_handle(
|
||||
&self,
|
||||
) -> std::result::Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
|
||||
self.runtime_handle.display_handle()
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<R: Runtime> HasRawDisplayHandle for App<R> {
|
||||
fn raw_display_handle(&self) -> raw_window_handle::RawDisplayHandle {
|
||||
self.handle.raw_display_handle()
|
||||
impl<R: Runtime> HasDisplayHandle for App<R> {
|
||||
fn display_handle(
|
||||
&self,
|
||||
) -> std::result::Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
|
||||
self.handle.display_handle()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,6 +148,10 @@ pub enum Error {
|
||||
/// Failed to deserialize scope object.
|
||||
#[error("error deserializing scope: {0}")]
|
||||
CannotDeserializeScope(Box<dyn std::error::Error + Send + Sync>),
|
||||
|
||||
/// Failed to get a raw handle.
|
||||
#[error(transparent)]
|
||||
RawHandleError(#[from] raw_window_handle::HandleError),
|
||||
}
|
||||
|
||||
/// `Result<T, ::tauri::Error>`
|
||||
|
@ -203,17 +203,27 @@ impl<T: UserEvent> RuntimeHandle<T> for MockRuntimeHandle {
|
||||
self.context.send_message(Message::Task(Box::new(f)))
|
||||
}
|
||||
|
||||
fn raw_display_handle(&self) -> raw_window_handle::RawDisplayHandle {
|
||||
fn display_handle(
|
||||
&self,
|
||||
) -> std::result::Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
|
||||
#[cfg(target_os = "linux")]
|
||||
return raw_window_handle::RawDisplayHandle::Xlib(raw_window_handle::XlibDisplayHandle::empty());
|
||||
return Ok(unsafe {
|
||||
raw_window_handle::DisplayHandle::borrow_raw(raw_window_handle::RawDisplayHandle::Xlib(
|
||||
raw_window_handle::XlibDisplayHandle::new(None, 0),
|
||||
))
|
||||
});
|
||||
#[cfg(target_os = "macos")]
|
||||
return raw_window_handle::RawDisplayHandle::AppKit(
|
||||
raw_window_handle::AppKitDisplayHandle::empty(),
|
||||
);
|
||||
return Ok(unsafe {
|
||||
raw_window_handle::DisplayHandle::borrow_raw(raw_window_handle::RawDisplayHandle::AppKit(
|
||||
raw_window_handle::AppKitDisplayHandle::new(),
|
||||
))
|
||||
});
|
||||
#[cfg(windows)]
|
||||
return raw_window_handle::RawDisplayHandle::Windows(
|
||||
raw_window_handle::WindowsDisplayHandle::empty(),
|
||||
);
|
||||
return Ok(unsafe {
|
||||
raw_window_handle::DisplayHandle::borrow_raw(raw_window_handle::RawDisplayHandle::Windows(
|
||||
raw_window_handle::WindowsDisplayHandle::new(),
|
||||
))
|
||||
});
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos", windows)))]
|
||||
return unimplemented!();
|
||||
}
|
||||
@ -641,19 +651,31 @@ impl<T: UserEvent> WindowDispatch<T> for MockWindowDispatcher {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn raw_window_handle(&self) -> Result<raw_window_handle::RawWindowHandle> {
|
||||
fn window_handle(
|
||||
&self,
|
||||
) -> std::result::Result<raw_window_handle::WindowHandle<'_>, raw_window_handle::HandleError> {
|
||||
#[cfg(target_os = "linux")]
|
||||
return Ok(raw_window_handle::RawWindowHandle::Xlib(
|
||||
raw_window_handle::XlibWindowHandle::empty(),
|
||||
));
|
||||
return unsafe {
|
||||
Ok(raw_window_handle::WindowHandle::borrow_raw(
|
||||
raw_window_handle::RawWindowHandle::Xlib(raw_window_handle::XlibWindowHandle::new(0)),
|
||||
))
|
||||
};
|
||||
#[cfg(target_os = "macos")]
|
||||
return Ok(raw_window_handle::RawWindowHandle::AppKit(
|
||||
raw_window_handle::AppKitWindowHandle::empty(),
|
||||
));
|
||||
return unsafe {
|
||||
Ok(raw_window_handle::WindowHandle::borrow_raw(
|
||||
raw_window_handle::RawWindowHandle::AppKit(raw_window_handle::AppKitWindowHandle::new(
|
||||
std::ptr::NonNull::from(&()).cast(),
|
||||
)),
|
||||
))
|
||||
};
|
||||
#[cfg(windows)]
|
||||
return Ok(raw_window_handle::RawWindowHandle::Win32(
|
||||
raw_window_handle::Win32WindowHandle::empty(),
|
||||
));
|
||||
return unsafe {
|
||||
Ok(raw_window_handle::WindowHandle::borrow_raw(
|
||||
raw_window_handle::RawWindowHandle::Win32(raw_window_handle::Win32WindowHandle::new(
|
||||
std::num::NonZeroIsize::MIN,
|
||||
)),
|
||||
))
|
||||
};
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos", windows)))]
|
||||
return unimplemented!();
|
||||
}
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
use crate::utils::config::WindowEffectsConfig;
|
||||
use crate::window::{Effect, EffectState};
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use raw_window_handle::HasWindowHandle;
|
||||
use window_vibrancy::{NSVisualEffectMaterial, NSVisualEffectState};
|
||||
|
||||
pub fn apply_effects(window: impl HasRawWindowHandle, effects: WindowEffectsConfig) {
|
||||
pub fn apply_effects(window: impl HasWindowHandle, effects: WindowEffectsConfig) {
|
||||
let WindowEffectsConfig {
|
||||
effects,
|
||||
radius,
|
||||
|
@ -11,10 +11,10 @@ use std::ffi::c_void;
|
||||
|
||||
use crate::utils::config::WindowEffectsConfig;
|
||||
use crate::window::{Color, Effect};
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use raw_window_handle::HasWindowHandle;
|
||||
use windows::Win32::Foundation::HWND;
|
||||
|
||||
pub fn apply_effects(window: impl HasRawWindowHandle, effects: WindowEffectsConfig) {
|
||||
pub fn apply_effects(window: impl HasWindowHandle, effects: WindowEffectsConfig) {
|
||||
let WindowEffectsConfig { effects, color, .. } = effects;
|
||||
let effect = if let Some(effect) = effects.iter().find(|e| {
|
||||
matches!(
|
||||
@ -47,7 +47,7 @@ pub fn apply_effects(window: impl HasRawWindowHandle, effects: WindowEffectsConf
|
||||
};
|
||||
}
|
||||
|
||||
pub fn clear_effects(window: impl HasRawWindowHandle) {
|
||||
pub fn clear_effects(window: impl HasWindowHandle) {
|
||||
window_vibrancy::clear_blur(&window);
|
||||
window_vibrancy::clear_acrylic(&window);
|
||||
window_vibrancy::clear_mica(&window);
|
||||
|
@ -864,9 +864,11 @@ impl<R: Runtime> PartialEq for WebviewWindow<R> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<R: Runtime> raw_window_handle::HasRawWindowHandle for WebviewWindow<R> {
|
||||
fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
|
||||
self.webview.window().raw_window_handle()
|
||||
impl<R: Runtime> raw_window_handle::HasWindowHandle for WebviewWindow<R> {
|
||||
fn window_handle(
|
||||
&self,
|
||||
) -> std::result::Result<raw_window_handle::WindowHandle<'_>, raw_window_handle::HandleError> {
|
||||
self.webview.window().window_handle()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -877,9 +877,11 @@ impl<R: Runtime> std::fmt::Debug for Window<R> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl<R: Runtime> raw_window_handle::HasRawWindowHandle for Window<R> {
|
||||
fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
|
||||
self.window.dispatcher.raw_window_handle().unwrap()
|
||||
impl<R: Runtime> raw_window_handle::HasWindowHandle for Window<R> {
|
||||
fn window_handle(
|
||||
&self,
|
||||
) -> std::result::Result<raw_window_handle::WindowHandle<'_>, raw_window_handle::HandleError> {
|
||||
self.window.dispatcher.window_handle()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1418,11 +1420,16 @@ impl<R: Runtime> Window<R> {
|
||||
self
|
||||
.window
|
||||
.dispatcher
|
||||
.raw_window_handle()
|
||||
.window_handle()
|
||||
.map_err(Into::into)
|
||||
.and_then(|handle| {
|
||||
if let raw_window_handle::RawWindowHandle::AppKit(h) = handle {
|
||||
Ok(h.ns_window)
|
||||
if let raw_window_handle::RawWindowHandle::AppKit(h) = handle.as_raw() {
|
||||
Ok(unsafe {
|
||||
use objc::*;
|
||||
let ns_window: cocoa::base::id =
|
||||
objc::msg_send![h.ns_view.as_ptr() as cocoa::base::id, window];
|
||||
ns_window as *mut _
|
||||
})
|
||||
} else {
|
||||
Err(crate::Error::InvalidWindowHandle)
|
||||
}
|
||||
@ -1435,11 +1442,11 @@ impl<R: Runtime> Window<R> {
|
||||
self
|
||||
.window
|
||||
.dispatcher
|
||||
.raw_window_handle()
|
||||
.window_handle()
|
||||
.map_err(Into::into)
|
||||
.and_then(|handle| {
|
||||
if let raw_window_handle::RawWindowHandle::AppKit(h) = handle {
|
||||
Ok(h.ns_view)
|
||||
if let raw_window_handle::RawWindowHandle::AppKit(h) = handle.as_raw() {
|
||||
Ok(h.ns_view.as_ptr())
|
||||
} else {
|
||||
Err(crate::Error::InvalidWindowHandle)
|
||||
}
|
||||
@ -1452,11 +1459,11 @@ impl<R: Runtime> Window<R> {
|
||||
self
|
||||
.window
|
||||
.dispatcher
|
||||
.raw_window_handle()
|
||||
.window_handle()
|
||||
.map_err(Into::into)
|
||||
.and_then(|handle| {
|
||||
if let raw_window_handle::RawWindowHandle::Win32(h) = handle {
|
||||
Ok(HWND(h.hwnd as _))
|
||||
if let raw_window_handle::RawWindowHandle::Win32(h) = handle.as_raw() {
|
||||
Ok(HWND(h.hwnd.get()))
|
||||
} else {
|
||||
Err(crate::Error::InvalidWindowHandle)
|
||||
}
|
||||
|
6
examples/api/src-tauri/Cargo.lock
generated
6
examples/api/src-tauri/Cargo.lock
generated
@ -4960,9 +4960,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wry"
|
||||
version = "0.35.2"
|
||||
version = "0.36.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3016c47c9b6f7029a9da7cd48af8352327226bba0e955f3c92e2966651365a9"
|
||||
checksum = "3a9e7b81968555303086ef882a0c213896a76099de4ed0b86a798775c2d54304"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"block",
|
||||
@ -4986,7 +4986,7 @@ dependencies = [
|
||||
"objc",
|
||||
"objc_id",
|
||||
"once_cell",
|
||||
"raw-window-handle 0.5.2",
|
||||
"raw-window-handle 0.6.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
|
Loading…
Reference in New Issue
Block a user