-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
53 lines (44 loc) · 1.29 KB
/
main.js
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
const { app, BrowserWindow, ipcMain } = require("electron");
function createWindow() {
let win = new BrowserWindow({
frame: false,
alwaysOnTop: true,
transparent: true,
skipTaskbar: true,
opacity: 0.8,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});
win.loadFile("index.html");
ipcMain.on(
"resize",
function (e, targetSizeX, targetSizeY, anchorRight, anchorBottom) {
if (anchorRight == true || anchorBottom == true) {
var targetPosX;
var targetPosY;
var [originalPosX, originalPosY] = win.getPosition();
var [originalSizeX, originalSizeY] = win.getSize();
if (anchorRight == true) {
targetPosX = originalPosX + (originalSizeX - targetSizeX);
} else {
targetPosX = originalPosX;
}
if (anchorBottom == true) {
targetPosY = originalPosY + (originalSizeY - targetSizeY);
} else {
targetPosY = originalPosY;
}
win.setPosition(targetPosX, targetPosY);
}
win.setContentSize(targetSizeX, targetSizeY);
}
);
ipcMain.on("quit", function () {
app.quit();
});
// Open dev tools in separate window.
// win.webContents.openDevTools({mode:'undocked'});
}
app.on("ready", createWindow);