aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2023-01-08 19:13:33 +0100
committerVendicated <vendicated@riseup.net>2023-01-08 19:13:57 +0100
commitae9fe7fcfd49b6b178e55f36cc3d12e286a6134c (patch)
tree17b6a042c5ae2700f16d9e090634d2737279da4c
parentf0240ec3457aff627b56d75876a8ed9fc8a98a5d (diff)
downloadVencord-ae9fe7fcfd49b6b178e55f36cc3d12e286a6134c.tar.gz
Vencord-ae9fe7fcfd49b6b178e55f36cc3d12e286a6134c.tar.bz2
Vencord-ae9fe7fcfd49b6b178e55f36cc3d12e286a6134c.zip
Fix Ctrl+Q shortcut working when Discord minimised
-rw-r--r--src/patcher.ts29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/patcher.ts b/src/patcher.ts
index 6766e0f..96cb23c 100644
--- a/src/patcher.ts
+++ b/src/patcher.ts
@@ -17,7 +17,7 @@
*/
import { onceDefined } from "@utils/onceDefined";
-import electron, { app, BrowserWindowConstructorOptions, globalShortcut } from "electron";
+import electron, { app, BrowserWindowConstructorOptions, Menu } from "electron";
import { readFileSync } from "fs";
import { dirname, join } from "path";
@@ -44,9 +44,27 @@ app.setAppPath(asarPath);
if (!process.argv.includes("--vanilla")) {
// Repatch after host updates on Windows
- if (process.platform === "win32")
+ if (process.platform === "win32") {
require("./patchWin32Updater");
+ const originalBuild = Menu.buildFromTemplate;
+ Menu.buildFromTemplate = function (template) {
+ if (template[0]?.label === "&File") {
+ const { submenu } = template[0];
+ if (Array.isArray(submenu)) {
+ submenu.push({
+ label: "Quit (Hidden)",
+ visible: false,
+ acceleratorWorksWhenHidden: true,
+ accelerator: "Control+Q",
+ click: () => app.quit()
+ });
+ }
+ }
+ return originalBuild.call(this, template);
+ };
+ }
+
class BrowserWindow extends electron.BrowserWindow {
constructor(options: BrowserWindowConstructorOptions) {
if (options?.webPreferences?.preload && options.title) {
@@ -153,13 +171,6 @@ if (!process.argv.includes("--vanilla")) {
responseHeaders["content-type"] = ["text/css"];
}
cb({ cancel: false, responseHeaders });
-
-
- if (process.platform === "win32") {
- globalShortcut.register("Control+Q", () => {
- app.quit();
- });
- }
});
});
} else {