This commit is contained in:
Zarpyk 2023-07-27 13:58:32 +02:00
parent a5abaf32e7
commit 71ba850a15
No known key found for this signature in database
GPG Key ID: 7A5606F53C8CDEE1

20
main.js
View File

@ -69,6 +69,21 @@ const childWindows = new Set(),
else showWindows(); else showWindows();
}; };
let isMaximized = false;
const onMinimize = () => {
if (isMaximized) getCurrentWindow().maximize();
hideWindows();
}, interceptWindowMinimize = () => {
isMaximized = getCurrentWindow().isMaximized();
getCurrentWindow().on("maximize", () => {
isMaximized = true;
});
getCurrentWindow().on("unmaximize", () => {
isMaximized = false;
});
getCurrentWindow().on("minimize", onMinimize);
};
const onWindowClose = (event) => event.preventDefault(), const onWindowClose = (event) => event.preventDefault(),
onWindowUnload = (event) => { onWindowUnload = (event) => {
log(LOG_WINDOW_CLOSE); log(LOG_WINDOW_CLOSE);
@ -394,7 +409,10 @@ class TrayPlugin extends obsidian.Plugin {
setHideTaskbarIcon(); setHideTaskbarIcon();
setLaunchOnStartup(); setLaunchOnStartup();
observeChildWindows(); observeChildWindows();
if (settings.runInBackground) interceptWindowClose(); if (settings.runInBackground) {
interceptWindowMinimize();
interceptWindowClose();
}
if (settings.hideOnLaunch) { if (settings.hideOnLaunch) {
this.registerEvent(this.app.workspace.onLayoutReady(hideWindows)); this.registerEvent(this.app.workspace.onLayoutReady(hideWindows));
} }