mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Add a way to enable legacy capturer
This commit is contained in:
parent
2dec7c21dc
commit
09fcd77803
9 changed files with 68 additions and 40 deletions
|
@ -26,6 +26,8 @@
|
||||||
"settings-startMinimized": "Start minimized",
|
"settings-startMinimized": "Start minimized",
|
||||||
"settings-startMinimized-desc": "ArmCord starts in background and remains out of your way.",
|
"settings-startMinimized-desc": "ArmCord starts in background and remains out of your way.",
|
||||||
"settings-patches": "Automatic Patches",
|
"settings-patches": "Automatic Patches",
|
||||||
|
"settings-useLegacyCapturer": "Use legacy capturer",
|
||||||
|
"settings-useLegacyCapturer-desc": "Use legacy screenshare module, instead of the new one. If you're experiencing issues with screen sharing, try enabling this.",
|
||||||
"settings-patches-desk": "Fetches automatic patches that are distributed if release turns out to have bugs after release. Usually\n you don't have to keep this enabled, unless notified in support Discord.",
|
"settings-patches-desk": "Fetches automatic patches that are distributed if release turns out to have bugs after release. Usually\n you don't have to keep this enabled, unless notified in support Discord.",
|
||||||
"settings-mobileMode": "Mobile mode",
|
"settings-mobileMode": "Mobile mode",
|
||||||
"settings-mobileMode-desc": "If you're on a device with touch-screen this feature is for you! It activates Discord's hidden mobile\n mode meant for phones and tablets. Only major feature missing is voice chat support. This is ideal for\n users on PinePhone and similar.",
|
"settings-mobileMode-desc": "If you're on a device with touch-screen this feature is for you! It activates Discord's hidden mobile\n mode meant for phones and tablets. Only major feature missing is voice chat support. This is ideal for\n users on PinePhone and similar.",
|
||||||
|
|
|
@ -120,6 +120,7 @@
|
||||||
alternativePaste: false,
|
alternativePaste: false,
|
||||||
automaticPatches: false,
|
automaticPatches: false,
|
||||||
mods: "none",
|
mods: "none",
|
||||||
|
useLegacyCapturer: false,
|
||||||
inviteWebsocket: true,
|
inviteWebsocket: true,
|
||||||
mobileMode: false,
|
mobileMode: false,
|
||||||
trayIcon: "default",
|
trayIcon: "default",
|
||||||
|
@ -154,6 +155,7 @@
|
||||||
mobileMode: false,
|
mobileMode: false,
|
||||||
automaticPatches: false,
|
automaticPatches: false,
|
||||||
performanceMode: "none",
|
performanceMode: "none",
|
||||||
|
useLegacyCapturer: false,
|
||||||
alternativePaste: false,
|
alternativePaste: false,
|
||||||
disableAutogain: false,
|
disableAutogain: false,
|
||||||
startMinimized: false,
|
startMinimized: false,
|
||||||
|
@ -173,6 +175,7 @@
|
||||||
mobileMode: false,
|
mobileMode: false,
|
||||||
disableAutogain: false,
|
disableAutogain: false,
|
||||||
mods: "none",
|
mods: "none",
|
||||||
|
useLegacyCapturer: false,
|
||||||
startMinimized: false,
|
startMinimized: false,
|
||||||
alternativePaste: false,
|
alternativePaste: false,
|
||||||
performanceMode: "none",
|
performanceMode: "none",
|
||||||
|
|
|
@ -118,6 +118,9 @@ export function registerIpc() {
|
||||||
ipcMain.on("clientmod", async (event, arg) => {
|
ipcMain.on("clientmod", async (event, arg) => {
|
||||||
event.returnValue = await getConfig("mods");
|
event.returnValue = await getConfig("mods");
|
||||||
});
|
});
|
||||||
|
ipcMain.on("legacyCapturer", async (event, arg) => {
|
||||||
|
event.returnValue = await getConfig("useLegacyCapturer");
|
||||||
|
});
|
||||||
ipcMain.on("trayIcon", async (event, arg) => {
|
ipcMain.on("trayIcon", async (event, arg) => {
|
||||||
event.returnValue = await getConfig("trayIcon");
|
event.returnValue = await getConfig("trayIcon");
|
||||||
});
|
});
|
||||||
|
@ -143,4 +146,5 @@ export function registerIpc() {
|
||||||
event.returnValue = false;
|
event.returnValue = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
ipcMain.handle("DESKTOP_CAPTURER_GET_SOURCES", (event, opts) => desktopCapturer.getSources(opts));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,40 @@
|
||||||
import {contextBridge, ipcRenderer} from "electron";
|
import {contextBridge, ipcRenderer} from "electron";
|
||||||
import {injectTitlebar} from "./titlebar";
|
import {injectTitlebar} from "./titlebar";
|
||||||
|
const CANCEL_ID = "desktop-capturer-selection__cancel";
|
||||||
|
const desktopCapturer = {
|
||||||
|
getSources: (opts: any) => ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES", opts)
|
||||||
|
};
|
||||||
|
interface IPCSources {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
thumbnail: HTMLCanvasElement;
|
||||||
|
}
|
||||||
|
async function getDisplayMediaSelector() {
|
||||||
|
const sources: IPCSources[] = await desktopCapturer.getSources({
|
||||||
|
types: ["screen", "window"]
|
||||||
|
});
|
||||||
|
return `<div class="desktop-capturer-selection__scroller">
|
||||||
|
<ul class="desktop-capturer-selection__list">
|
||||||
|
${sources
|
||||||
|
.map(
|
||||||
|
({id, name, thumbnail}) => `
|
||||||
|
<li class="desktop-capturer-selection__item">
|
||||||
|
<button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}">
|
||||||
|
<img class="desktop-capturer-selection__thumbnail" src="${thumbnail.toDataURL()}" />
|
||||||
|
<span class="desktop-capturer-selection__name">${name}</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
`
|
||||||
|
)
|
||||||
|
.join("")}
|
||||||
|
<li class="desktop-capturer-selection__item">
|
||||||
|
<button class="desktop-capturer-selection__btn" data-id="${CANCEL_ID}" title="Cancel">
|
||||||
|
<span class="desktop-capturer-selection__name desktop-capturer-selection__name--cancel">Cancel</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
contextBridge.exposeInMainWorld("armcord", {
|
contextBridge.exposeInMainWorld("armcord", {
|
||||||
window: {
|
window: {
|
||||||
show: () => ipcRenderer.send("win-show"),
|
show: () => ipcRenderer.send("win-show"),
|
||||||
|
@ -20,6 +54,7 @@ contextBridge.exposeInMainWorld("armcord", {
|
||||||
ipcRenderer.invoke("getLang", toGet).then((result) => {
|
ipcRenderer.invoke("getLang", toGet).then((result) => {
|
||||||
return result;
|
return result;
|
||||||
}),
|
}),
|
||||||
|
getDisplayMediaSelector: getDisplayMediaSelector,
|
||||||
version: ipcRenderer.sendSync("get-app-version", "app-version"),
|
version: ipcRenderer.sendSync("get-app-version", "app-version"),
|
||||||
mods: ipcRenderer.sendSync("clientmod"),
|
mods: ipcRenderer.sendSync("clientmod"),
|
||||||
packageVersion: ipcRenderer.sendSync("get-package-version", "app-version"),
|
packageVersion: ipcRenderer.sendSync("get-package-version", "app-version"),
|
||||||
|
|
|
@ -1,47 +1,11 @@
|
||||||
//Fixed context isolation version https://github.com/getferdi/ferdi/blob/develop/src/webview/screenshare.ts
|
//Fixed context isolation version https://github.com/getferdi/ferdi/blob/develop/src/webview/screenshare.ts
|
||||||
//original https://github.com/electron/electron/issues/16513#issuecomment-602070250
|
//original https://github.com/electron/electron/issues/16513#issuecomment-602070250
|
||||||
import {ipcRenderer} from "electron";
|
|
||||||
import {addStyle, addScript} from "../utils";
|
import {addStyle, addScript} from "../utils";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
const desktopCapturer = {
|
|
||||||
getSources: (opts: any) => ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES", opts)
|
|
||||||
};
|
|
||||||
const CANCEL_ID = "desktop-capturer-selection__cancel";
|
const CANCEL_ID = "desktop-capturer-selection__cancel";
|
||||||
|
|
||||||
interface IPCSources {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
thumbnail: HTMLCanvasElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getDisplayMediaSelector() {
|
|
||||||
const sources: IPCSources[] = await desktopCapturer.getSources({
|
|
||||||
types: ["screen", "window"]
|
|
||||||
});
|
|
||||||
return `<div class="desktop-capturer-selection__scroller">
|
|
||||||
<ul class="desktop-capturer-selection__list">
|
|
||||||
${sources
|
|
||||||
.map(
|
|
||||||
({id, name, thumbnail}) => `
|
|
||||||
<li class="desktop-capturer-selection__item">
|
|
||||||
<button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}">
|
|
||||||
<img class="desktop-capturer-selection__thumbnail" src="${thumbnail.toDataURL()}" />
|
|
||||||
<span class="desktop-capturer-selection__name">${name}</span>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
`
|
|
||||||
)
|
|
||||||
.join("")}
|
|
||||||
<li class="desktop-capturer-selection__item">
|
|
||||||
<button class="desktop-capturer-selection__btn" data-id="${CANCEL_ID}" title="Cancel">
|
|
||||||
<span class="desktop-capturer-selection__name desktop-capturer-selection__name--cancel">Cancel</span>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const screenShareJS = `
|
const screenShareJS = `
|
||||||
window.navigator.mediaDevices.getDisplayMedia = () => new Promise(async (resolve, reject) => {
|
window.navigator.mediaDevices.getDisplayMedia = () => new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import {ipcRenderer} from "electron";
|
import {ipcRenderer} from "electron";
|
||||||
import "./bridge";
|
import "./bridge";
|
||||||
//import "./capturer";
|
|
||||||
import "./patch";
|
import "./patch";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
@ -8,6 +7,10 @@ import {fixTitlebar, injectTitlebar} from "./titlebar";
|
||||||
import {sleep, addStyle, addScript} from "../utils";
|
import {sleep, addStyle, addScript} from "../utils";
|
||||||
import {injectMobileStuff} from "./mobile";
|
import {injectMobileStuff} from "./mobile";
|
||||||
window.localStorage.setItem("hideNag", "true");
|
window.localStorage.setItem("hideNag", "true");
|
||||||
|
if (ipcRenderer.sendSync("legacyCapturer")) {
|
||||||
|
console.warn("Using legacy capturer module");
|
||||||
|
import("./capturer");
|
||||||
|
}
|
||||||
var version = ipcRenderer.sendSync("displayVersion");
|
var version = ipcRenderer.sendSync("displayVersion");
|
||||||
var channel = ipcRenderer.sendSync("channel");
|
var channel = ipcRenderer.sendSync("channel");
|
||||||
async function updateLang() {
|
async function updateLang() {
|
||||||
|
|
|
@ -191,6 +191,18 @@
|
||||||
<p data-string="settings-skipSplash-desc" class="description"></p>
|
<p data-string="settings-skipSplash-desc" class="description"></p>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
<div>
|
||||||
|
<label class="header" data-string="settings-useLegacyCapturer"></label>
|
||||||
|
<input
|
||||||
|
id="useLegacyCapturer"
|
||||||
|
class="tgl tgl-light left"
|
||||||
|
data-setting="useLegacyCapturer"
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
<label class="tgl-btn left" for="useLegacyCapturer"></label>
|
||||||
|
<p data-string="settings-useLegacyCapturer-desc" class="description"></p>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
<button data-string="settings-pluginsFolder" data-open="Plugins" class="center"></button>
|
<button data-string="settings-pluginsFolder" data-open="Plugins" class="center"></button>
|
||||||
<br />
|
<br />
|
||||||
<button data-string="settings-themesFolder" data-open="Themes" class="center"></button>
|
<button data-string="settings-themesFolder" data-open="Themes" class="center"></button>
|
||||||
|
|
|
@ -51,6 +51,7 @@ export function setup() {
|
||||||
inviteWebsocket: true,
|
inviteWebsocket: true,
|
||||||
startMinimized: false,
|
startMinimized: false,
|
||||||
disableAutogain: false,
|
disableAutogain: false,
|
||||||
|
useLegacyCapturer: false,
|
||||||
mobileMode: false,
|
mobileMode: false,
|
||||||
trayIcon: "default",
|
trayIcon: "default",
|
||||||
doneSetup: false
|
doneSetup: false
|
||||||
|
@ -244,6 +245,7 @@ export interface Settings {
|
||||||
skipSplash: boolean;
|
skipSplash: boolean;
|
||||||
performanceMode: string;
|
performanceMode: string;
|
||||||
startMinimized: boolean;
|
startMinimized: boolean;
|
||||||
|
useLegacyCapturer: boolean;
|
||||||
inviteWebsocket: boolean;
|
inviteWebsocket: boolean;
|
||||||
disableAutogain: boolean;
|
disableAutogain: boolean;
|
||||||
trayIcon: string;
|
trayIcon: string;
|
||||||
|
|
|
@ -130,7 +130,10 @@ async function doAfterDefiningTheWindow() {
|
||||||
}
|
}
|
||||||
return {action: "deny"};
|
return {action: "deny"};
|
||||||
});
|
});
|
||||||
import("./screenshare/main");
|
if ((await getConfig("useLegacyCapturer")) == false) {
|
||||||
|
console.log("Starting screenshare module...");
|
||||||
|
import("./screenshare/main");
|
||||||
|
}
|
||||||
mainWindow.webContents.session.webRequest.onBeforeRequest((details, callback) => {
|
mainWindow.webContents.session.webRequest.onBeforeRequest((details, callback) => {
|
||||||
if (/api\/v\d\/science$/g.test(details.url)) return callback({cancel: true});
|
if (/api\/v\d\/science$/g.test(details.url)) return callback({cancel: true});
|
||||||
return callback({});
|
return callback({});
|
||||||
|
|
Loading…
Reference in a new issue