Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix audio and quality settings menu on wayland #131

Merged
merged 31 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bf4c203
added the beginnings of audio support
catgirlcataclysm Sep 25, 2023
c2476a7
Merge branch 'Vencord:main' into main
catgirlcataclysm Sep 26, 2023
8ac5409
updated dependencies
catgirlcataclysm Sep 26, 2023
e902505
updated dependencies
catgirlcataclysm Sep 26, 2023
a7249ec
updated dependencies and pulled new changes from vencord/vesktop
catgirlcataclysm Sep 26, 2023
8655318
added constraints and fixed device not detected
catgirlcataclysm Sep 26, 2023
538c009
Merge branch 'Vencord:main' into main
catgirlcataclysm Sep 27, 2023
d717e9d
switched to try a different function for wayland stream control
catgirlcataclysm Sep 28, 2023
eb90500
Merge branch 'Vencord:main' into wayland-fixes
catgirlcataclysm Sep 28, 2023
bc7d802
fixed screensharing under wayland, but caused other issues by updatin…
catgirlcataclysm Sep 28, 2023
2e5c450
Merge branch 'wayland-fixes' of https://github.com/kaitlynkittyy/vesk…
catgirlcataclysm Sep 28, 2023
7847e6b
Merge branch 'Vencord:main' into main
catgirlcataclysm Sep 28, 2023
7409c65
Merge branch 'wayland-fixes' of https://github.com/kaitlynkittyy/vesk…
catgirlcataclysm Sep 28, 2023
29206b9
fixed broken merge
catgirlcataclysm Sep 28, 2023
0c8ce8e
continued to fix broken merge
catgirlcataclysm Sep 28, 2023
f1cacc5
MORE BROKEN MERGE STUFF AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaa
catgirlcataclysm Sep 28, 2023
c2e3722
more fixing
catgirlcataclysm Sep 28, 2023
5906a7e
removed stupid line from merge
catgirlcataclysm Sep 28, 2023
c4f6941
deleted more leftovers
catgirlcataclysm Sep 28, 2023
2b79ad8
removed unnecessary screensharing portal on wayland
catgirlcataclysm Sep 28, 2023
1e48f0c
Discard changes to .vscode/launch.json
catgirlcataclysm Sep 28, 2023
691997d
removed unneeded dependency
catgirlcataclysm Sep 28, 2023
5001300
fixed crash when cancelling screenshare
catgirlcataclysm Sep 28, 2023
70fbc7a
fixed package name and description in package.json
catgirlcataclysm Sep 28, 2023
5bb06ca
changed var to const
catgirlcataclysm Sep 28, 2023
de175f9
Discard changes to package.json
Vendicated Oct 3, 2023
7a6cb2e
Discard changes to src/renderer/hideGarbage.css
Vendicated Oct 3, 2023
4cda6c0
Discard changes to pnpm-lock.yaml
Vendicated Oct 3, 2023
c710f67
Merge branch 'virtmic' into wayland-fixes
Vendicated Oct 3, 2023
7313d47
fixes
Vendicated Oct 11, 2023
4aefd21
Merge branch 'virtmic' into wayland-fixes
Vendicated Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions src/main/screenShare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -23,17 +26,19 @@ export function registerScreenShareHandler() {
});

session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) => {
const sources = await desktopCapturer.getSources({
types: ["window", "screen"],
thumbnailSize: {
width: 176,
height: 99
}
});
// request full resolution on wayland right away because we always only end up with one result anyway
const width = isWayland ? 1920 : 176;
const sources = await desktopCapturer
.getSources({
types: ["window", "screen"],
thumbnailSize: {
width,
height: width * (9 / 16)
}
})
.catch(err => console.error("Error during screenshare picker", err));

const isWayland =
process.platform === "linux" &&
(process.env.XDG_SESSION_TYPE === "wayland" || !!process.env.WAYLAND_DISPLAY);
if (!sources) return callback({});

const data = sources.map(({ id, name, thumbnail }) => ({
id,
Expand All @@ -43,10 +48,14 @@ export function registerScreenShareHandler() {

if (isWayland) {
const video = data[0];
if (video)
await request.frame.executeJavaScript(
`Vesktop.Components.ScreenShare.openScreenSharePicker(${JSON.stringify([data])}, true)`
);
if (video) {
const stream = await request.frame
.executeJavaScript(
`Vesktop.Components.ScreenShare.openScreenSharePicker(${JSON.stringify([video])},true)`
)
.catch(() => null);
if (stream === null) return callback({});
}

callback(video ? { video: sources[0] } : {});
return;
Expand Down
18 changes: 12 additions & 6 deletions src/renderer/components/ScreenSharePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ addPatch({
}
});

export function openScreenSharePicker(screens: Source[], skipPicker = false) {
export function openScreenSharePicker(screens: Source[], skipPicker: boolean) {
let didSubmit = false;
return new Promise<StreamPick>((resolve, reject) => {
const key = openModal(
Expand Down Expand Up @@ -119,16 +119,21 @@ function ScreenPicker({ screens, chooseScreen }: { screens: Source[]; chooseScre
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), {
fallbackValue: source.url,
deps: [source.id]
});
const [thumb] = useAwaiter(
() => (skipPicker ? Promise.resolve(source.url) : VesktopNative.capturer.getLargeThumbnail(source.id)),
{
fallbackValue: source.url,
deps: [source.id]
}
);

return (
<div>
Expand Down Expand Up @@ -269,6 +274,7 @@ function ModalComponent({
source={screens.find(s => s.id === selected)!}
settings={settings}
setSettings={setSettings}
skipPicker={skipPicker}
/>
)}
</Modals.ModalContent>
Expand Down