Skip to content

Commit 7c529e3

Browse files
committed
Re-enable audio sharing on Wayland
This also adds a popup to ask for permission to share audio, since Wayland logic is tripped off any UI WebCord usually provides for X11. See: 7883dac
1 parent d77abc4 commit 7c529e3

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

sources/code/main/windows/main.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ export default function createMainWindow(...flags:MainWindowFlags): BrowserWindo
506506
name: "Entire Screen",
507507
thumbnail: nativeImage.createEmpty()
508508
} satisfies Electron.DesktopCapturerSource]);
509-
if(lock) {
509+
if (lock) {
510510
const view = new WebContentsView({
511511
webPreferences: {
512512
preload: resolve(app.getAppPath(), "app/code/renderer/preload/capturer.js"),
@@ -520,20 +520,20 @@ export default function createMainWindow(...flags:MainWindowFlags): BrowserWindo
520520
}
521521
});
522522
ipcMain.handleOnce("getDesktopCapturerSources", async (event) => {
523-
if(event.sender === view.webContents)
523+
if (event.sender === view.webContents)
524524
return await sources;
525525
else
526526
return null;
527527
});
528528
const autoResize = () => setImmediate(() => view.setBounds({
529529
...win.getBounds(),
530-
x:0,
531-
y:0,
530+
x: 0,
531+
y: 0,
532532
}));
533533
ipcMain.handleOnce("capturer-get-settings", () => {
534534
return appConfig.value.screenShareStore;
535535
});
536-
ipcMain.once("closeCapturerView", (_event,data:Electron.Streams) => {
536+
ipcMain.once("closeCapturerView", (_event, data: Electron.Streams) => {
537537
win.contentView.removeChildView(view);
538538
view.webContents.delete();
539539
win.removeListener("resize", autoResize);
@@ -547,18 +547,19 @@ export default function createMainWindow(...flags:MainWindowFlags): BrowserWindo
547547
autoResize();
548548
win.on("resize", autoResize);
549549
});
550-
} else void sources.then(sources => sources[0] ? callback({
551-
video: sources[0],
552-
// FIXME: Look if there's audio on Wayland.
553-
// Also test this code:
554-
//
555-
//...(apiGuard.unixAudioSharing ? {audio:"loopback"} : {})
556-
//
557-
// In general, I know there's bug where Electron seem to
558-
// trigger Wayland capture, but somewhat cancels it or
559-
// stops taking care of its input (crashes?). Need to check
560-
// it out further.
561-
}) : callback(null as unknown as Electron.Streams));
550+
} else void sources.then(sources => {
551+
let allowAudioSharing = false;
552+
// FIXME: L10N
553+
if (apiGuard.unixAudioSharing) allowAudioSharing = dialog.showMessageBoxSync(win, {
554+
message: "Do you want to enable audio as well?",
555+
title: "Wayland: Audio sharing",
556+
buttons: ["yes", "no"]
557+
}) == 0;
558+
if (sources[0]) callback({
559+
video: sources[0],
560+
...(allowAudioSharing ? { audio: "loopback" } : {})
561+
}); else callback(null as unknown as Electron.Streams);
562+
});
562563
},{ useSystemPicker: true });
563564

564565
// IPC events validated by secret "API" key and sender frame.

0 commit comments

Comments
 (0)