Skip to content
This repository has been archived by the owner on Nov 23, 2023. It is now read-only.

Fix app closing on macOS #235

Merged
merged 2 commits into from
Oct 22, 2023
Merged
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
26 changes: 17 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@ app.on("ready", async () => {
app.quit();
}

// TODO: Check for compatability for Linux and Windows
globalShortcut.register("CommandOrControl+Q", () => shutdownMenu());
// TODO: Support custom binds for other platforms
if (mainWindow)
mainWindow.webContents.on("before-input-event", (event, input) => {
if (input.meta && input.key.toUpperCase() === "Q") {
event.preventDefault();
shutdownMenu();
}
});
});

async function createMainWindow() {
Expand Down Expand Up @@ -165,13 +171,16 @@ async function createMainWindow() {
// after the user close the last window, instead wait for Command + Q (or equivalent).
// Noted. Will look into this later.
app.on("window-all-closed", () => {
// blix.projectManager.saveAllProjects();
/**
* We only need this if we wanted the user to manualy close the app on macOS
* but we want to do this manually
*/
if (process.platform !== "darwin") app.quit();
});

app.on("will-quit", (e) => {
// blix.projectManager.saveAllProjects();
});
// app.on("will-quit", (e) => {
// blix.projectManager.saveAllProjects();
// });

async function shutdownMenu() {
if (!mainWindow) return;
Expand Down Expand Up @@ -226,9 +235,8 @@ async function shutdownMenu() {
}

function closeApp() {
// TODO: Is this a clean quit?
mainWindow?.destroy();
if (process.platform !== "darwin") app.quit();
// mainWindow?.destroy();
app.quit();
}

app.on("activate", () => {
Expand Down
Loading