summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-03-05 19:53:53 +0100
committerAndrej Mihajlov <and@mullvad.net>2018-03-07 11:51:31 +0100
commit203e57d687804f0cc4cb7f33b5f5b4ab055a91bd (patch)
tree71f463442c0e738009e913414d7247512b6e84c0 /app
parent2de1c162aeb0214e6afd95c42655d0653ac28bff (diff)
downloadmullvadvpn-203e57d687804f0cc4cb7f33b5f5b4ab055a91bd.tar.xz
mullvadvpn-203e57d687804f0cc4cb7f33b5f5b4ab055a91bd.zip
Move macOS patch for window.blur into separate method
Diffstat (limited to 'app')
-rw-r--r--app/main.js35
1 files changed, 20 insertions, 15 deletions
diff --git a/app/main.js b/app/main.js
index 4d7dcd408a..bfb8c85af8 100644
--- a/app/main.js
+++ b/app/main.js
@@ -483,29 +483,34 @@ const appDelegate = {
tray.setHighlightMode('never');
tray.on('click', () => appDelegate._toggleWindow(window, tray));
- const trayIconManager = new TrayIconManager(tray, 'unsecured');
-
- // setup NSEvent monitor to fix inconsistent window.blur
- // see https://github.com/electron/electron/issues/8689
- // $FlowFixMe: this module is only available on macOS
- if(process.platform === 'darwin') {
- const { NSEventMonitor, NSEventMask } = require('nseventmonitor');
- const macEventMonitor = new NSEventMonitor();
- const eventMask = NSEventMask.leftMouseDown | NSEventMask.rightMouseDown;
-
- window.on('show', () => macEventMonitor.start(eventMask, () => window.hide()));
- window.on('hide', () => macEventMonitor.stop());
- }
-
// add IPC handler to change tray icon from renderer
+ const trayIconManager = new TrayIconManager(tray, 'unsecured');
ipcMain.on('changeTrayIcon', (_: Event, type: TrayIconType) => trayIconManager.iconType = type);
// setup event handlers
window.on('close', () => window.closeDevTools());
window.on('blur', () => !window.isDevToolsOpened() && window.hide());
+ // apply macOS patch for windows.blur
+ if(process.platform === 'darwin') {
+ appDelegate._macOSFixInconsistentWindowBlur(window);
+ }
+
return tray;
- }
+ },
+
+ // setup NSEvent monitor to fix inconsistent window.blur on macOS
+ // see https://github.com/electron/electron/issues/8689
+ _macOSFixInconsistentWindowBlur: (window: BrowserWindow) => {
+ // $FlowFixMe: this module is only available on macOS
+ const { NSEventMonitor, NSEventMask } = require('nseventmonitor');
+ const macEventMonitor = new NSEventMonitor();
+ const eventMask = NSEventMask.leftMouseDown | NSEventMask.rightMouseDown;
+
+ window.on('show', () => macEventMonitor.start(eventMask, () => window.hide()));
+ window.on('hide', () => macEventMonitor.stop());
+ },
+
};
appDelegate.setup();