mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-31 13:39:58 +01:00
Switch to IPC channel for getDesktopCapturerSources
(#320)
This commit is contained in:
parent
a80bc76e22
commit
634c5c66a6
@ -19,7 +19,17 @@ limitations under the License.
|
|||||||
|
|
||||||
// Squirrel on windows starts the app with various flags as hooks to tell us when we've been installed/uninstalled etc.
|
// Squirrel on windows starts the app with various flags as hooks to tell us when we've been installed/uninstalled etc.
|
||||||
import "./squirrelhooks";
|
import "./squirrelhooks";
|
||||||
import { app, ipcMain, powerSaveBlocker, BrowserWindow, Menu, autoUpdater, protocol, dialog } from "electron";
|
import {
|
||||||
|
app,
|
||||||
|
ipcMain,
|
||||||
|
powerSaveBlocker,
|
||||||
|
BrowserWindow,
|
||||||
|
Menu,
|
||||||
|
autoUpdater,
|
||||||
|
protocol,
|
||||||
|
dialog,
|
||||||
|
desktopCapturer,
|
||||||
|
} from "electron";
|
||||||
import AutoLaunch from "auto-launch";
|
import AutoLaunch from "auto-launch";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import windowStateKeeper from 'electron-window-state';
|
import windowStateKeeper from 'electron-window-state';
|
||||||
@ -502,6 +512,13 @@ ipcMain.on('ipcCall', async function(ev, payload) {
|
|||||||
await keytar.deletePassword("riot.im", `${args[0]}|${args[1]}`);
|
await keytar.deletePassword("riot.im", `${args[0]}|${args[1]}`);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
break;
|
break;
|
||||||
|
case 'getDesktopCapturerSources':
|
||||||
|
ret = (await desktopCapturer.getSources(args[0])).map((source) => ({
|
||||||
|
id: source.id,
|
||||||
|
name: source.name,
|
||||||
|
thumbnailURL: source.thumbnail.toDataURL(),
|
||||||
|
}));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mainWindow.webContents.send('ipcReply', {
|
mainWindow.webContents.send('ipcReply', {
|
||||||
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ipcRenderer, desktopCapturer, contextBridge, IpcRendererEvent, SourcesOptions } from 'electron';
|
import { ipcRenderer, contextBridge, IpcRendererEvent } from 'electron';
|
||||||
|
|
||||||
// Expose only expected IPC wrapper APIs to the renderer process to avoid
|
// Expose only expected IPC wrapper APIs to the renderer process to avoid
|
||||||
// handing out generalised messaging access.
|
// handing out generalised messaging access.
|
||||||
@ -36,12 +36,6 @@ const CHANNELS = [
|
|||||||
"userDownloadAction",
|
"userDownloadAction",
|
||||||
];
|
];
|
||||||
|
|
||||||
interface ISource {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
thumbnailURL: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld(
|
contextBridge.exposeInMainWorld(
|
||||||
"electron",
|
"electron",
|
||||||
{
|
{
|
||||||
@ -59,19 +53,5 @@ contextBridge.exposeInMainWorld(
|
|||||||
}
|
}
|
||||||
ipcRenderer.send(channel, ...args);
|
ipcRenderer.send(channel, ...args);
|
||||||
},
|
},
|
||||||
async getDesktopCapturerSources(options: SourcesOptions): Promise<ISource[]> {
|
|
||||||
const sources = await desktopCapturer.getSources(options);
|
|
||||||
const desktopCapturerSources: ISource[] = [];
|
|
||||||
|
|
||||||
for (const source of sources) {
|
|
||||||
desktopCapturerSources.push({
|
|
||||||
id: source.id,
|
|
||||||
name: source.name,
|
|
||||||
thumbnailURL: source.thumbnail.toDataURL(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return desktopCapturerSources;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user