Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Make Element Call screensharing work on desktop #9476

Merged
merged 3 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
23 changes: 19 additions & 4 deletions src/models/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import { WidgetMessagingStore, WidgetMessagingStoreEvent } from "../stores/widge
import ActiveWidgetStore, { ActiveWidgetStoreEvent } from "../stores/ActiveWidgetStore";
import PlatformPeg from "../PlatformPeg";
import { getCurrentLanguage } from "../languageHandler";
import DesktopCapturerSourcePicker from "../components/views/elements/DesktopCapturerSourcePicker";
import Modal from "../Modal";

const TIMEOUT_MS = 16000;

Expand Down Expand Up @@ -639,10 +641,6 @@ export class ElementCall extends Call {
baseUrl: client.baseUrl,
lang: getCurrentLanguage().replace("_", "-"),
});
// Currently, the screen-sharing support is the same is it is for Jitsi
if (!PlatformPeg.get().supportsJitsiScreensharing()) {
params.append("hideScreensharing", "");
}
url.hash = `#?${params.toString()}`;

// To use Element Call without touching room state, we create a virtual
Expand Down Expand Up @@ -818,6 +816,7 @@ export class ElementCall extends Call {
this.messaging!.on(`action:${ElementWidgetActions.HangupCall}`, this.onHangup);
this.messaging!.on(`action:${ElementWidgetActions.TileLayout}`, this.onTileLayout);
this.messaging!.on(`action:${ElementWidgetActions.SpotlightLayout}`, this.onSpotlightLayout);
this.messaging!.on(`action:${ElementWidgetActions.Screenshare}`, this.onScreenshare);
SimonBrandner marked this conversation as resolved.
Show resolved Hide resolved
}

protected async performDisconnection(): Promise<void> {
Expand Down Expand Up @@ -951,4 +950,20 @@ export class ElementCall extends Call {
this.layout = Layout.Spotlight;
await this.messaging!.transport.reply(ev.detail, {}); // ack
};

private onScreenshare = async (ev: CustomEvent<IWidgetApiRequest>) => {
ev.preventDefault();

if (PlatformPeg.get().supportsDesktopCapturer()) {
const { finished } = Modal.createDialog(DesktopCapturerSourcePicker);
const [source] = await finished;

await this.messaging!.transport.reply(ev.detail, {
failed: !source,
desktopCapturerSourceId: source,
});
} else {
await this.messaging!.transport.reply(ev.detail, {});
}
};
}
1 change: 1 addition & 0 deletions src/stores/widgets/ElementWidgetActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export enum ElementWidgetActions {
// Actions for switching layouts
TileLayout = "io.element.tile_layout",
SpotlightLayout = "io.element.spotlight_layout",
Screenshare = "io.element.screenshare",

OpenIntegrationManager = "integration_manager_open",

Expand Down