Fixed Snap issue with resizing on Windows 11 (#2686)

* Fixed Snap issue with resizing on Windows 11

* Run on focus/blur as well

* Whoops, left my logging changes

* Fix tests
This commit is contained in:
Devin Binnie
2023-04-21 18:09:20 -04:00
committed by GitHub
parent 73edb2fe48
commit 0f94b7d510
3 changed files with 11 additions and 0 deletions

View File

@@ -88,6 +88,7 @@ import {
GET_ORDERED_SERVERS, GET_ORDERED_SERVERS,
GET_ORDERED_TABS_FOR_SERVER, GET_ORDERED_TABS_FOR_SERVER,
SERVERS_UPDATE, SERVERS_UPDATE,
VIEW_FINISHED_RESIZING,
} from 'common/communication'; } from 'common/communication';
console.log('Preload initialized'); console.log('Preload initialized');
@@ -251,3 +252,7 @@ const createKeyDownListener = () => {
}); });
}; };
createKeyDownListener(); createKeyDownListener();
window.addEventListener('resize', () => {
ipcRenderer.send(VIEW_FINISHED_RESIZING);
});

View File

@@ -462,6 +462,7 @@ describe('main/windows/mainWindow', () => {
}; };
BrowserWindow.mockImplementation(() => window); BrowserWindow.mockImplementation(() => window);
const mainWindow = new MainWindow(); const mainWindow = new MainWindow();
mainWindow.getBounds = jest.fn();
mainWindow.init(); mainWindow.init();
Object.defineProperty(process, 'platform', { Object.defineProperty(process, 'platform', {
value: originalPlatform, value: originalPlatform,

View File

@@ -133,6 +133,7 @@ export class MainWindow extends EventEmitter {
this.win.on('leave-full-screen', () => this.win?.webContents.send('leave-full-screen')); this.win.on('leave-full-screen', () => this.win?.webContents.send('leave-full-screen'));
this.win.on('will-resize', this.onWillResize); this.win.on('will-resize', this.onWillResize);
this.win.on('resized', this.onResized); this.win.on('resized', this.onResized);
this.win.on('moved', this.onResized);
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
mainWindow.on('resize', this.onResize); mainWindow.on('resize', this.onResize);
} }
@@ -286,6 +287,8 @@ export class MainWindow extends EventEmitter {
// do nothing because we want to supress the menu popping up // do nothing because we want to supress the menu popping up
}); });
} }
this.emit(MAIN_WINDOW_RESIZED, this.getBounds());
} }
private onBlur = () => { private onBlur = () => {
@@ -295,6 +298,8 @@ export class MainWindow extends EventEmitter {
globalShortcut.unregisterAll(); globalShortcut.unregisterAll();
this.emit(MAIN_WINDOW_RESIZED, this.getBounds());
// App should save bounds when a window is closed. // App should save bounds when a window is closed.
// However, 'close' is not fired in some situations(shutdown, ctrl+c) // However, 'close' is not fired in some situations(shutdown, ctrl+c)
// because main process is killed in such situations. // because main process is killed in such situations.