Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDA-4256 (Exit fullscreen before hiding the main window) #2020

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
};
Loading