-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
44 lines (36 loc) · 998 Bytes
/
main.js
File metadata and controls
44 lines (36 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
let win;
function createWindow() {
win = new BrowserWindow({
width: 280,
height: 320,
alwaysOnTop: true,
frame: false,
transparent: true,
resizable: false,
skipTaskbar: false,
icon: path.join(__dirname, 'assets', 'icon.ico'),
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
nodeIntegration: false
}
});
// screen-saver level ensures it stays above PPT fullscreen
win.setAlwaysOnTop(true, 'screen-saver');
win.loadFile(path.join(__dirname, 'renderer', 'index.html'));
// Re-assert always-on-top when focus changes
win.on('blur', () => {
if (win && !win.isDestroyed()) {
win.setAlwaysOnTop(true, 'screen-saver');
}
});
}
ipcMain.on('window-close', () => {
if (win) win.close();
});
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
app.quit();
});