[MM-58001] Fix an issue where the window position has a decimal number (#3017)

* [MM-58001] Fix an issue where the window position has a decimal number

* I accidentally a log
This commit is contained in:
Devin Binnie 2024-04-24 13:20:16 -04:00 committed by GitHub
parent 54091f3c7d
commit a6ce24d184
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View file

@ -166,6 +166,22 @@ describe('main/app/utils', () => {
resizeScreen(browserWindow);
expect(browserWindow.setPosition).toHaveBeenCalledWith(690, 410);
});
it('should never return non-integer value', () => {
MainWindow.get.mockReturnValue({
getPosition: () => [450, 350],
getSize: () => [1280, 720],
});
const browserWindow = {
getPosition: () => [450, 350],
getSize: () => [1281, 721],
setPosition: jest.fn(),
center: jest.fn(),
once: jest.fn(),
};
resizeScreen(browserWindow);
expect(browserWindow.setPosition).toHaveBeenCalledWith(449, 349);
});
});
describe('migrateMacAppStore', () => {

View file

@ -155,8 +155,8 @@ function getNewWindowPosition(browserWindow: BrowserWindow) {
const mainWindowPosition = mainWindow.getPosition();
return [
mainWindowPosition[0] + ((mainWindowSize[0] - newWindowSize[0]) / 2),
mainWindowPosition[1] + ((mainWindowSize[1] - newWindowSize[1]) / 2),
Math.floor(mainWindowPosition[0] + ((mainWindowSize[0] - newWindowSize[0]) / 2)),
Math.floor(mainWindowPosition[1] + ((mainWindowSize[1] - newWindowSize[1]) / 2)),
];
}