feat: Send the application image with the screenpicker hook

Signed-off-by: Jacob Schlecht <dadadah@echoha.us>
This commit is contained in:
Jacob Schlecht 2026-04-17 21:57:09 -06:00
parent 45b949e1ae
commit 7f8f0646a5
2 changed files with 16 additions and 2 deletions

View File

@ -221,10 +221,19 @@ export function createMainWindow() {
mainWindow.webContents.send( mainWindow.webContents.send(
"screenPicker", "screenPicker",
sources.map((source, idx) => { sources.map((source, idx) => {
const image = source.appIcon;
if (image) {
if (image.getAspectRatio() > 1) {
image.resize({ width: 256 });
} else {
image.resize({ height: 256 });
}
}
return { return {
idx: idx, idx: idx,
isFullScreen: source.id.startsWith("screen"),
name: source.name, name: source.name,
isFullScreen: source.id.startsWith("screen"),
image: image?.toDataURL(),
}; };
}), }),
); );

View File

@ -19,7 +19,12 @@ contextBridge.exposeInMainWorld("native", {
// Wrapped in braces to return void // Wrapped in braces to return void
onceScreenPicker: ( onceScreenPicker: (
onScreenPick: ( onScreenPick: (
sources: { idx: number; isFullScreen: boolean; name: string }[], sources: {
idx: number;
name: string;
isFullScreen: boolean;
image?: string;
}[],
) => void, ) => void,
) => { ) => {
ipcRenderer.once("screenPicker", (_, sources) => onScreenPick(sources)); ipcRenderer.once("screenPicker", (_, sources) => onScreenPick(sources));