From 357b92784ce60610df567cc2c5d1944230ec69fb Mon Sep 17 00:00:00 2001 From: amrbashir Date: Mon, 14 Oct 2024 13:45:06 +0300 Subject: [PATCH 1/2] fix: use `activateIgnoringOtherApps` on older macOS versions closes tauri-apps/tauri#11340 ref: https://github.com/tauri-apps/wry/pull/1316#discussion_r1799161597 --- .changes/crash-macos-below-14.md | 5 +++++ src/wkwebview/mod.rs | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changes/crash-macos-below-14.md diff --git a/.changes/crash-macos-below-14.md b/.changes/crash-macos-below-14.md new file mode 100644 index 000000000..152abdf2e --- /dev/null +++ b/.changes/crash-macos-below-14.md @@ -0,0 +1,5 @@ +--- +"wry": "patch:bug" +--- + +Fix crash on macOS versions below 14. diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs index 7669a76cb..4046a7214 100644 --- a/src/wkwebview/mod.rs +++ b/src/wkwebview/mod.rs @@ -515,7 +515,11 @@ r#"Object.defineProperty(window, 'ipc', { // make sure the window is always on top when we create a new webview let app = NSApplication::sharedApplication(mtm); - NSApplication::activate(&app); + if os_version.0 >= 14 { + NSApplication::activate(&app); + } else { + NSApplication::activateIgnoringOtherApps(&app, true); + } } #[cfg(target_os = "ios")] From 94dea1dd9c7d10f5d1fd0211023a137b3a6adfa4 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 14 Oct 2024 20:51:05 -0300 Subject: [PATCH 2/2] clippy --- src/wkwebview/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs index 4046a7214..0e9aec8bd 100644 --- a/src/wkwebview/mod.rs +++ b/src/wkwebview/mod.rs @@ -518,6 +518,7 @@ r#"Object.defineProperty(window, 'ipc', { if os_version.0 >= 14 { NSApplication::activate(&app); } else { + #[allow(deprecated)] NSApplication::activateIgnoringOtherApps(&app, true); } }