From da6c9a2c18a6844a9cd57c3a1508145479567277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Thu, 10 Oct 2024 13:24:49 +0200 Subject: [PATCH] Improved hide/show --- apps/desktop/src/main/window.main.ts | 10 ++++++++++ apps/desktop/src/platform/popup-modal-styles.ts | 5 ++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/main/window.main.ts b/apps/desktop/src/main/window.main.ts index bd57566c50e..5224dfc7c32 100644 --- a/apps/desktop/src/main/window.main.ts +++ b/apps/desktop/src/main/window.main.ts @@ -75,10 +75,16 @@ export class WindowMain { pairwise(), concatMap(async ([lastValue, newValue]) => { if (lastValue && !newValue) { + //console.log("Apply main window styles"); + // Reset the window state to the main window state applyMainWindowStyles(this.win, this.windowStates[mainWindowSizeKey]); + // Because modal is used in front of another app, UX wise it makes sense to hide the main window when leaving modal mode. this.win.hide(); } else if (!lastValue && newValue) { + // Apply the popup modal styles applyPopupModalStyles(this.win); + //console.log("show the modal"); + this.win.show(); } }), ) @@ -382,6 +388,10 @@ export class WindowMain { this.windowStates[configKey].isMaximized = win.isMaximized() || win.isFullScreen(); this.windowStates[configKey].displayBounds = screen.getDisplayMatching(bounds).bounds; + // Maybe store these as well? + //console.log("isFocused", win.isFocused()); + //console.log("isVisible", win.isVisible()); + if (!win.isMaximized() && !win.isMinimized() && !win.isFullScreen()) { this.windowStates[configKey].x = bounds.x; this.windowStates[configKey].y = bounds.y; diff --git a/apps/desktop/src/platform/popup-modal-styles.ts b/apps/desktop/src/platform/popup-modal-styles.ts index aeccf418270..629e7c84f4f 100644 --- a/apps/desktop/src/platform/popup-modal-styles.ts +++ b/apps/desktop/src/platform/popup-modal-styles.ts @@ -14,7 +14,7 @@ export function applyPopupModalStyles(window: BrowserWindow) { window.setResizable(false); window.setAlwaysOnTop(true); - // recover from full screen is a bit more hassle + // Adjusting from full screen is a bit more hassle if (window.isFullScreen()) { window.setFullScreen(false); window.once("leave-full-screen", () => { @@ -32,9 +32,8 @@ export function applyMainWindowStyles(window: BrowserWindow, existingWindowState window.setMenuBarVisibility(true); window.setResizable(true); window.setAlwaysOnTop(false); - // window.hide(); - // console.log("is maximized", existingWindowState.isMaximized); + // We're currently not recovering the maximized state, mostly due to conflicts with hiding the window. // window.setFullScreen(existingWindowState.isMaximized); // if (existingWindowState.isMaximized) {