From 6b8b0e1a75c6fd7b2bf4eaecba6431f233a5ea2e Mon Sep 17 00:00:00 2001 From: ulu <147140426+ulugmer@users.noreply.github.com> Date: Thu, 21 Dec 2023 13:09:49 +0800 Subject: [PATCH 1/3] Resolve Full-Screen Exit Issue on MacOS Application | issue #330 Resolve Full-Screen Exit Issue on MacOS Application | issue #330 --- src/electron/window.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/electron/window.ts b/src/electron/window.ts index e0ac186e57..f0ec6f5a64 100644 --- a/src/electron/window.ts +++ b/src/electron/window.ts @@ -99,7 +99,19 @@ export function createWindow(url?: string) { }); window.on('close', (event) => { - if (IS_MAC_OS || (IS_WINDOWS && tray.isEnabled)) { + const focusedWindow = getCurrentWindow(); + + if (focusedWindow && focusedWindow.isFullScreen()) { + event.preventDefault(); + focusedWindow.once('leave-full-screen', () => { + if (forceQuit.isEnabled) { + app.exit(0); + } else { + focusedWindow.close(); + } + }); + focusedWindow.setFullScreen(false); + } else if (IS_MAC_OS || (IS_WINDOWS && tray.isEnabled)) { if (forceQuit.isEnabled) { app.exit(0); forceQuit.disable(); From 4900c565e370f421946ec79c57a54db0a0de3534 Mon Sep 17 00:00:00 2001 From: ulu <147140426+ulugmer@users.noreply.github.com> Date: Thu, 21 Dec 2023 13:37:53 +0800 Subject: [PATCH 2/3] Return forceQuit without leaving fullscreen --- src/electron/window.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/electron/window.ts b/src/electron/window.ts index f0ec6f5a64..ca7215b1fe 100644 --- a/src/electron/window.ts +++ b/src/electron/window.ts @@ -98,24 +98,22 @@ export function createWindow(url?: string) { window.webContents.send(ElectronEvent.FULLSCREEN_CHANGE, false); }); - window.on('close', (event) => { + window.on('close', (event) => { const focusedWindow = getCurrentWindow(); + if (forceQuit.isEnabled) { + app.exit(0); + return; + } if (focusedWindow && focusedWindow.isFullScreen()) { event.preventDefault(); focusedWindow.once('leave-full-screen', () => { - if (forceQuit.isEnabled) { - app.exit(0); - } else { - focusedWindow.close(); - } + focusedWindow.close(); }); focusedWindow.setFullScreen(false); } else if (IS_MAC_OS || (IS_WINDOWS && tray.isEnabled)) { - if (forceQuit.isEnabled) { - app.exit(0); - forceQuit.disable(); - } else if (hasExtraWindows()) { + // Обычная логика закрытия + if (hasExtraWindows()) { windows.delete(window); windowState.unmanage(); } else { From c270df0b02a665d5ec0374c469dbb42eb6db3f23 Mon Sep 17 00:00:00 2001 From: ulu <147140426+ulugmer@users.noreply.github.com> Date: Mon, 25 Dec 2023 10:49:59 +0800 Subject: [PATCH 3/3] Translate Comments and Resolve ESLint Issues --- src/electron/window.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/electron/window.ts b/src/electron/window.ts index ca7215b1fe..8abbac77dc 100644 --- a/src/electron/window.ts +++ b/src/electron/window.ts @@ -98,7 +98,7 @@ export function createWindow(url?: string) { window.webContents.send(ElectronEvent.FULLSCREEN_CHANGE, false); }); - window.on('close', (event) => { + window.on('close', (event) => { const focusedWindow = getCurrentWindow(); if (forceQuit.isEnabled) { app.exit(0); @@ -112,7 +112,7 @@ export function createWindow(url?: string) { }); focusedWindow.setFullScreen(false); } else if (IS_MAC_OS || (IS_WINDOWS && tray.isEnabled)) { - // Обычная логика закрытия + // Standard logic for closing if (hasExtraWindows()) { windows.delete(window); windowState.unmanage();