mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
committed by
GitHub
parent
8c13344f8f
commit
fe32afcc93
7
.changes/window-send-sync.md
Normal file
7
.changes/window-send-sync.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"tauri": patch
|
||||
"tauri-runtime-wry": patch
|
||||
"tauri-runtime": patch
|
||||
---
|
||||
|
||||
`Window` is now `Send + Sync` on Windows.
|
||||
@@ -594,7 +594,7 @@ impl From<FileDropEventWrapper> for FileDropEvent {
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
struct Hwnd(*mut std::ffi::c_void);
|
||||
struct Hwnd(HWND);
|
||||
#[cfg(windows)]
|
||||
unsafe impl Send for Hwnd {}
|
||||
|
||||
@@ -823,7 +823,7 @@ impl Dispatch for WryDispatcher {
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn hwnd(&self) -> Result<*mut std::ffi::c_void> {
|
||||
fn hwnd(&self) -> Result<HWND> {
|
||||
Ok(dispatcher_getter!(self, WindowMessage::Hwnd).0)
|
||||
}
|
||||
|
||||
@@ -1594,7 +1594,7 @@ fn handle_event_loop(
|
||||
#[cfg(windows)]
|
||||
WindowMessage::Hwnd(tx) => {
|
||||
use wry::application::platform::windows::WindowExtWindows;
|
||||
tx.send(Hwnd(window.hwnd())).unwrap()
|
||||
tx.send(Hwnd(window.hwnd() as HWND)).unwrap()
|
||||
}
|
||||
// Setters
|
||||
WindowMessage::Center(tx) => {
|
||||
|
||||
@@ -11,6 +11,8 @@ use std::{fmt::Debug, hash::Hash, path::PathBuf};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri_utils::assets::Assets;
|
||||
use uuid::Uuid;
|
||||
#[cfg(windows)]
|
||||
use winapi::shared::windef::HWND;
|
||||
|
||||
/// Create window and system tray menus.
|
||||
#[cfg(any(feature = "menu", feature = "system-tray"))]
|
||||
@@ -413,7 +415,7 @@ pub trait Dispatch: Clone + Send + Sized + 'static {
|
||||
|
||||
/// Returns the native handle that is used by this window.
|
||||
#[cfg(windows)]
|
||||
fn hwnd(&self) -> crate::Result<*mut std::ffi::c_void>;
|
||||
fn hwnd(&self) -> crate::Result<HWND>;
|
||||
|
||||
// SETTERS
|
||||
|
||||
|
||||
@@ -503,7 +503,12 @@ impl<P: Params> Window<P> {
|
||||
/// You can spawn a task to use the API using the [`async_runtime`](crate::async_runtime) to prevent the panic.
|
||||
#[cfg(windows)]
|
||||
pub fn hwnd(&self) -> crate::Result<*mut std::ffi::c_void> {
|
||||
self.window.dispatcher.hwnd().map_err(Into::into)
|
||||
self
|
||||
.window
|
||||
.dispatcher
|
||||
.hwnd()
|
||||
.map(|hwnd| hwnd as *mut _)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
// Setters
|
||||
|
||||
Reference in New Issue
Block a user