Skip to content

Commit

Permalink
Implement use of nseventmonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
dbilgili committed Mar 31, 2021
1 parent d73f8e5 commit afe6a94
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/server/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ const {
const { is } = require('electron-util');
const Store = require('electron-store');
const path = require('path');
const { NSEventMonitor, NSEventMask } = require('nseventmonitor');
const TrayGenerator = require('./TrayGenerator');

const Notification = require('./Notification');

const gotTheLock = app.requestSingleInstanceLock();

const macEventMonitor = new NSEventMonitor();

const store = new Store();
// store.clear();

Expand Down Expand Up @@ -49,8 +52,10 @@ const createMainWindow = () => {
resizable: false,
webPreferences: {
devTools: is.development,
backgroundThrottling: false,
nodeIntegration: true,
backgroundThrottling: false
contextIsolation: false,
enableRemoteModule: true,
}
});

Expand All @@ -64,6 +69,9 @@ const createMainWindow = () => {
mainWindow.on('focus', () => {
globalShortcut.register('Command+R', () => null);
mainWindow.webContents.send('WINDOW_VISIBLE');
macEventMonitor.start((NSEventMask.leftMouseDown || NSEventMask.rightMouseDown), () => {
mainWindow.hide();
});
});

mainWindow.on('blur', () => {
Expand All @@ -72,9 +80,7 @@ const createMainWindow = () => {
globalShortcut.unregister('Command+R');
mainWindow.webContents.send('WINDOW_VISIBLE');
}
if (store.get('clearOnBlur')) {
mainWindow.webContents.send('CLEAR_TEXT_AREA');
}
macEventMonitor.stop();
});
};

Expand Down

0 comments on commit afe6a94

Please sign in to comment.