Skip to content

Commit e933172

Browse files
Merge branch 'master' into master
2 parents f4ea6df + 92b0388 commit e933172

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

ElectronNET.API/App.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Newtonsoft.Json.Linq;
44
using Newtonsoft.Json.Serialization;
55
using System;
6+
using System.Runtime.InteropServices;
67
using System.Threading;
78
using System.Threading.Tasks;
89

@@ -31,7 +32,7 @@ public event Action WindowAllClosed
3132
{
3233
BridgeConnector.Socket.On("app-window-all-closed" + GetHashCode(), () =>
3334
{
34-
if (!Electron.WindowManager.IsQuitOnWindowAllClosed)
35+
if (!Electron.WindowManager.IsQuitOnWindowAllClosed || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
3536
{
3637
_windowAllClosed();
3738
}

ElectronNET.Host/api/app.js

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/app.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
let isQuitWindowAllClosed = true, electronSocket;
2+
let appWindowAllClosedEventId;
23
export = (socket: SocketIO.Socket, app: Electron.App) => {
34
electronSocket = socket;
4-
// Quit when all windows are closed.
5+
6+
// By default, quit when all windows are closed
57
app.on('window-all-closed', () => {
68
// On macOS it is common for applications and their menu bar
79
// to stay active until the user quits explicitly with Cmd + Q
8-
if (process.platform !== 'darwin' &&
9-
isQuitWindowAllClosed) {
10+
if (process.platform !== 'darwin' && isQuitWindowAllClosed) {
1011
app.quit();
12+
} else if (appWindowAllClosedEventId) {
13+
// If the user is on macOS
14+
// - OR -
15+
// If the user has indicated NOT to quit when all windows are closed,
16+
// emit the event.
17+
electronSocket.emit('app-window-all-closed' + appWindowAllClosedEventId);
1118
}
1219
});
1320

@@ -16,9 +23,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
1623
});
1724

1825
socket.on('register-app-window-all-closed-event', (id) => {
19-
app.on('window-all-closed', () => {
20-
electronSocket.emit('app-window-all-closed' + id);
21-
});
26+
appWindowAllClosedEventId = id;
2227
});
2328

2429
socket.on('register-app-before-quit-event', (id) => {

ElectronNET.Host/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ app.on('ready', () => {
6262

6363
});
6464

65+
app.on('quit', async (event, exitCode) => {
66+
await server.close();
67+
apiProcess.kill();
68+
});
69+
6570
function isSplashScreenEnabled() {
6671
if (manifestJsonFile.hasOwnProperty('splashscreen')) {
6772
if (manifestJsonFile.splashscreen.hasOwnProperty('imageFile')) {

0 commit comments

Comments
 (0)