From 8f48145125b0c80096d4248cbed67fc91bb71a26 Mon Sep 17 00:00:00 2001 From: fabianlars Date: Mon, 6 Jan 2025 18:08:34 +0100 Subject: [PATCH] fix? --- Cargo.toml | 2 ++ src/wkwebview/class/wry_web_view_parent.rs | 29 +++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1bec5fd12..ab5b634ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -156,6 +156,8 @@ objc2-ui-kit = { version = "0.2.2", features = [ [target."cfg(target_os = \"macos\")".dependencies] objc2-app-kit = { version = "0.2.0", features = [ "NSApplication", + "NSButton", + "NSControl", "NSEvent", "NSWindow", "NSView", diff --git a/src/wkwebview/class/wry_web_view_parent.rs b/src/wkwebview/class/wry_web_view_parent.rs index f54cfd152..fe968632d 100644 --- a/src/wkwebview/class/wry_web_view_parent.rs +++ b/src/wkwebview/class/wry_web_view_parent.rs @@ -8,9 +8,10 @@ use objc2::{ declare_class, msg_send_id, mutability::MainThreadOnly, rc::Retained, ClassType, DeclaredClass, }; #[cfg(target_os = "macos")] -use objc2_app_kit::{NSApplication, NSEvent, NSView}; -use objc2_app_kit::{NSWindow, NSWindowButton}; -use objc2_foundation::{MainThreadMarker, NSRect}; +use objc2_app_kit::{NSApplication, NSEvent, NSView, NSWindow, NSWindowButton}; +use objc2_foundation::MainThreadMarker; +#[cfg(target_os = "macos")] +use objc2_foundation::NSRect; #[cfg(target_os = "ios")] use objc2_ui_kit::UIView as NSView; @@ -69,19 +70,23 @@ impl WryWebViewParent { } pub fn set_traffic_light_inset(&self, ns_window: &NSWindow, position: dpi::Position) { - 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); + #[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); + } } } } +#[cfg(target_os = "macos")] pub unsafe fn inset_traffic_lights(window: &NSWindow, x: f64, y: f64) { let close = window .standardWindowButton(NSWindowButton::NSWindowCloseButton)