From 77a103fbf1159771d4af12ac56e88b8d186751e5 Mon Sep 17 00:00:00 2001 From: James Hall Date: Thu, 4 Aug 2016 01:52:31 +0100 Subject: [PATCH] [WIP] Add proper window support (#547) * Add proper window support to both the top menu, and the dock * Sort out linting * Only create dockMenu on Mac * Remove label from menu as it is not needed when using role * Fix spacing --- app/index.js | 16 +++++++++++++--- app/menu.js | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/index.js b/app/index.js index 80bba5df..e0879f42 100644 --- a/app/index.js +++ b/app/index.js @@ -97,7 +97,6 @@ app.on('ready', () => { const browserOptions = plugins.getDecoratedBrowserOptions(browserDefaults); const win = new BrowserWindow(browserOptions); - windowSet.add(win); win.loadURL(url); @@ -159,6 +158,7 @@ app.on('ready', () => { }); session.on('title', (title) => { + win.setTitle(title); rpc.emit('session title', { uid, title }); }); @@ -174,14 +174,15 @@ app.on('ready', () => { // on Session and focus/blur to subscribe rpc.on('focus', ({ uid }) => { const session = sessions.get(uid); - + if (typeof session !== 'undefined' && typeof session.lastTitle !== 'undefined') { + win.setTitle(session.lastTitle); + } if (session) { session.focus(); } else { console.log('session not found by', uid); } }); - rpc.on('blur', ({ uid }) => { const session = sessions.get(uid); @@ -309,6 +310,15 @@ app.on('ready', () => { } })); + // If we're on Mac make a Dock Menu + if (process.platform === 'darwin') { + const { app, Menu } = require('electron'); + const dockMenu = Menu.buildFromTemplate([ + {label: 'New Window', click () { createWindow(); }} + ]); + app.dock.setMenu(dockMenu); + } + Menu.setApplicationMenu(Menu.buildFromTemplate(tpl)); }; diff --git a/app/menu.js b/app/menu.js index 1c0b8677..aba49ed8 100644 --- a/app/menu.js +++ b/app/menu.js @@ -208,7 +208,7 @@ module.exports = function createMenu ({ createWindow, updatePlugins }) { ] }, { - label: 'Window', + role: 'window', submenu: [ { role: 'minimize'