mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
fix macOS window behaviour
This commit is contained in:
parent
cd869a885c
commit
59e7a4bcc9
1 changed files with 31 additions and 15 deletions
|
@ -27,6 +27,7 @@ import {iconPath} from "./main";
|
||||||
import {createSetupWindow} from "./setup/main";
|
import {createSetupWindow} from "./setup/main";
|
||||||
export let mainWindow: BrowserWindow;
|
export let mainWindow: BrowserWindow;
|
||||||
export let inviteWindow: BrowserWindow;
|
export let inviteWindow: BrowserWindow;
|
||||||
|
let forceQuit = false;
|
||||||
let osType = os.type();
|
let osType = os.type();
|
||||||
contextMenu({
|
contextMenu({
|
||||||
showSaveImageAs: true,
|
showSaveImageAs: true,
|
||||||
|
@ -89,6 +90,9 @@ async function doAfterDefiningTheWindow(): Promise<void> {
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
app.on("activate", function () {
|
||||||
|
app.show();
|
||||||
|
});
|
||||||
mainWindow.webContents.setWindowOpenHandler(({url}) => {
|
mainWindow.webContents.setWindowOpenHandler(({url}) => {
|
||||||
// Allow about:blank (used by Vencord QuickCss popup)
|
// Allow about:blank (used by Vencord QuickCss popup)
|
||||||
if (url === "about:blank") return {action: "allow"};
|
if (url === "about:blank") return {action: "allow"};
|
||||||
|
@ -220,23 +224,35 @@ async function doAfterDefiningTheWindow(): Promise<void> {
|
||||||
});
|
});
|
||||||
await setMenu();
|
await setMenu();
|
||||||
mainWindow.on("close", async (e) => {
|
mainWindow.on("close", async (e) => {
|
||||||
let [width, height] = mainWindow.getSize();
|
if (process.platform === "darwin" && forceQuit) {
|
||||||
await setWindowState({
|
mainWindow.close();
|
||||||
width,
|
} else {
|
||||||
height,
|
let [width, height] = mainWindow.getSize();
|
||||||
isMaximized: mainWindow.isMaximized(),
|
await setWindowState({
|
||||||
x: mainWindow.getPosition()[0],
|
width,
|
||||||
y: mainWindow.getPosition()[1]
|
height,
|
||||||
});
|
isMaximized: mainWindow.isMaximized(),
|
||||||
if (await getConfig("minimizeToTray")) {
|
x: mainWindow.getPosition()[0],
|
||||||
e.preventDefault();
|
y: mainWindow.getPosition()[1]
|
||||||
mainWindow.hide();
|
});
|
||||||
} else if (!(await getConfig("minimizeToTray"))) {
|
if (await getConfig("minimizeToTray")) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
app.quit();
|
mainWindow.hide();
|
||||||
|
} else if (!(await getConfig("minimizeToTray"))) {
|
||||||
|
e.preventDefault();
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (process.platform === "darwin") {
|
||||||
|
app.on("before-quit", function (event) {
|
||||||
|
if (!forceQuit) {
|
||||||
|
event.preventDefault();
|
||||||
|
forceQuit = true;
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
mainWindow.on("focus", () => {
|
mainWindow.on("focus", () => {
|
||||||
mainWindow.webContents.executeJavaScript(`document.body.removeAttribute("unFocused");`);
|
mainWindow.webContents.executeJavaScript(`document.body.removeAttribute("unFocused");`);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue