fix resizing

This commit is contained in:
Anton Bracke 2022-02-22 19:58:51 +01:00
parent 67ef2abb24
commit 92ec433539
No known key found for this signature in database
GPG Key ID: B1222603899C6B25

View File

@ -18,17 +18,20 @@ export function getAppView() {
}
function resizeAppView() {
if (!mainWindow || !appView) {
return;
}
// TODO: workaround: set timeout is needed as mainWindow.getBounds() needs some time to update
setTimeout(() => {
if (!mainWindow || !appView) {
return;
}
const { width, height } = mainWindow.getBounds();
const { width, height } = mainWindow.getBounds();
appView.setBounds({
x: sidebarWidth,
y: 0,
width: width - sidebarWidth,
height: height,
appView.setBounds({
x: sidebarWidth,
y: 0,
width: width - sidebarWidth,
height: height,
});
});
}
@ -92,16 +95,7 @@ export async function createWindow() {
});
resizeAppView();
appView.setAutoResize({ width: true, height: true });
// TODO: workaround to fix appView resizing when window is resized
mainWindow.on("maximize", resizeAppView);
mainWindow.on("unmaximize", resizeAppView);
mainWindow.on("minimize", resizeAppView);
mainWindow.on("restore", resizeAppView);
mainWindow.on("resize", resizeAppView);
mainWindow.on("show", resizeAppView);
mainWindow.on("enter-full-screen", resizeAppView);
mainWindow.on("leave-full-screen", resizeAppView);
mainWindow.once("ready-to-show", () => {
mainWindow?.show();