Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #1101 #1107

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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