diff --git a/.changes/fix-screenshare-media-dialog.md b/.changes/fix-screenshare-media-dialog.md new file mode 100644 index 0000000000..1979f5673f --- /dev/null +++ b/.changes/fix-screenshare-media-dialog.md @@ -0,0 +1,5 @@ +--- +"wry": patch +--- + +Fix screen share permissions dialog not showing up on macOS 14.0+ diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs index 49d8f62e4a..6fbcfe18d2 100644 --- a/src/wkwebview/mod.rs +++ b/src/wkwebview/mod.rs @@ -787,11 +787,16 @@ impl InnerWebView { run_file_upload_panel as extern "C" fn(&Object, Sel, id, id, id, id), ); - // Disable media dialogs - ctl.add_method( - sel!(webView:requestMediaCapturePermissionForOrigin:initiatedByFrame:type:decisionHandler:), - request_media_capture_permission as extern "C" fn(&Object, Sel, id, id, id, id, id), - ); + // Only disable media dialogs on macOS < 14.0 + // https://tauri.app/v1/references/webview-versions/ + let webview_system_version = platform_webview_system_version()?.parse::(); + if webview_system_version.is_err() || webview_system_version.unwrap() < 19 { + // Disable media dialogs + ctl.add_method( + sel!(webView:requestMediaCapturePermissionForOrigin:initiatedByFrame:type:decisionHandler:), + request_media_capture_permission as extern "C" fn(&Object, Sel, id, id, id, id, id), + ); + } ctl.register() } @@ -1170,6 +1175,17 @@ pub fn platform_webview_version() -> Result { } } +pub fn platform_webview_system_version() -> Result { + platform_webview_version().map(|webview_version| { + let webview_system_and_major_version = webview_version.split('.').next().unwrap(); + if webview_system_and_major_version.chars().count() < 5 { + webview_system_and_major_version[..1].to_string() + } else { + webview_system_and_major_version[..2].to_string() + } + }) +} + impl Drop for InnerWebView { fn drop(&mut self) { // We need to drop handler closures here