Workaround Linux Wayland screenshare bug
This commit is contained in:
parent
944a70abe7
commit
d7da7fdca0
3 changed files with 29 additions and 8 deletions
17
app/main.ts
17
app/main.ts
|
@ -2630,13 +2630,16 @@ ipc.handle('show-save-dialog', async (_event, { defaultPath }) => {
|
|||
return { canceled: false, filePath: finalFilePath };
|
||||
});
|
||||
|
||||
ipc.handle('getScreenCaptureSources', async () => {
|
||||
return desktopCapturer.getSources({
|
||||
fetchWindowIcons: true,
|
||||
thumbnailSize: { height: 102, width: 184 },
|
||||
types: ['window', 'screen'],
|
||||
});
|
||||
});
|
||||
ipc.handle(
|
||||
'getScreenCaptureSources',
|
||||
async (_event, types: Array<'screen' | 'window'> = ['screen', 'window']) => {
|
||||
return desktopCapturer.getSources({
|
||||
fetchWindowIcons: true,
|
||||
thumbnailSize: { height: 102, width: 184 },
|
||||
types,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
ipc.handle('executeMenuRole', async ({ sender }, untypedRole) => {
|
||||
const role = untypedRole as MenuItemConstructorOptions['role'];
|
||||
|
|
|
@ -95,6 +95,7 @@ import {
|
|||
import { callingMessageToProto } from '../util/callingMessageToProto';
|
||||
import { getSendOptions } from '../util/getSendOptions';
|
||||
import { requestMicrophonePermissions } from '../util/requestMicrophonePermissions';
|
||||
import OS from '../util/os/osMain';
|
||||
import { SignalService as Proto } from '../protobuf';
|
||||
import dataInterface from '../sql/Client';
|
||||
import {
|
||||
|
@ -1329,8 +1330,20 @@ export class CallingClass {
|
|||
}
|
||||
|
||||
async getPresentingSources(): Promise<Array<PresentableSource>> {
|
||||
// There's a Linux Wayland Electron bug where requesting desktopCapturer.
|
||||
// getSources() with types as ['screen', 'window'] (the default) pops 2
|
||||
// OS permissions dialogs in an unusable state (Dialog 1 for Share Window
|
||||
// is the foreground and ignores input; Dialog 2 for Share Screen is background
|
||||
// and requires input. As a workaround, request both sources sequentially.
|
||||
// https://github.com/signalapp/Signal-Desktop/issues/5350#issuecomment-1688614149
|
||||
const sources: ReadonlyArray<DesktopCapturerSource> =
|
||||
await ipcRenderer.invoke('getScreenCaptureSources');
|
||||
OS.isLinux() && OS.isWaylandEnabled()
|
||||
? (
|
||||
await ipcRenderer.invoke('getScreenCaptureSources', ['screen'])
|
||||
).concat(
|
||||
await ipcRenderer.invoke('getScreenCaptureSources', ['window'])
|
||||
)
|
||||
: await ipcRenderer.invoke('getScreenCaptureSources');
|
||||
|
||||
const presentableSources: Array<PresentableSource> = [];
|
||||
|
||||
|
|
|
@ -19,9 +19,14 @@ function getLinuxName(): string | undefined {
|
|||
return match[1];
|
||||
}
|
||||
|
||||
function isWaylandEnabled(): boolean {
|
||||
return Boolean(process.env.WAYLAND_DISPLAY);
|
||||
}
|
||||
|
||||
const OS = {
|
||||
...getOSFunctions(os.release()),
|
||||
getLinuxName,
|
||||
isWaylandEnabled,
|
||||
};
|
||||
|
||||
export default OS;
|
||||
|
|
Loading…
Reference in a new issue