Files
Simon Hofmann 49f146494e Bugfix/559/limit window region to main screen dimensions (#561)
* (#559) Adjust getRegion implementation

It’ll now cut off window regions at the borders of the main screen, avoiding errors due to out of bounds regions

* (#559) Moved window e2e test into dedicated e2e subpackage
2024-02-16 23:41:54 +01:00

38 lines
874 B
JavaScript

const { app, ipcMain, BrowserWindow } = require("electron");
const path = require("path");
const { POS_X, POS_Y, WIDTH, HEIGHT } = require("./constants");
function createWindow() {
const mainWindow = new BrowserWindow({
width: WIDTH,
height: HEIGHT,
alwaysOnTop: true,
webPreferences: {
nodeIntegration: true,
preload: path.join(__dirname, "preload.js"),
},
});
mainWindow.loadFile(path.join(__dirname, "index.html"));
mainWindow.setPosition(POS_X, POS_Y);
}
ipcMain.on("main", (event, args) => {
if (args === "quit") {
app.quit();
}
});
app.whenReady().then(() => {
setTimeout(() => app.exit(1), 15000);
createWindow();
app.on("activate", function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on("window-all-closed", function () {
console.log("Bye!");
app.quit();
});