Skip to content

Commit b0bf59f

Browse files
committed
Fix issue with not being able to hide window after toggling alwaysOnTop setting
1 parent 41f01f2 commit b0bf59f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

electron/main/index.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ async function createWindow() {
163163
win.setFullScreen(true)
164164
}
165165

166+
167+
// when app gets focused, show the window if it's hidden
168+
// without this, there are cases when Cmd-Tabbing to Heynote won't show the window
169+
app.on("did-become-active", (event) => {
170+
if (!win.isVisible()) {
171+
win.show()
172+
}
173+
})
174+
166175
win.on("close", (event) => {
167176
if (!forceQuit && CONFIG.get("settings.showInMenu")) {
168177
event.preventDefault()
@@ -294,10 +303,7 @@ function registerGlobalHotkey() {
294303
// app.hide() only available on macOS
295304
// We want to use app.hide() so that the menu bar also gets changed
296305
app?.hide()
297-
if (CONFIG.get("settings.alwaysOnTop")) {
298-
// if alwaysOnTop is on, calling app.hide() won't hide the window
299-
win.hide()
300-
}
306+
win.hide()
301307
} else if (isLinux) {
302308
win.blur()
303309
// If we don't hide the window, it will stay on top of the stack even though it's not visible
@@ -365,7 +371,7 @@ function registerAlwaysOnTop() {
365371
if (CONFIG.get("settings.alwaysOnTop")) {
366372
const setAlwaysOnTop = () => {
367373
win.setAlwaysOnTop(true, "floating");
368-
win.setVisibleOnAllWorkspaces(true, {visibleOnFullScreen: true});
374+
win.setVisibleOnAllWorkspaces(true, {visibleOnFullScreen: true, skipTransformProcessType:true});
369375
win.setFullScreenable(false);
370376

371377
// Ensure the Dock icon remains visible on macOS

0 commit comments

Comments
 (0)