Skip to content

Commit

Permalink
fix: tauri-apps#1101 screen share permissions dialog (tauri-apps#1111)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarushnagpal authored and jiangjw committed Feb 5, 2024
1 parent 42b0cdd commit 9db277b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-screenshare-media-dialog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": patch
---

Fix screen share permissions dialog not showing up on macOS 14.0+
26 changes: 21 additions & 5 deletions src/wkwebview/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<i32>();
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()
}
Expand Down Expand Up @@ -1170,6 +1175,17 @@ pub fn platform_webview_version() -> Result<String> {
}
}

pub fn platform_webview_system_version() -> Result<String> {
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
Expand Down

0 comments on commit 9db277b

Please sign in to comment.