|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
//! The [`wry`] Tauri [`Runtime`].
|
|
|
|
|
|
+use raw_window_handle::HasRawWindowHandle;
|
|
|
use tauri_runtime::{
|
|
|
http::{
|
|
|
Request as HttpRequest, RequestParts as HttpRequestParts, Response as HttpResponse,
|
|
@@ -976,18 +977,6 @@ impl From<FileDropEventWrapper> for FileDropEvent {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#[cfg(target_os = "macos")]
|
|
|
-pub struct NSWindow(*mut std::ffi::c_void);
|
|
|
-#[cfg(target_os = "macos")]
|
|
|
-#[allow(clippy::non_send_fields_in_send_ty)]
|
|
|
-unsafe impl Send for NSWindow {}
|
|
|
-
|
|
|
-#[cfg(windows)]
|
|
|
-pub struct Hwnd(HWND);
|
|
|
-#[cfg(windows)]
|
|
|
-#[allow(clippy::non_send_fields_in_send_ty)]
|
|
|
-unsafe impl Send for Hwnd {}
|
|
|
-
|
|
|
#[cfg(any(
|
|
|
target_os = "linux",
|
|
|
target_os = "dragonfly",
|
|
@@ -1006,6 +995,9 @@ pub struct GtkWindow(gtk::ApplicationWindow);
|
|
|
#[allow(clippy::non_send_fields_in_send_ty)]
|
|
|
unsafe impl Send for GtkWindow {}
|
|
|
|
|
|
+pub struct RawWindowHandle(raw_window_handle::RawWindowHandle);
|
|
|
+unsafe impl Send for RawWindowHandle {}
|
|
|
+
|
|
|
pub enum WindowMessage {
|
|
|
WithWebview(Box<dyn FnOnce(Webview) + Send>),
|
|
|
// Devtools
|
|
@@ -1030,10 +1022,6 @@ pub enum WindowMessage {
|
|
|
CurrentMonitor(Sender<Option<MonitorHandle>>),
|
|
|
PrimaryMonitor(Sender<Option<MonitorHandle>>),
|
|
|
AvailableMonitors(Sender<Vec<MonitorHandle>>),
|
|
|
- #[cfg(target_os = "macos")]
|
|
|
- NSWindow(Sender<NSWindow>),
|
|
|
- #[cfg(windows)]
|
|
|
- Hwnd(Sender<Hwnd>),
|
|
|
#[cfg(any(
|
|
|
target_os = "linux",
|
|
|
target_os = "dragonfly",
|
|
@@ -1042,6 +1030,7 @@ pub enum WindowMessage {
|
|
|
target_os = "openbsd"
|
|
|
))]
|
|
|
GtkWindow(Sender<GtkWindow>),
|
|
|
+ RawWindowHandle(Sender<RawWindowHandle>),
|
|
|
Theme(Sender<Theme>),
|
|
|
// Setters
|
|
|
Center(Sender<Result<()>>),
|
|
@@ -1285,16 +1274,6 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
- #[cfg(target_os = "macos")]
|
|
|
- fn ns_window(&self) -> Result<*mut std::ffi::c_void> {
|
|
|
- window_getter!(self, WindowMessage::NSWindow).map(|w| w.0)
|
|
|
- }
|
|
|
-
|
|
|
- #[cfg(windows)]
|
|
|
- fn hwnd(&self) -> Result<HWND> {
|
|
|
- window_getter!(self, WindowMessage::Hwnd).map(|w| w.0)
|
|
|
- }
|
|
|
-
|
|
|
fn theme(&self) -> Result<Theme> {
|
|
|
window_getter!(self, WindowMessage::Theme)
|
|
|
}
|
|
@@ -1311,6 +1290,10 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
|
|
|
window_getter!(self, WindowMessage::GtkWindow).map(|w| w.0)
|
|
|
}
|
|
|
|
|
|
+ fn raw_window_handle(&self) -> Result<raw_window_handle::RawWindowHandle> {
|
|
|
+ window_getter!(self, WindowMessage::RawWindowHandle).map(|w| w.0)
|
|
|
+ }
|
|
|
+
|
|
|
// Setters
|
|
|
|
|
|
fn center(&self) -> Result<()> {
|
|
@@ -2330,10 +2313,6 @@ fn handle_user_message<T: UserEvent>(
|
|
|
WindowMessage::AvailableMonitors(tx) => {
|
|
|
tx.send(window.available_monitors().collect()).unwrap()
|
|
|
}
|
|
|
- #[cfg(target_os = "macos")]
|
|
|
- WindowMessage::NSWindow(tx) => tx.send(NSWindow(window.ns_window())).unwrap(),
|
|
|
- #[cfg(windows)]
|
|
|
- WindowMessage::Hwnd(tx) => tx.send(Hwnd(HWND(window.hwnd() as _))).unwrap(),
|
|
|
#[cfg(any(
|
|
|
target_os = "linux",
|
|
|
target_os = "dragonfly",
|
|
@@ -2344,6 +2323,9 @@ fn handle_user_message<T: UserEvent>(
|
|
|
WindowMessage::GtkWindow(tx) => {
|
|
|
tx.send(GtkWindow(window.gtk_window().clone())).unwrap()
|
|
|
}
|
|
|
+ WindowMessage::RawWindowHandle(tx) => tx
|
|
|
+ .send(RawWindowHandle(window.raw_window_handle()))
|
|
|
+ .unwrap(),
|
|
|
WindowMessage::Theme(tx) => {
|
|
|
#[cfg(any(windows, target_os = "macos"))]
|
|
|
tx.send(map_theme(&window.theme())).unwrap();
|