fix: quit properly in tray

This commit is contained in:
smartfrigde 2024-06-15 11:41:35 +02:00
parent 46a72f99cd
commit 6da51782ad
6 changed files with 13 additions and 7 deletions

View file

@ -9,7 +9,7 @@
"scripts": {
"build": "tsc && copyfiles -u 1 src/**/*.html src/**/**/*.css src/**/**/*.js ts-out/ && copyfiles package.json ts-out/ && copyfiles assets/**/** ts-out/",
"watch": "tsc -w",
"start": "pnpm run build && electron ./ts-out/main.js",
"start": "pnpm run build && electron --trace-warnings ./ts-out/main.js",
"startThemeManager": "pnpm run build && electron ./ts-out/main.js themes",
"startKeybindManager": "pnpm run build && electron ./ts-out/main.js keybinds",
"startWayland": "pnpm run build && electron ./ts-out/main.js --ozone-platform-hint=auto --enable-features=WebRTCPipeWireCapturer,WaylandWindowDecorations --disable-gpu",

View file

@ -83,6 +83,9 @@ export function registerIpc(passedWindow: BrowserWindow): void {
passedWindow.hide();
});
ipcMain.on("win-quit", () => {
app.quit();
});
ipcMain.on("win-forceQuit", () => {
app.exit();
});
ipcMain.on("get-app-version", (event) => {

View file

@ -112,7 +112,7 @@ setInterval(() => {
tManager.onclick = () => ipcRenderer.send("openManagerWindow");
fQuit.textContent = "Force Quit";
fQuit.id = "acForceQuit";
fQuit.onclick = () => ipcRenderer.send("win-quit");
fQuit.onclick = () => ipcRenderer.send("win-forceQuit");
advanced.insertAdjacentElement("afterend", acSettings);
advanced.insertAdjacentElement("afterend", tManager);
advanced.insertAdjacentElement("afterend", fQuit);

View file

@ -30,6 +30,7 @@ function registerCustomHandler(): void {
types: ["screen", "window"]
})
.then((sources) => {
if (!sources) return callback({});
console.log(sources);
if (process.platform === "linux" && process.env.XDG_SESSION_TYPE?.toLowerCase() === "wayland") {
console.log("WebRTC Capturer detected, skipping window creation."); //assume webrtc capturer is used

View file

@ -12,13 +12,13 @@ import * as fs from "fs";
import contextMenu from "electron-context-menu";
import os from "os";
import RPCServer from "arrpc";
import {tray} from "../tray.js";
import {isQuitting, tray} from "../tray.js";
import {iconPath, init} from "../main.js";
import {getConfig, setConfig, firstRun} from "../common/config.js";
import {getWindowState, setWindowState} from "../common/windowState.js";
export let mainWindows: BrowserWindow[] = [];
export let inviteWindow: BrowserWindow;
let forceQuit = false;
export let forceQuit = false;
let osType = os.type();
contextMenu({
showSaveImageAs: true,
@ -252,7 +252,7 @@ function doAfterDefiningTheWindow(passedWindow: BrowserWindow): void {
x: passedWindow.getPosition()[0],
y: passedWindow.getPosition()[1]
});
if (getConfig("minimizeToTray")) {
if (getConfig("minimizeToTray") && !isQuitting) {
e.preventDefault();
passedWindow.hide();
} else if (!getConfig("minimizeToTray")) {

View file

@ -6,6 +6,7 @@ import {createSettingsWindow} from "./settings/main.js";
import {getConfig, getConfigLocation, setConfig} from "./common/config.js";
import {getDisplayVersion} from "./common/version.js";
export let tray: Tray;
export let isQuitting = false;
let trayIcon = "ac_plug_colored";
void app.whenReady().then(async () => {
// REVIEW - app will hang at startup if line above is awaited.
@ -85,8 +86,9 @@ void app.whenReady().then(async () => {
{
label: `Quit ${clientName}`,
click() {
// NOTE - Temporary fix for app not actually quitting
app.exit();
//NOTE - It would be better to unify isQuitting with forceQuit in window.ts that's used on macOS
isQuitting = true;
app.quit();
}
}
]);