Hide Heynote from taskbar on Windows when Tray icon has been turned on. Make close button just hide the window, and require using the Tray menu to quit for real. Fixes 137.

This commit is contained in:
Jonatan Heyman 2024-01-06 02:51:07 +01:00
parent aa420acd1d
commit bb5975455c
2 changed files with 17 additions and 2 deletions

View File

@ -63,6 +63,12 @@ if (isBetaVersion) {
CONFIG.set("settings.allowBetaVersions", true)
}
let forceQuit = false
export function quit() {
forceQuit = true
app.quit()
}
async function createWindow() {
// read any stored window settings from config, or use defaults
@ -87,7 +93,7 @@ async function createWindow() {
nodeIntegration: true,
contextIsolation: true,
},
skipTaskbar: isWindows && CONFIG.get("settings.showInMenu"),
}, windowConfig))
// maximize window if it was maximized last time
@ -99,6 +105,11 @@ async function createWindow() {
}
win.on("close", (event) => {
if (!forceQuit && isWindows && CONFIG.get("settings.showInMenu")) {
event.preventDefault()
win.hide()
return
}
// Prevent the window from closing, and send a message to the renderer which will in turn
// send a message to the main process to save the current buffer and close the window.
if (!contentSaved) {
@ -207,6 +218,9 @@ function registerShowInMenu() {
} else {
tray?.destroy()
}
if (isWindows) {
win.setSkipTaskbar(CONFIG.get("settings.showInMenu"))
}
}
app.whenReady().then(createWindow).then(async () => {

View File

@ -1,6 +1,7 @@
const { app, Menu } = require("electron")
import { OPEN_SETTINGS_EVENT } from "../constants";
import { openAboutWindow } from "./about";
import { quit } from "./index"
const isMac = process.platform === "darwin"
@ -157,7 +158,7 @@ export function getTrayMenu(win) {
{
label: 'Quit',
click: () => {
app.quit()
quit()
},
},
])