Skip to content

Commit 662f4b2

Browse files
Update electron window management
1 parent 96bffc1 commit 662f4b2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

electron/main/ui/window.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export function createWindow(rendererURL: string) {
2020
visualEffectState: 'active',
2121
webPreferences: {
2222
preload: path.join(app.getAppPath(), 'build', 'electron', 'preload', 'index.cjs'),
23+
nodeIntegration: false,
24+
contextIsolation: true,
25+
backgroundThrottling: false,
26+
offscreen: false,
2327
},
2428
});
2529

@@ -41,9 +45,17 @@ export function createWindow(rendererURL: string) {
4145
win.webContents.openDevTools();
4246
}
4347

48+
// Debounce window bounds saving to prevent excessive disk writes
49+
let boundsTimeout: NodeJS.Timeout | null = null;
4450
const boundsListener = () => {
45-
const bounds = win.getBounds();
46-
store.set('bounds', bounds);
51+
if (boundsTimeout) {
52+
clearTimeout(boundsTimeout);
53+
}
54+
boundsTimeout = setTimeout(() => {
55+
const bounds = win.getBounds();
56+
store.set('bounds', bounds);
57+
boundsTimeout = null;
58+
}, 500);
4759
};
4860
win.on('moved', boundsListener);
4961
win.on('resized', boundsListener);

0 commit comments

Comments
 (0)