fix app quit event bugs

This commit is contained in:
Gregor Biswanger
2017-11-10 01:48:06 +01:00
parent 96722e7598
commit fdb026c7bd
10 changed files with 162 additions and 76 deletions

View File

@@ -3,6 +3,8 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
namespace ElectronNET.API
@@ -30,7 +32,10 @@ namespace ElectronNET.API
{
BridgeConnector.Socket.On("app-window-all-closed" + GetHashCode(), () =>
{
_windowAllClosed();
if (!Electron.WindowManager.IsQuitOnWindowAllClosed)
{
_windowAllClosed();
}
});
BridgeConnector.Socket.Emit("register-app-window-all-closed-event", GetHashCode());
@@ -54,15 +59,38 @@ namespace ElectronNET.API
/// Note: If application quit was initiated by autoUpdater.quitAndInstall() then before-quit is emitted after
/// emitting close event on all windows and closing them.
/// </summary>
public event Action BeforeQuit
public event Func<Task> BeforeQuit
{
add
{
if (_beforeQuit == null)
{
BridgeConnector.Socket.On("app-before-quit" + GetHashCode(), () =>
BridgeConnector.Socket.On("app-before-quit" + GetHashCode(), async () =>
{
_beforeQuit();
await _beforeQuit();
if(_willQuit == null && _quitting == null)
{
Exit();
}
else if (_willQuit != null)
{
await _willQuit();
if(_quitting == null)
{
Exit();
} else
{
await _quitting();
Exit();
}
}
else if(_quitting != null)
{
await _quitting();
Exit();
}
});
BridgeConnector.Socket.Emit("register-app-before-quit-event", GetHashCode());
@@ -78,7 +106,7 @@ namespace ElectronNET.API
}
}
private event Action _beforeQuit;
private event Func<Task> _beforeQuit;
/// <summary>
/// Emitted when all windows have been closed and the application will quit.
@@ -86,15 +114,25 @@ namespace ElectronNET.API
/// See the description of the window-all-closed event for the differences between the will-quit and
/// window-all-closed events.
/// </summary>
public event Action WillQuit
public event Func<Task> WillQuit
{
add
{
if (_willQuit == null)
{
BridgeConnector.Socket.On("app-will-quit" + GetHashCode(), () =>
BridgeConnector.Socket.On("app-will-quit" + GetHashCode(), async () =>
{
_willQuit();
await _willQuit();
if(_quitting == null)
{
Exit();
}
else
{
await _quitting();
Exit();
}
});
BridgeConnector.Socket.Emit("register-app-will-quit-event", GetHashCode());
@@ -110,23 +148,27 @@ namespace ElectronNET.API
}
}
private event Action _willQuit;
private event Func<Task> _willQuit;
/// <summary>
/// Emitted when the application is quitting.
/// </summary>
public event Action Quitting
public event Func<Task> Quitting
{
add
{
if (_quitting == null)
{
BridgeConnector.Socket.On("app-quit" + GetHashCode(), () =>
BridgeConnector.Socket.On("app-will-quit" + GetHashCode() + "quitting", async () =>
{
_quitting();
if(_willQuit == null)
{
await _quitting();
Exit();
}
});
BridgeConnector.Socket.Emit("register-app-quit-event", GetHashCode());
BridgeConnector.Socket.Emit("register-app-will-quit-event", GetHashCode() + "quitting");
}
_quitting += value;
}
@@ -135,11 +177,11 @@ namespace ElectronNET.API
_quitting -= value;
if (_quitting == null)
BridgeConnector.Socket.Off("app-quit" + GetHashCode());
BridgeConnector.Socket.Off("app-will-quit" + GetHashCode() + "quitting");
}
}
private event Action _quitting;
private event Func<Task> _quitting;
/// <summary>
/// Emitted when a BrowserWindow gets blurred.

View File

@@ -47,18 +47,21 @@ namespace ElectronNET.API
public Task<string[]> ShowOpenDialogAsync(BrowserWindow browserWindow, OpenDialogOptions options)
{
var taskCompletionSource = new TaskCompletionSource<string[]>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("showOpenDialogComplete", (filePaths) =>
BridgeConnector.Socket.On("showOpenDialogComplete" + guid, (filePaths) =>
{
BridgeConnector.Socket.Off("showOpenDialogComplete");
BridgeConnector.Socket.Off("showOpenDialogComplete" + guid);
var result = ((JArray)filePaths).ToObject<string[]>();
taskCompletionSource.SetResult(result);
});
BridgeConnector.Socket.Emit("showOpenDialog",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(options, _jsonSerializer));
BridgeConnector.Socket.Emit("showOpenDialog",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(options, _jsonSerializer),
guid);
return taskCompletionSource.Task;
}
@@ -72,17 +75,19 @@ namespace ElectronNET.API
public Task<string> ShowSaveDialogAsync(BrowserWindow browserWindow, SaveDialogOptions options)
{
var taskCompletionSource = new TaskCompletionSource<string>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("showSaveDialogComplete", (filename) =>
BridgeConnector.Socket.On("showSaveDialogComplete" + guid, (filename) =>
{
BridgeConnector.Socket.Off("showSaveDialogComplete");
BridgeConnector.Socket.Off("showSaveDialogComplete" + guid);
taskCompletionSource.SetResult(filename.ToString());
});
BridgeConnector.Socket.Emit("showSaveDialog",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(options, _jsonSerializer));
JObject.FromObject(options, _jsonSerializer),
guid);
return taskCompletionSource.Task;
}
@@ -139,10 +144,11 @@ namespace ElectronNET.API
public Task<MessageBoxResult> ShowMessageBoxAsync(BrowserWindow browserWindow, MessageBoxOptions messageBoxOptions)
{
var taskCompletionSource = new TaskCompletionSource<MessageBoxResult>();
var guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("showMessageBoxComplete", (args) =>
BridgeConnector.Socket.On("showMessageBoxComplete" + guid, (args) =>
{
BridgeConnector.Socket.Off("showMessageBoxComplete");
BridgeConnector.Socket.Off("showMessageBoxComplete" + guid);
var result = ((JArray)args);
@@ -156,12 +162,13 @@ namespace ElectronNET.API
if (browserWindow == null)
{
BridgeConnector.Socket.Emit("showMessageBox", JObject.FromObject(messageBoxOptions, _jsonSerializer));
BridgeConnector.Socket.Emit("showMessageBox", JObject.FromObject(messageBoxOptions, _jsonSerializer), guid);
} else
{
BridgeConnector.Socket.Emit("showMessageBox",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(messageBoxOptions, _jsonSerializer));
JObject.FromObject(messageBoxOptions, _jsonSerializer),
guid);
}
return taskCompletionSource.Task;
@@ -205,16 +212,18 @@ namespace ElectronNET.API
public Task ShowCertificateTrustDialogAsync(BrowserWindow browserWindow, CertificateTrustDialogOptions options)
{
var taskCompletionSource = new TaskCompletionSource<object>();
string guid = Guid.NewGuid().ToString();
BridgeConnector.Socket.On("showCertificateTrustDialogComplete", () =>
BridgeConnector.Socket.On("showCertificateTrustDialogComplete" + guid, () =>
{
BridgeConnector.Socket.Off("showCertificateTrustDialogComplete");
BridgeConnector.Socket.Off("showCertificateTrustDialogComplete" + guid);
taskCompletionSource.SetResult(null);
});
BridgeConnector.Socket.Emit("showCertificateTrustDialog",
JObject.FromObject(browserWindow, _jsonSerializer),
JObject.FromObject(options, _jsonSerializer));
JObject.FromObject(options, _jsonSerializer),
guid);
return taskCompletionSource.Task;
}

View File

@@ -38,6 +38,23 @@ namespace ElectronNET.API
}
}
/// <summary>
/// Quit when all windows are closed. (Default is true)
/// </summary>
/// <value>
/// <c>true</c> if [quit window all closed]; otherwise, <c>false</c>.
/// </value>
public bool IsQuitOnWindowAllClosed
{
get { return _isQuitOnWindowAllClosed; }
set
{
BridgeConnector.Socket.Emit("quit-app-window-all-closed-event", value);
_isQuitOnWindowAllClosed = value;
}
}
private bool _isQuitOnWindowAllClosed = true;
/// <summary>
/// Gets the browser windows.
/// </summary>

View File

@@ -1,26 +1,36 @@
"use strict";
exports.__esModule = true;
var isQuitWindowAllClosed = true;
module.exports = function (socket, app) {
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin' &&
isQuitWindowAllClosed) {
app.quit();
}
});
socket.on('quit-app-window-all-closed-event', function (quit) {
isQuitWindowAllClosed = quit;
});
socket.on('register-app-window-all-closed-event', function (id) {
app.on('window-all-closed', function () {
socket.emit('app-window-all-closed' + id);
});
});
socket.on('register-app-before-quit-event', function (id) {
app.on('before-quit', function () {
app.on('before-quit', function (event) {
event.preventDefault();
socket.emit('app-before-quit' + id);
});
});
socket.on('register-app-will-quit-event', function (id) {
app.on('will-quit', function () {
app.on('will-quit', function (event) {
event.preventDefault();
socket.emit('app-will-quit' + id);
});
});
socket.on('register-app-quit-event', function (id) {
app.on('quit', function () {
socket.emit('app-quit' + id);
});
});
socket.on('register-app-browser-window-blur-event', function (id) {
app.on('browser-window-blur', function () {
socket.emit('app-browser-window-blur' + id);

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,22 @@
import { nativeImage as NativeImage } from 'electron';
let isQuitWindowAllClosed = true;
module.exports = (socket: SocketIO.Server, app: Electron.App) => {
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin' &&
isQuitWindowAllClosed) {
app.quit();
}
});
socket.on('quit-app-window-all-closed-event', (quit) => {
isQuitWindowAllClosed = quit;
});
socket.on('register-app-window-all-closed-event', (id) => {
app.on('window-all-closed', () => {
socket.emit('app-window-all-closed' + id);
@@ -9,20 +24,18 @@ module.exports = (socket: SocketIO.Server, app: Electron.App) => {
});
socket.on('register-app-before-quit-event', (id) => {
app.on('before-quit', () => {
app.on('before-quit', (event) => {
event.preventDefault();
socket.emit('app-before-quit' + id);
});
});
socket.on('register-app-will-quit-event', (id) => {
app.on('will-quit', () => {
socket.emit('app-will-quit' + id);
});
});
app.on('will-quit', (event) => {
event.preventDefault();
socket.on('register-app-quit-event', (id) => {
app.on('quit', () => {
socket.emit('app-quit' + id);
socket.emit('app-will-quit' + id);
});
});
@@ -103,7 +116,7 @@ module.exports = (socket: SocketIO.Server, app: Electron.App) => {
// }
socket.on('appGetFileIcon', (path, options) => {
if(options) {
if (options) {
app.getFileIcon(path, options, (error, nativeImage) => {
socket.emit('appGetFileIconCompleted', [error, nativeImage]);
});

View File

@@ -2,38 +2,40 @@
exports.__esModule = true;
var electron_1 = require("electron");
module.exports = function (socket) {
socket.on('showMessageBox', function (browserWindow, options) {
socket.on('showMessageBox', function (browserWindow, options, guid) {
if ("id" in browserWindow) {
var window = electron_1.BrowserWindow.fromId(browserWindow.id);
electron_1.dialog.showMessageBox(window, options, function (response, checkboxChecked) {
socket.emit('showMessageBoxComplete', [response, checkboxChecked]);
socket.emit('showMessageBoxComplete' + guid, [response, checkboxChecked]);
});
}
else {
var message = browserWindow;
var id_1 = guid || options;
electron_1.dialog.showMessageBox(browserWindow, function (response, checkboxChecked) {
socket.emit('showMessageBoxComplete', [response, checkboxChecked]);
socket.emit('showMessageBoxComplete' + id_1, [response, checkboxChecked]);
});
}
});
socket.on('showOpenDialog', function (browserWindow, options) {
socket.on('showOpenDialog', function (browserWindow, options, guid) {
var window = electron_1.BrowserWindow.fromId(browserWindow.id);
electron_1.dialog.showOpenDialog(window, options, function (filePaths) {
socket.emit('showOpenDialogComplete', filePaths || []);
socket.emit('showOpenDialogComplete' + guid, filePaths || []);
});
});
socket.on('showSaveDialog', function (browserWindow, options) {
socket.on('showSaveDialog', function (browserWindow, options, guid) {
var window = electron_1.BrowserWindow.fromId(browserWindow.id);
electron_1.dialog.showSaveDialog(window, options, function (filename) {
socket.emit('showSaveDialogComplete', filename || '');
socket.emit('showSaveDialogComplete' + guid, filename || '');
});
});
socket.on('showErrorBox', function (title, content) {
electron_1.dialog.showErrorBox(title, content);
});
socket.on('showCertificateTrustDialog', function (browserWindow, options) {
socket.on('showCertificateTrustDialog', function (browserWindow, options, guid) {
var window = electron_1.BrowserWindow.fromId(browserWindow.id);
electron_1.dialog.showCertificateTrustDialog(window, options, function () {
socket.emit('showCertificateTrustDialogComplete');
socket.emit('showCertificateTrustDialogComplete' + guid);
});
});
};

View File

@@ -1 +1 @@
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["dialog.ts"],"names":[],"mappings":";;AAAA,qCAAiD;AAEjD,MAAM,CAAC,OAAO,GAAG,UAAC,MAAuB;IACrC,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,UAAC,aAAa,EAAE,OAAO;QAC/C,EAAE,CAAC,CAAC,IAAI,IAAI,aAAa,CAAC,CAAC,CAAC;YACxB,IAAI,MAAM,GAAG,wBAAa,CAAC,MAAM,CAAC,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AC7D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAA"}

View File

@@ -1,31 +1,33 @@
import { BrowserWindow, dialog } from "electron";
module.exports = (socket: SocketIO.Server) => {
socket.on('showMessageBox', (browserWindow, options) => {
socket.on('showMessageBox', (browserWindow, options, guid) => {
if ("id" in browserWindow) {
var window = BrowserWindow.fromId(browserWindow.id);
dialog.showMessageBox(window, options, (response, checkboxChecked) => {
socket.emit('showMessageBoxComplete', [response, checkboxChecked]);
socket.emit('showMessageBoxComplete' + guid, [response, checkboxChecked]);
});
} else {
var message = browserWindow;
let id = guid || options;
dialog.showMessageBox(browserWindow, (response, checkboxChecked) => {
socket.emit('showMessageBoxComplete', [response, checkboxChecked]);
socket.emit('showMessageBoxComplete' + id, [response, checkboxChecked]);
});
}
});
socket.on('showOpenDialog', (browserWindow, options) => {
socket.on('showOpenDialog', (browserWindow, options, guid) => {
var window = BrowserWindow.fromId(browserWindow.id);
dialog.showOpenDialog(window, options, (filePaths) => {
socket.emit('showOpenDialogComplete', filePaths || []);
socket.emit('showOpenDialogComplete' + guid, filePaths || []);
});
});
socket.on('showSaveDialog', (browserWindow, options) => {
socket.on('showSaveDialog', (browserWindow, options, guid) => {
var window = BrowserWindow.fromId(browserWindow.id);
dialog.showSaveDialog(window, options, (filename) => {
socket.emit('showSaveDialogComplete', filename || '');
socket.emit('showSaveDialogComplete' + guid, filename || '');
});
});
@@ -33,10 +35,10 @@ module.exports = (socket: SocketIO.Server) => {
dialog.showErrorBox(title, content);
});
socket.on('showCertificateTrustDialog', (browserWindow, options) => {
socket.on('showCertificateTrustDialog', (browserWindow, options, guid) => {
var window = BrowserWindow.fromId(browserWindow.id);
dialog.showCertificateTrustDialog(window, options, () => {
socket.emit('showCertificateTrustDialogComplete');
socket.emit('showCertificateTrustDialogComplete' + guid);
});
});
}

View File

@@ -58,15 +58,6 @@ function startAspCoreBackend(electronPort) {
});
}
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
//app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.