Skip to content

Commit

Permalink
macOS: ensure menu items are disabled when animator is minimised
Browse files Browse the repository at this point in the history
  • Loading branch information
charlielee committed Mar 22, 2021
1 parent 50915e4 commit 3d0b352
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/js/main/MenuBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@
{ role: "togglefullscreen" }
]
},
// Window (macOS only)
...(isMac ? [{
role: "windowMenu"
}] : []),
// Help
{
label: "Help",
Expand Down
25 changes: 23 additions & 2 deletions src/js/main/Win.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
this.menuBar.eventEmitter.on("menubar:click", (menuItemName) => {
let currentWindow = (BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0]);

// Open the launcher if the app is open but there are no windows open
// (this situation is only possible on macOS)
// Ensure current window is visible
if (currentWindow && !currentWindow.isVisible()) {
currentWindow.restore();
}

// Open the launcher if the app is open but there are no windows open (only possible on macOS)
if (!currentWindow) {
self.loadLauncher();
}
Expand Down Expand Up @@ -90,6 +94,23 @@
e.preventDefault();
}
});

// Disable menu items on minimise
let reenableMenuItemsAfterMinimize = false;
animatorWin.on("minimize", () => {
if (this.menuBar.animatorItemsEnabled) {
this.menuBar.toggleAnimatorItems(false);
reenableMenuItemsAfterMinimize = true;
}
});

// Enable menu items on restore
animatorWin.on("restore", () => {
if (reenableMenuItemsAfterMinimize) {
this.menuBar.toggleAnimatorItems(true);
reenableMenuItemsAfterMinimize = false;
}
});
}

/**
Expand Down

0 comments on commit 3d0b352

Please sign in to comment.