From bfa57cfda208a227a29a14146d610060adb8e3aa Mon Sep 17 00:00:00 2001 From: Seito Tanaka Date: Sun, 22 May 2022 17:32:05 +0900 Subject: [PATCH] Fix timer stopped when the window in the background (#10) --- lib/pomodoro-edit.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pomodoro-edit.js b/lib/pomodoro-edit.js index f35a005..9d119b4 100644 --- a/lib/pomodoro-edit.js +++ b/lib/pomodoro-edit.js @@ -9,6 +9,7 @@ import Core, { getReplacementRange } from '@seachicken/pomodoro-edit-core'; let _tray; let _disposables = new CompositeDisposable(); let _core; +let _backgroundThrottling; export function activate() { if (!inkdrop.isMainWindow) return; @@ -18,6 +19,9 @@ export function activate() { const modulePath = `${app.getAppPath()}/node_modules`; require(`${modulePath}/codemirror/addon/hint/show-hint`); + _backgroundThrottling = inkdrop.window.webContents.backgroundThrottling; + inkdrop.window.webContents.backgroundThrottling = false; + if (process.platform === 'win32') { _tray = new Tray(`${__dirname}/../resources/icon.ico`); } else { @@ -40,6 +44,7 @@ export function deactivate() { _core.closeServer(); _core.stopTimer(); _tray.destroy(); + inkdrop.window.webContents.backgroundThrottling = _backgroundThrottling; } function _registerCommands(editor) {