From b711f0207c06d61165c6ddbcb3ff373a6a969078 Mon Sep 17 00:00:00 2001 From: fabianlars Date: Mon, 6 Jan 2025 18:41:32 +0100 Subject: [PATCH] ios --- src/wkwebview/class/wry_web_view_parent.rs | 22 ++++++++++------------ src/wkwebview/mod.rs | 9 ++++----- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/wkwebview/class/wry_web_view_parent.rs b/src/wkwebview/class/wry_web_view_parent.rs index fe968632d..3942b9959 100644 --- a/src/wkwebview/class/wry_web_view_parent.rs +++ b/src/wkwebview/class/wry_web_view_parent.rs @@ -69,19 +69,17 @@ impl WryWebViewParent { unsafe { msg_send_id![super(delegate), init] } } + #[cfg(target_os = "macos")] pub fn set_traffic_light_inset(&self, ns_window: &NSWindow, position: dpi::Position) { - #[cfg(target_os = "macos")] - { - let scale_factor = NSWindow::backingScaleFactor(ns_window); - let position = position.to_logical(scale_factor); - self - .ivars() - .traffic_light_inset - .replace(Some((position.x, position.y))); - - unsafe { - inset_traffic_lights(ns_window, position.x, position.y); - } + let scale_factor = NSWindow::backingScaleFactor(ns_window); + let position = position.to_logical(scale_factor); + self + .ivars() + .traffic_light_inset + .replace(Some((position.x, position.y))); + + unsafe { + inset_traffic_lights(ns_window, position.x, position.y); } } } diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs index 2af78784e..d6a0acfb3 100644 --- a/src/wkwebview/mod.rs +++ b/src/wkwebview/mod.rs @@ -135,6 +135,7 @@ pub(crate) struct InnerWebView { // We need this the keep the reference count ui_delegate: Retained, protocol_ptrs: Vec<*mut Box>, RequestAsyncResponder)>>, + #[cfg(target_os = "macos")] // We need this to update the traffic light inset parent_view: Option>, } @@ -941,12 +942,10 @@ r#"Object.defineProperty(window, 'ipc', { Ok(()) } + #[cfg(target_os = "macos")] pub(crate) fn set_traffic_light_inset(&self, position: dpi::Position) -> crate::Result<()> { - #[cfg(target_os = "macos")] - if !self.is_child { - if let Some(parent_view) = &self.parent_view { - parent_view.set_traffic_light_inset(&self.webview.window().unwrap(), position); - } + if let Some(parent_view) = &self.parent_view { + parent_view.set_traffic_light_inset(&self.webview.window().unwrap(), position); } Ok(())