mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Tweak screensharing
This commit is contained in:
parent
8e16371521
commit
334d28542f
2 changed files with 32 additions and 35 deletions
|
@ -2,6 +2,7 @@ import {BrowserWindow, desktopCapturer, ipcMain, session, shell} from "electron"
|
|||
import path from "path";
|
||||
import {iconPath} from "../main";
|
||||
var capturerWindow: BrowserWindow;
|
||||
function registerCustomHandler() {
|
||||
session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) => {
|
||||
const sources = await desktopCapturer.getSources({
|
||||
types: ["screen", "window"]
|
||||
|
@ -21,17 +22,15 @@ session.defaultSession.setDisplayMediaRequestHandler(async (request, callback) =
|
|||
preload: path.join(__dirname, "preload.js")
|
||||
}
|
||||
});
|
||||
ipcMain.on("selectScreenshareSource", (event, id, name) => {
|
||||
ipcMain.once("selectScreenshareSource", (event, id, name) => {
|
||||
console.log(sources[id]);
|
||||
console.log(id);
|
||||
callback({video: {id, name}});
|
||||
|
||||
capturerWindow.close();
|
||||
});
|
||||
capturerWindow.webContents.setWindowOpenHandler(({url}) => {
|
||||
shell.openExternal(url);
|
||||
return {action: "deny"};
|
||||
var result = {id, name};
|
||||
callback({video: result});
|
||||
});
|
||||
capturerWindow.loadURL(`file://${__dirname}/picker.html`);
|
||||
capturerWindow.webContents.send("getSources", sources);
|
||||
});
|
||||
}
|
||||
registerCustomHandler();
|
||||
|
|
|
@ -5,7 +5,7 @@ interface IPCSources {
|
|||
thumbnail: HTMLCanvasElement;
|
||||
}
|
||||
async function addDisplays() {
|
||||
ipcRenderer.on("getSources", (event, arg) => {
|
||||
ipcRenderer.once("getSources", (event, arg) => {
|
||||
var sources: IPCSources[] = arg;
|
||||
console.log(sources);
|
||||
const selectionElem = document.createElement("div");
|
||||
|
@ -45,8 +45,6 @@ async function addDisplays() {
|
|||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
} finally {
|
||||
ipcRenderer.sendSync("closeScreenshareWindow");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue