mirror of
https://github.com/dragonwocky/obsidian-tray.git
synced 2025-04-04 03:59:03 +00:00
merge pull request #24 from Zarpyk/main
semi-addresses #22: will re-maximise windows automatically when minimised however, only works when run in background is enabled and causes weird window flickering on minimisation
This commit is contained in:
commit
78e819cc45
20
main.js
20
main.js
@ -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));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user