File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -556,8 +556,14 @@ app.on("ready", async () => {
556
556
557
557
session . defaultSession . setDisplayMediaRequestHandler ( ( _ , callback ) => {
558
558
if ( process . env . XDG_SESSION_TYPE === "wayland" ) {
559
+ // On Wayland, calling getSources() opens the xdg-desktop-portal picker.
560
+ // The user can only select a single source there, so Electron will return an array with exactly one entry.
559
561
desktopCapturer . getSources ( { types : [ 'screen' , 'window' ] } ) . then ( ( sources ) => {
560
- callback ( { video : sources [ 0 ] } )
562
+ callback ( { video : sources [ 0 ] } ) ;
563
+ } ) . catch ( ( err ) => {
564
+ // If the user cancels the dialog an error occurs "Failed to get sources"
565
+ console . error ( "Wayland: failed to get user-selected source:" , err ) ;
566
+ callback ( { video : { id : "" , name : "" } } ) ; // The promise does not return if no dummy is passed here as source
561
567
} ) ;
562
568
} else {
563
569
global . mainWindow ?. webContents . send ( "openDesktopCapturerSourcePicker" ) ;
You can’t perform that action at this time.
0 commit comments