-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev mode #99
Merged
Merged
Dev mode #99
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9981770
feat(index) menubar stays open in development for debugging
seanoliver 53a9d91
reverting focusable change
seanoliver 4a415bc
Merge branch 'main' of https://github.com/smol-ai/menubar into dev-mode
seanoliver e1097aa
feat(index.js) add development mode detections, refactor(index.js) mo…
seanoliver 17f83d0
disable hiding on click away
swyxio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
|
@@ -382,13 +415,6 @@ app.on('ready', () => { | |
}); | ||
}); | ||
|
||
if (process.platform == 'darwin') { | ||
// restore focus to previous app on hiding | ||
mb.on('after-hide', () => { | ||
mb.app.hide(); | ||
}); | ||
} | ||
|
||
Comment on lines
-385
to
-391
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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 |
||
// open links in new window | ||
// app.on("web-contents-created", (event, contents) => { | ||
// contents.on("will-navigate", (event, navigationUrl) => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did this break the click open?