Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions electron/electron-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ interface Window {
error?: string;
};
}>;
openNotes: () => Promise<{
opened: boolean;
reason?: string;
}>;
selectSource: (source: ProcessedDesktopSource) => Promise<ProcessedDesktopSource | null>;
getSelectedSource: () => Promise<ProcessedDesktopSource | null>;
onSelectedSourceChanged: (callback: (source: ProcessedDesktopSource) => void) => () => void;
Expand Down
13 changes: 13 additions & 0 deletions electron/ipc/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1280,8 +1280,10 @@ export function registerIpcHandlers(
createEditorWindow: () => void,
createSourceSelectorWindow: () => BrowserWindow,
createCountdownOverlayWindow: () => BrowserWindow,
createNotesWindowWrapper: () => BrowserWindow,
getMainWindow: () => BrowserWindow | null,
getSourceSelectorWindow: () => BrowserWindow | null,
getNotesWindow: () => BrowserWindow | null,
getCountdownOverlayWindow?: () => BrowserWindow | null,
onRecordingStateChange?: (recording: boolean, sourceName: string) => void,
_switchToHud?: () => void,
Expand Down Expand Up @@ -1479,6 +1481,17 @@ export function registerIpcHandlers(
return { opened: true };
});

ipcMain.handle("open-notes", async () => {
const notesSelectorWin = getNotesWindow();
if (notesSelectorWin) {
notesSelectorWin.focus();
return { opened: true };
}

createNotesWindowWrapper();
return { opened: true };
});

ipcMain.handle("switch-to-editor", () => {
// createEditorWindow already closes the current mainWindow (the HUD) before
// opening the editor. Closing it here too double-closes, leaving ghost
Expand Down
17 changes: 17 additions & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
createCountdownOverlayWindow,
createEditorWindow,
createHudOverlayWindow,
createNotesWindow,
createSourceSelectorWindow,
} from "./windows";

Expand Down Expand Up @@ -84,6 +85,7 @@ process.env.VITE_PUBLIC = VITE_DEV_SERVER_URL
let mainWindow: BrowserWindow | null = null;
let sourceSelectorWindow: BrowserWindow | null = null;
let countdownOverlayWindow: BrowserWindow | null = null;
let notesWindow: BrowserWindow | null = null;
let tray: Tray | null = null;
let selectedSourceName = "";
const isMac = process.platform === "darwin";
Expand Down Expand Up @@ -437,6 +439,19 @@ function createSourceSelectorWindowWrapper() {
return sourceSelectorWindow;
}

function createNotesWindowWrapper() {
{
notesWindow = createNotesWindow();
notesWindow.on("closed", () => {
notesWindow = null;
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.webContents.send("notes-window-closed");
}
});
return notesWindow;
}
}

function createCountdownOverlayWindowWrapper() {
if (countdownOverlayWindow && !countdownOverlayWindow.isDestroyed()) {
return countdownOverlayWindow;
Expand Down Expand Up @@ -575,8 +590,10 @@ appReady?.then(async () => {
createEditorWindowWrapper,
createSourceSelectorWindowWrapper,
createCountdownOverlayWindowWrapper,
createNotesWindowWrapper,
() => mainWindow,
() => sourceSelectorWindow,
() => notesWindow,
() => countdownOverlayWindow,
(recording: boolean, sourceName: string) => {
selectedSourceName = sourceName;
Expand Down
3 changes: 3 additions & 0 deletions electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ contextBridge.exposeInMainWorld("electronAPI", {
openSourceSelector: () => {
return ipcRenderer.invoke("open-source-selector");
},
openNotes: () => {
return ipcRenderer.invoke("open-notes");
},
selectSource: (source: ProcessedDesktopSource) => {
return ipcRenderer.invoke("select-source", source);
},
Expand Down
41 changes: 41 additions & 0 deletions electron/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,44 @@ export function createCountdownOverlayWindow(): BrowserWindow {

return win;
}

// Frameless Notes Window for taking notes during a recording.
export function createNotesWindow(): BrowserWindow {
const win = new BrowserWindow({
width: 400,
height: 540,
minWidth: 360,
minHeight: 400,
maxWidth: 640,
maxHeight: 720,
title: "OpenScreen - Notes",
backgroundColor: "#09090b",
resizable: true,
alwaysOnTop: true,
skipTaskbar: false,
show: false,
webPreferences: {
preload: path.join(__dirname, "preload.mjs"),
additionalArguments: [ASSET_BASE_URL_ARG],
nodeIntegration: false,
contextIsolation: true,
backgroundThrottling: false,
},
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.

win.setContentProtection(true);
win.once("ready-to-show", () => {
win.setContentProtection(true);
win.show();
});

if (VITE_DEV_SERVER_URL) {
win.loadURL(VITE_DEV_SERVER_URL + "?showNotes=true");
} else {
win.loadFile(path.join(RENDERER_DIST, "index.html"), {
query: { showNotes: "true" },
});
}

return win;
}
Loading
Loading