agent: fix — auto-grant microphone permission on WebKitGTK/Linux
WebKitGTK denies getUserMedia by default with no permission prompt. Connect to the permission-request signal and auto-allow, plus enable media-stream and media-capabilities in WebKit settings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -94,6 +94,34 @@ pub fn run() {
|
||||
let _ = main_window.eval(&init_script);
|
||||
}
|
||||
|
||||
// Auto-grant microphone permission on Linux (WebKitGTK).
|
||||
// WebKitGTK doesn't show a permission dialog — it just denies
|
||||
// getUserMedia by default. We connect to the permission-request
|
||||
// signal and grant audio capture requests automatically.
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
main_window.with_webview(|webview| {
|
||||
use webkit2gtk::{
|
||||
PermissionRequest, PermissionRequestExt,
|
||||
SettingsExt, WebViewExt,
|
||||
};
|
||||
|
||||
let wv: webkit2gtk::WebView = webview.inner().clone();
|
||||
|
||||
// Enable media stream in WebKit settings
|
||||
if let Some(settings) = WebViewExt::settings(&wv) {
|
||||
settings.set_enable_media_stream(true);
|
||||
settings.set_enable_media_capabilities(true);
|
||||
}
|
||||
|
||||
// Auto-grant all permission requests (audio/video capture)
|
||||
WebViewExt::connect_permission_request(&wv, |_wv, request: &PermissionRequest| {
|
||||
request.allow();
|
||||
true
|
||||
});
|
||||
}).expect("Failed to configure webview media permissions");
|
||||
}
|
||||
|
||||
// Close-to-tray: hide window instead of exiting
|
||||
let win = main_window.clone();
|
||||
main_window.on_window_event(move |event| {
|
||||
|
||||
Reference in New Issue
Block a user