Align fullscreen return button with project actions

This commit is contained in:
鲨鱼辣椒 committed 2026-09-30 00:58:46 +08:00
1 parent 80b0cb99a8
commit 343f88ce59
9 files changed
+203 -7

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
import { ipcMain, type BrowserWindow } from 'electron';
export function registerWindowFullscreenHandlers(
requireWindow: (event: Electron.IpcMainInvokeEvent) => BrowserWindow,
): (window: BrowserWindow) => void {
ipcMain.handle('window:isFullScreen', (event) => requireWindow(event).isFullScreen());
const boundWindows = new WeakSet<BrowserWindow>();
return (window: BrowserWindow): void => {
if (window.isDestroyed() || window.webContents.isDestroyed() || boundWindows.has(window)) return;
boundWindows.add(window);
const notify = (fullscreen: boolean): void => {
if (window.isDestroyed() || window.webContents.isDestroyed()) return;
window.webContents.send('window:fullscreen-changed', fullscreen);
};
window.on('enter-full-screen', () => notify(true));
window.on('leave-full-screen', () => notify(false));
};
}