From 99817704688aff50e0e041a2c4f02a90b7e74a27 Mon Sep 17 00:00:00 2001 From: Sean Oliver <882952+seanoliver@users.noreply.github.com> Date: Sun, 30 Jul 2023 22:29:06 -0700 Subject: [PATCH 1/4] feat(index) menubar stays open in development for debugging --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index a40d1a1..74f3002 100644 --- a/index.js +++ b/index.js @@ -90,6 +90,7 @@ app.on('ready', () => { }, width: store.get('isFullscreen', false) ? width : 1200, height: 750, + focusable: process.env.NODE_ENV !== 'development' }, tray, showOnAllWorkspaces: false, From 53a9d911e91042f93172044e1ec360d2e522137f Mon Sep 17 00:00:00 2001 From: Sean Oliver <882952+seanoliver@users.noreply.github.com> Date: Sun, 30 Jul 2023 22:57:17 -0700 Subject: [PATCH 2/4] reverting focusable change --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 74f3002..ae6b56c 100644 --- a/index.js +++ b/index.js @@ -90,7 +90,7 @@ app.on('ready', () => { }, width: store.get('isFullscreen', false) ? width : 1200, height: 750, - focusable: process.env.NODE_ENV !== 'development' + // focusable: process.env.NODE_ENV !== 'development' }, tray, showOnAllWorkspaces: false, From e1097aaceaba0f5b7c0b1a27fc0ce51b9f555d3f Mon Sep 17 00:00:00 2001 From: Sean Oliver <882952+seanoliver@users.noreply.github.com> Date: Sun, 30 Jul 2023 23:52:33 -0700 Subject: [PATCH 3/4] feat(index.js) add development mode detections, refactor(index.js) modify window hiding function with manual flag, feat(index.js) add double-click on tray for quicker open. --- index.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ae6b56c..4f311d0 100644 --- a/index.js +++ b/index.js @@ -90,7 +90,6 @@ app.on('ready', () => { }, width: store.get('isFullscreen', false) ? width : 1200, height: 750, - // focusable: process.env.NODE_ENV !== 'development' }, tray, showOnAllWorkspaces: false, @@ -99,6 +98,22 @@ app.on('ready', () => { icon: image, }); + // Flag to detect if the window was hidden manually + let manualHide = false; + + // Prevent window from hiding when in development mode if not hidden manually + // (for debugging) + if (process.env.NODE_ENV === 'development') { + const originalHideWindow = mb.hideWindow.bind(mb); + + mb.hideWindow = () => { + if (manualHide) { + manualHide = false; // Reset the flag + originalHideWindow(); // Call the original hideWindow method + } + }; + } + // On menubar ready, the following code will execute mb.on('ready', () => { const { window } = mb; @@ -246,6 +261,16 @@ app.on('ready', () => { }, ]; + // FYI to the user that they are in development mode + if (process.env.NODE_ENV === 'development') { + menuHeader.unshift( + { + label: '👨‍💻 IN DEV MODE 👨‍💻', + }, + separator, + ); + } + // Return the complete context menu template return [ ...menuHeader, @@ -271,12 +296,20 @@ app.on('ready', () => { if (e.ctrlKey || e.metaKey) { const contextMenuTemplate = createContextMenuTemplate(); mb.tray.popUpContextMenu(Menu.buildFromTemplate(contextMenuTemplate)); + } else { + quickOpen(); } }); + + tray.on('double-click', () => { + quickOpen(); + }); + const menu = new Menu(); function quickOpen() { if (window.isVisible()) { + manualHide = true; // Honor manual hide in development mode mb.hideWindow(); } else { mb.showWindow(); From 17f83d00ab2a767f2fbc0ffcbd71e70472d370a6 Mon Sep 17 00:00:00 2001 From: "swyx.io" Date: Tue, 1 Aug 2023 04:06:09 +0800 Subject: [PATCH 4/4] disable hiding on click away i think this completes our transition away from a menubar app towards just a straight up full app that happens to have a keyboard shortcut to activate --- index.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/index.js b/index.js index 4f311d0..ab09785 100644 --- a/index.js +++ b/index.js @@ -415,13 +415,6 @@ app.on('ready', () => { }); }); - if (process.platform == 'darwin') { - // restore focus to previous app on hiding - mb.on('after-hide', () => { - mb.app.hide(); - }); - } - // open links in new window // app.on("web-contents-created", (event, contents) => { // contents.on("will-navigate", (event, navigationUrl) => {