From b9d989b281d2f4dab4d800c196363c6d6f6b9e95 Mon Sep 17 00:00:00 2001 From: Philippe Gibert Date: Fri, 5 Feb 2021 09:17:11 +0100 Subject: [PATCH] fix: Quit process behaviour on Mac (#119) * Ignore apple & IntelliJ files * supress unused call to css/index.css * Fix quit behaviour on MacOs * Revert "supress unused call to css/index.css" This reverts commit 679ff0a1ad448915c0b9604f8b4a7cb990143b28. --- .gitignore | 6 ++++++ app/main/window/hideOnClose.js | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index f9d427ab..67d327df 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,9 @@ node_modules/ dist/ *_.* *_ + +yarn-error.log + +.idea/ + +.DS_Store diff --git a/app/main/window/hideOnClose.js b/app/main/window/hideOnClose.js index f1ff1b03..99ff22ff 100644 --- a/app/main/window/hideOnClose.js +++ b/app/main/window/hideOnClose.js @@ -1,10 +1,25 @@ const { app } = require("electron"); +const quit = require("../quit"); + + module.exports = function hideOnClose(win) { + let willQuitApp = false; + win.on("close", (event) => { + + // Quit on Cmd + Q on Mac + if (willQuitApp && process.platform === 'darwin') { + quit(); + } + if (!app.__isQuitting) { event.preventDefault(); win.hide(); } }); + + // Detect If the user decide to quit app + app.on('before-quit', () => willQuitApp = true); + };