forked from processing/processing4
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
57 lines (47 loc) · 1.29 KB
/
main.js
File metadata and controls
57 lines (47 loc) · 1.29 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
const path = require('node:path');
const { app, BrowserWindow, globalShortcut, ipcMain } = require('electron');
const createWindow = () => {
const win = new BrowserWindow({
width: 400,
height: 400,
show: false,
fullscreen: process.env.PRESENT == "true",
fullscreenable: true,
autoHideMenuBar: true,
alwaysOnTop: false,
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
preload: path.join(__dirname, "preload.js")
}
});
win.loadFile('electron/index.html');
// Register the 'Escape' key shortcut
globalShortcut.register('Escape', () => {
win.close();
});
// Unregister the shortcut when window is closed
win.on('closed', () => {
globalShortcut.unregister('Escape');
});
return win;
}
app.on('window-all-closed', () => {
// Unregister all shortcuts when app is closing
globalShortcut.unregisterAll();
app.quit();
});
app.whenReady().then(() => {
const win = createWindow();
// Allow all devices to be connected to
win.webContents.session.setDevicePermissionHandler((details) => {
return true
})
ipcMain.on("send-message", (event, message) => {
console.log(message);
});
ipcMain.on("resize", (event, {width, height}) => {
win.setContentSize(width, height);
win.show();
});
});