import { screen } from "electron"; export default function setWindowBouns(window) { let { x, y, width, height } = window.getBounds(); const { width: screenWidth, height: screenHeight } = screen.getPrimaryDisplay().size; const maxX = screenWidth - width - 1; const maxY = screenHeight - height - 1; if (x > maxX) { x = maxX; } else if (x < 0) { x = 0; } if (y > maxY) { y = maxY; } else if (y < 0) { y = 0; } if (width > screenWidth) { width = screenWidth; } if (height > screenHeight) { height = screenHeight; } window.setPosition(x, y); return { x, y, width, height }; }