Skip to content

Commit

Permalink
SDA-4256 - Exit fullscreen before hiding the main window (#2020)
Browse files Browse the repository at this point in the history
  • Loading branch information
KiranNiranjan committed Nov 28, 2023
1 parent c9f358f commit 723f802
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
21 changes: 6 additions & 15 deletions src/app/stores/window-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { isMac } from '../../common/env';
import { logger } from '../../common/logger';
import { presenceStatus } from '../presence-status-handler';
import { ICustomBrowserWindow, windowHandler } from '../window-handler';
import { getWindowByName, showBadgeCount } from '../window-utils';
import {
getWindowByName,
hideFullscreenWindow,
showBadgeCount,
} from '../window-utils';

export interface IWindowObject {
windows: IWindowState[];
Expand Down Expand Up @@ -56,7 +60,7 @@ export class WindowStore {
) {
if (isMac) {
if (isFullScreen) {
this.hideFullscreenWindow(currentWindow);
hideFullscreenWindow(currentWindow);
// No need to hide minimized windows
} else if (!isMinimized) {
currentWindow?.hide();
Expand Down Expand Up @@ -150,19 +154,6 @@ export class WindowStore {
});
};

private hideFullscreenWindow = (window: BrowserWindow) => {
window.once('leave-full-screen', () => {
if (isMac) {
window.hide();
} else {
setTimeout(() => {
window.hide();
}, 0);
}
});
window.setFullScreen(false);
};

/**
* Restores windows that are in fullscreen and focus on the right window
* On macOS, windows in fullscreen need to be restore one by one
Expand Down
9 changes: 8 additions & 1 deletion src/app/window-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import {
getWindowByName,
handleCertificateProxyVerification,
handleDownloadManager,
hideFullscreenWindow,
initSysTray,
injectStyles,
isSymphonyReachable,
Expand Down Expand Up @@ -775,7 +776,13 @@ export class WindowHandler {

if (isMac && !this.isAutoUpdating) {
event.preventDefault();
this.mainWindow.hide();
// this is a workaround for an issue with macOS
// https://github.com/electron/electron/issues/39572
if (this.mainWindow.isFullScreen()) {
hideFullscreenWindow(this.mainWindow);
} else {
this.mainWindow.hide();
}
return;
}

Expand Down
17 changes: 17 additions & 0 deletions src/app/window-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1440,3 +1440,20 @@ export const loadBrowserViews = async (

return mainView.webContents;
};

export const hideFullscreenWindow = (window: BrowserWindow) => {
window.once('leave-full-screen', () => {
if (!window && !windowExists(window)) {
logger.info('window-utils: window does not exists');
return;
}
if (isMac) {
window.hide();
} else {
setTimeout(() => {
window.hide();
}, 0);
}
window.setFullScreen(false);
});
};

0 comments on commit 723f802

Please sign in to comment.