diff --git a/CHANGELOG.md b/CHANGELOG.md
index d02af607..eabdd5d3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@
#### OS X
- Fixed that two icons appear on a notification.
+- Added Option to hide Window from dock on close
### Improvements
- Added shortcuts
diff --git a/docs/setup.md b/docs/setup.md
index 8fe3f42d..8e7157a9 100644
--- a/docs/setup.md
+++ b/docs/setup.md
@@ -124,7 +124,7 @@ The Settings Page is available from the **File** menu under **Settings** (Click
This option allows such images to be rendered, but please be careful for security.
- **Start app on login** (Windows, Linux)
- This option starts the application when you login.
- - **Leave app running in notification area when the window is closed** (Windows)
+ - **Leave app running in notification area when the window is closed** (Windows, OS X)
- This option hides the window to the system tray, if the window is closed
- **Toggle window visibility when clicking on the tray icon** (Windows)
- If checked, then a click on the system tray icon leads to a toggling of the minimized/maximized state of the window
diff --git a/src/browser/settings.jsx b/src/browser/settings.jsx
index f6a7fbb6..b1e3ed52 100644
--- a/src/browser/settings.jsx
+++ b/src/browser/settings.jsx
@@ -102,9 +102,16 @@ var SettingsPage = React.createClass({
});
},
handleChangeShowTrayIcon: function() {
+ var shouldShowTrayIcon = this.refs.showTrayIcon.getChecked();
this.setState({
- showTrayIcon: this.refs.showTrayIcon.getChecked()
+ showTrayIcon: shouldShowTrayIcon
});
+
+ if (process.platform === 'darwin' && !shouldShowTrayIcon) {
+ this.setState({
+ minimizeToTray: false
+ });
+ }
},
handleChangeTrayIconTheme: function() {
this.setState({
@@ -117,8 +124,11 @@ var SettingsPage = React.createClass({
});
},
handleChangeMinimizeToTray: function() {
+ var shouldMinimizeToTray = (process.platform !== 'darwin' || this.refs.showTrayIcon.getChecked())
+ && this.refs.minimizeToTray.getChecked();
+
this.setState({
- minimizeToTray: this.refs.minimizeToTray.getChecked()
+ minimizeToTray: shouldMinimizeToTray
});
},
handleChangeToggleWindowOnTrayIconClick: function() {
@@ -172,6 +182,12 @@ var SettingsPage = React.createClass({
if (process.platform === 'win32') {
options.push();
+ } else if (process.platform === 'darwin') {
+ options.push();
+ }
+
+ if (process.platform === 'win32') {
options.push();
}
diff --git a/src/main.js b/src/main.js
index ab5c74b3..e63aa2fa 100644
--- a/src/main.js
+++ b/src/main.js
@@ -241,10 +241,22 @@ app.on('ready', function() {
mainWindow.focus();
}
}
+ else if (process.platform === 'darwin') {
+ if (mainWindow.isHidden || mainWindow.isMinimized()) {
+ mainWindow.show();
+ mainWindow.isHidden = false;
+ mainWindow.focus();
+ app.dock.show();
+ }
+ else {
+ mainWindow.focus();
+ }
+ }
else {
mainWindow.focus();
}
});
+
trayIcon.on('right-click', () => {
trayIcon.popUpContextMenu();
});
@@ -380,7 +392,14 @@ app.on('ready', function() {
mainWindow.minimize();
break;
case 'darwin':
- mainWindow.hide();
+ if (config.minimizeToTray) {
+ mainWindow.hide();
+ app.dock.hide();
+ mainWindow.isHidden = true;
+ }
+ else {
+ mainWindow.minimize();
+ }
break;
default:
}
diff --git a/src/main/menus/tray.js b/src/main/menus/tray.js
index a537c408..9e6291f0 100644
--- a/src/main/menus/tray.js
+++ b/src/main/menus/tray.js
@@ -11,6 +11,12 @@ function createDefault(mainWindow) {
label: `Open ${app.getName()}`,
click: () => {
mainWindow.show();
+ mainWindow.isHidden = false;
+
+ if (process.platform === 'darwin') {
+ app.dock.show();
+ mainWindow.focus();
+ }
}
}, {
type: 'separator'
diff --git a/test/specs/browser/settings_test.js b/test/specs/browser/settings_test.js
index 0bd050a8..14aa7f73 100644
--- a/test/specs/browser/settings_test.js
+++ b/test/specs/browser/settings_test.js
@@ -152,8 +152,8 @@ describe('browser/settings.html', function() {
});
describe('Minimize to tray', function() {
- it('should appear win32', function() {
- const expected = (process.platform === 'win32');
+ it('should appear on win32 and darwin', function() {
+ const expected = (process.platform === 'win32' || process.platform === 'darwin');
env.addClientCommands(this.app.client);
return this.app.client
.loadSettingsPage()
@@ -162,7 +162,7 @@ describe('browser/settings.html', function() {
});
describe('Toggle window visibility when clicking on the tray icon', function() {
- it('should appear win32', function() {
+ it('should appear on win32', function() {
const expected = (process.platform === 'win32');
env.addClientCommands(this.app.client);
return this.app.client