diff --git a/app/scripts/comp/launcher.js b/app/scripts/comp/launcher.js index cdf26649..77c3491e 100644 --- a/app/scripts/comp/launcher.js +++ b/app/scripts/comp/launcher.js @@ -54,7 +54,7 @@ if (window.process && window.process.versions && window.process.versions.electro return false; }, exit: function() { - Launcher.exitRequested = true; + this.exitRequested = true; this.requestExit(); }, requestExit: function() { @@ -85,6 +85,9 @@ if (window.process && window.process.versions && window.process.versions.electro return process.platform === 'win32'; } }; + Backbone.on('launcher-exit-request', function() { + setTimeout(function() { Launcher.exit(); }, 0); + }); window.launcherOpen = function(path) { Backbone.trigger('launcher-open-file', path); }; diff --git a/electron/app.js b/electron/app.js index c045e628..27531606 100644 --- a/electron/app.js +++ b/electron/app.js @@ -10,6 +10,7 @@ var app = require('app'), Tray = require('tray'); var mainWindow = null, + appIcon = null, openFile = process.argv.filter(function(arg) { return /\.kdbx$/i.test(arg); })[0], ready = false, restartPending = false, @@ -65,15 +66,30 @@ app.minimizeApp = function() { if (process.platform === 'win32') { mainWindow.minimize(); mainWindow.setSkipTaskbar(true); - var appIcon = new Tray(path.join(__dirname, 'icon.png')); - appIcon.on('clicked', function () { - mainWindow.restore(); - mainWindow.setSkipTaskbar(false); - }); + appIcon = new Tray(path.join(__dirname, 'icon.png')); + appIcon.on('clicked', restoreMainWindow); + var contextMenu = Menu.buildFromTemplate([ + { label: 'Open KeeWeb', click: restoreMainWindow }, + { label: 'Quit KeeWeb', click: closeMainWindow } + ]); + appIcon.setContextMenu(contextMenu); appIcon.setToolTip('KeeWeb'); } }; +function restoreMainWindow() { + appIcon.destroy(); + appIcon = null; + mainWindow.restore(); + mainWindow.setSkipTaskbar(false); +} + +function closeMainWindow() { + appIcon.destroy(); + appIcon = null; + mainWindow.webContents.executeJavaScript('Backbone.trigger("launcher-exit-request");'); +} + function setMenu() { if (process.platform === 'darwin') { var name = require('app').getName(); diff --git a/electron/package.json b/electron/package.json index 11a4afef..6abb972e 100644 --- a/electron/package.json +++ b/electron/package.json @@ -1,6 +1,6 @@ { "name": "KeeWeb", - "version": "0.4.2", + "version": "0.4.3", "description": "KeePass web app", "main": "main.js", "repository": "https://github.com/antelle/keeweb", diff --git a/package.json b/package.json index 6c606b0d..589e8acb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "keeweb", - "version": "0.4.2", + "version": "0.4.3", "description": "KeePass web app", "main": "Gruntfile.js", "repository": "https://github.com/antelle/keeweb", diff --git a/release-notes.md b/release-notes.md index 31a86938..6ec211f6 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,7 +1,10 @@ Release notes ------------- +##### v0.4.3 (2015-11-22) +Windows minimize to tray bugfix + ##### v0.4.1, v0.4.2 (2015-11-22) -Auto-update bugfixes +Auto-update and bugfixes ##### v0.4.0 (2015-11-22) Locking, better Dropbox, custom icons, security enhancements, bugfixes