handle macOS activate

This commit is contained in:
Guillermo Rauch 2016-07-01 17:02:08 -07:00
parent a4bfd0ae1e
commit 624b7c3992
2 changed files with 15 additions and 2 deletions

View file

@ -3,7 +3,8 @@
## TODO ## TODO
- [ ] Listen on `resize` event *coming* from the pty. - [ ] Listen on `resize` event *coming* from the pty.
- [ ] Add support for zsh and other popular shells - [ ] Make sure all popular shells work well, and that we detect
"url commands" appropriately for them.
- [ ] Figure out process title extraction on other platforms. - [ ] Figure out process title extraction on other platforms.
- [ ] Define extensibility surface and APIs - [ ] Define extensibility surface and APIs
- [ ] Define approach to conf management (`~/.hyperterm.json` ?) - [ ] Define approach to conf management (`~/.hyperterm.json` ?)

View file

@ -28,6 +28,8 @@ app.on('window-all-closed', () => {
// terminal is closed // terminal is closed
}); });
let winCount = 0;
app.on('ready', () => { app.on('ready', () => {
function createWindow (fn) { function createWindow (fn) {
let win = new BrowserWindow({ let win = new BrowserWindow({
@ -41,7 +43,7 @@ app.on('ready', () => {
// is ready for user input // is ready for user input
show: process.env.HYPERTERM_DEBUG || isDev show: process.env.HYPERTERM_DEBUG || isDev
}); });
winCount++;
win.loadURL(url); win.loadURL(url);
const rpc = createRPC(win); const rpc = createRPC(win);
@ -117,6 +119,7 @@ app.on('ready', () => {
win.on('close', () => { win.on('close', () => {
rpc.destroy(); rpc.destroy();
deleteSessions(); deleteSessions();
winCount--;
}); });
win.rpc = rpc; win.rpc = rpc;
@ -125,6 +128,15 @@ app.on('ready', () => {
// when opening create a new window // when opening create a new window
createWindow(); createWindow();
// mac only. when the dock icon is clicked
// and we don't have any active windows open,
// we open one
app.on('activate', () => {
if (!winCount) {
createWindow();
}
});
// set menu // set menu
Menu.setApplicationMenu(Menu.buildFromTemplate([ Menu.setApplicationMenu(Menu.buildFromTemplate([
{ {