diff --git a/src/renderer/components/ScreenSharePicker.tsx b/src/renderer/components/ScreenSharePicker.tsx index 45319434..a470d1fc 100644 --- a/src/renderer/components/ScreenSharePicker.tsx +++ b/src/renderer/components/ScreenSharePicker.tsx @@ -20,7 +20,7 @@ import { useState } from "@vencord/types/webpack/common"; import type { Dispatch, SetStateAction } from "react"; -import { patchAudioWithDevice } from "renderer/patches/screenShareAudio"; +import { patchDisplayMedia } from "renderer/patches/screenSharePatch"; import { addPatch } from "renderer/patches/shared"; import { isLinux, isWindows } from "renderer/utils"; @@ -43,6 +43,7 @@ interface StreamSettings { export interface StreamPick extends StreamSettings { id: string; + cameraId?: string; } interface Source { @@ -51,6 +52,11 @@ interface Source { url: string; } +interface Camera { + id: string; + name: string; +} + let currentSettings: StreamSettings | null = null; addPatch({ @@ -100,6 +106,7 @@ if (isLinux) { export function openScreenSharePicker(screens: Source[], skipPicker: boolean) { let didSubmit = false; + return new Promise((resolve, reject) => { const key = openModal( props => ( @@ -109,16 +116,24 @@ export function openScreenSharePicker(screens: Source[], skipPicker: boolean) { submit={async v => { didSubmit = true; if (v.audioSource && v.audioSource !== "None") { - if (v.audioSource === "Entire System") { - await VesktopNative.virtmic.startSystem(v.workaround); - } else { - await VesktopNative.virtmic.start([v.audioSource], v.workaround); + patchDisplayMedia({ + audioId: v.audioDevice, + venmic: !!v.audioSource && v.audioSource !== "None", + videoId: v.cameraId + }); + + if (!v.audioDevice && v.audioSource && v.audioSource !== "None") { + if (v.audioSource === "Entire System") { + await VesktopNative.virtmic.startSystem(v.workaround); + } else { + await VesktopNative.virtmic.start([v.audioSource], v.workaround); + } } - } - patchAudioWithDevice(v.audioDevice); + patchAudioWithDevice(v.audioDevice); - resolve(v); + resolve(v); + } }} close={() => { props.onClose(); @@ -137,12 +152,26 @@ export function openScreenSharePicker(screens: Source[], skipPicker: boolean) { }); } -function ScreenPicker({ screens, chooseScreen }: { screens: Source[]; chooseScreen: (id: string) => void }) { +function ScreenPicker({ + screens, + chooseScreen, + isDisabled = false +}: { + screens: Source[]; + chooseScreen: (id: string) => void; + isDisabled?: boolean; +}) { return (
{screens.map(({ id, name, url }) => (