removed unnecessary screensharing portal on wayland

This commit is contained in:
Kaitlyn 2023-09-28 16:20:06 -04:00
parent c4f6941ea6
commit 2b79ad8389
2 changed files with 30 additions and 18 deletions

View file

@ -10,6 +10,9 @@ import { IpcEvents } from "shared/IpcEvents";
import { handle } from "./utils/ipcWrappers";
const isWayland =
process.platform === "linux" && (process.env.XDG_SESSION_TYPE === "wayland" || !!process.env.WAYLAND_DISPLAY);
export function registerScreenShareHandler() {
handle(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, async (_, id: string) => {
const sources = await desktopCapturer.getSources({
@ -23,20 +26,23 @@ export function registerScreenShareHandler() {
});
session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) => {
const sources = await desktopCapturer.getSources({
const sources = await desktopCapturer
.getSources({
types: ["window", "screen"],
thumbnailSize: {
thumbnailSize: isWayland
? {
width: 1920,
height: 1080
}
: {
width: 176,
height: 99
}
}).catch(() => null);
})
.catch(() => null);
if (sources === null) return callback({});
const isWayland =
process.platform === "linux" &&
(process.env.XDG_SESSION_TYPE === "wayland" || !!process.env.WAYLAND_DISPLAY);
const data = sources.map(({ id, name, thumbnail }) => ({
id,
name,

View file

@ -116,19 +116,24 @@ function ScreenPicker({ screens, chooseScreen }: { screens: Source[]; chooseScre
);
}
export function StreamSettings({
function StreamSettings({
source,
settings,
setSettings
setSettings,
skipPicker
}: {
source: Source;
settings: StreamSettings;
setSettings: Dispatch<SetStateAction<StreamSettings>>;
skipPicker: boolean;
}) {
const [thumb] = useAwaiter(() => VesktopNative.capturer.getLargeThumbnail(source.id), {
const [thumb] = useAwaiter(
() => (skipPicker ? Promise.resolve(source.url) : VesktopNative.capturer.getLargeThumbnail(source.id)),
{
fallbackValue: source.url,
deps: [source.id]
});
}
);
return (
<div>
@ -269,6 +274,7 @@ function ModalComponent({
source={screens.find(s => s.id === selected)!}
settings={settings}
setSettings={setSettings}
skipPicker={skipPicker}
/>
)}
</Modals.ModalContent>