Skip to content

Commit

Permalink
🐛 restore triggers handleMainWindowResize
Browse files Browse the repository at this point in the history
Allows startMinimized to work properly on Windows

Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Mar 8, 2024
1 parent c21c1b0 commit d3ce65c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/main/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,23 @@ describe('Main module test suite', () => {
expect(settingsModule.updateSettings).toHaveBeenCalledWith({width: 13, height: 37});
});
});
describe('restore (required for windows when starting minimized)', () => {
let mockAppMenu;
beforeEach(() => {
mockAppMenu = {
setBounds: jest.fn()
};
jest.spyOn(appMenuModule, 'newAppMenu').mockImplementation(() => mockAppMenu);
main.init();
});
test('should set app-menu bounds', () => {
// When
mockBrowserWindow.listeners.restore({sender: mockBrowserWindow});
jest.runAllTimers();
// Then
expect(mockAppMenu.setBounds).toHaveBeenCalledWith({x: 0, y: 0, width: 10, height: 34});
});
});
describe('resize', () => {
test('#78: should be run in separate setTimeout timer function to resize properly in Linux', () => {
// When
Expand Down
2 changes: 1 addition & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ const init = () => {
mainWindow.show();
}
mainWindow.removeMenu();
['resize', 'maximize']
['resize', 'maximize', 'restore']
.forEach(event => mainWindow.on(event, handleMainWindowResize));
mainWindow.on('close', handleWindowClose);
initTabListener();
Expand Down

0 comments on commit d3ce65c

Please sign in to comment.