fix throwing error screen before loading update
This commit is contained in:
@@ -108,22 +108,29 @@ export function foundationIpcRegistration(mainWindow: BrowserWindow) {
|
||||
});
|
||||
|
||||
ipcMain.on('window-resize', (_, { width, height }) => {
|
||||
const { x: currentX, y: currentY, width: currentWidth, height: currentHeight } = mainWindow.getBounds();
|
||||
const { x: currentX, y: currentY } = mainWindow.getBounds();
|
||||
|
||||
const newX = currentX + (currentWidth - width) / 2;
|
||||
const newY = currentY + (currentHeight - height) / 2;
|
||||
const display = screen.getDisplayMatching(mainWindow.getBounds());
|
||||
const displayBounds = display.workArea;
|
||||
|
||||
const { width: screenWidth, height: screenHeight } = screen.getPrimaryDisplay().workAreaSize;
|
||||
let newX = currentX;
|
||||
let newY = currentY;
|
||||
|
||||
const clampedX = Math.max(0, Math.min(newX, screenWidth - width));
|
||||
//const clampedY = Math.max(0, Math.min(newY, screenHeight - height));
|
||||
if (currentX + width > displayBounds.x + displayBounds.width) {
|
||||
newX = displayBounds.x + displayBounds.width - width;
|
||||
}
|
||||
|
||||
if (currentY + height > displayBounds.y + displayBounds.height) {
|
||||
newY = displayBounds.y + displayBounds.height - height;
|
||||
}
|
||||
|
||||
mainWindow.setBounds({
|
||||
x: Math.round(clampedX),
|
||||
//y: Math.round(clampedY),
|
||||
width,
|
||||
height,
|
||||
x: newX,
|
||||
y: newY,
|
||||
width: width,
|
||||
height: height
|
||||
});
|
||||
mainWindow.webContents.send('window-state-changed');
|
||||
});
|
||||
|
||||
ipcMain.on('window-resizeble', (_, isResizeble) => {
|
||||
|
||||
Reference in New Issue
Block a user