Skip to content

Commit

Permalink
minimize on alt+f4 (Vendicated#1556)
Browse files Browse the repository at this point in the history
  • Loading branch information
gorgulenkozxc committed Oct 16, 2023
1 parent 188d12d commit a628881
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/api/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface Settings {
winCtrlQ: boolean;
macosTranslucency: boolean;
disableMinSize: boolean;
hideOnAltF4: boolean;
winNativeTitleBar: boolean;
plugins: {
[plugin: string]: {
Expand Down Expand Up @@ -76,6 +77,7 @@ const DefaultSettings: Settings = {
winCtrlQ: false,
macosTranslucency: false,
disableMinSize: false,
hideOnAltF4: false,
winNativeTitleBar: false,
plugins: {},

Expand Down
5 changes: 5 additions & 0 deletions src/components/VencordSettings/VencordTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ function VencordSettings() {
title: "Disable minimum window size",
note: "Requires a full restart"
},
IS_DISCORD_DESKTOP && {
key: "hideOnAltF4",
title: "Prevent Alt+F4",
note: "Hide Discord on Alt+F4 instead of closing it"
},
IS_DISCORD_DESKTOP && isMac && {
key: "macosTranslucency",
title: "Enable translucent window",
Expand Down
7 changes: 7 additions & 0 deletions src/main/ipcMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ export function initIpc(mainWindow: BrowserWindow) {
watch(THEMES_DIR, { persistent: false }, debounce(() => {
mainWindow.webContents.postMessage(IpcEvents.THEME_UPDATE, void 0);
}));

mainWindow.webContents.on("before-input-event", (event, input) => {
if (input.code === "F4" && input.alt && getSettings().hideOnAltF4) {
event.preventDefault();
mainWindow.hide();
}
});
}

ipcMain.handle(IpcEvents.OPEN_MONACO_EDITOR, async () => {
Expand Down

0 comments on commit a628881

Please sign in to comment.