1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-26 09:33:22 +00:00

Improved hide/show

This commit is contained in:
Anders Åberg
2024-10-10 13:24:49 +02:00
parent d26b61eed9
commit da6c9a2c18
2 changed files with 12 additions and 3 deletions

View File

@@ -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;

View File

@@ -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) {