diff --git a/main/ipc.js b/main/ipc.js index e5b0a3a8..a147d9cb 100644 --- a/main/ipc.js +++ b/main/ipc.js @@ -82,12 +82,12 @@ function init () { ipcMain.on('onPlayerOpen', function () { menu.onPlayerOpen() - shortcuts.registerPlayerShortcuts() + shortcuts.onPlayerOpen() }) ipcMain.on('onPlayerClose', function () { menu.onPlayerClose() - shortcuts.unregisterPlayerShortcuts() + shortcuts.onPlayerOpen() }) ipcMain.on('focusWindow', function (e, windowName) { diff --git a/main/menu.js b/main/menu.js index fe8d0f36..55fea7d3 100644 --- a/main/menu.js +++ b/main/menu.js @@ -5,6 +5,8 @@ module.exports = { onToggleFullScreen, onWindowHide, onWindowShow, + + // TODO: move these out of menu.js -- they don't belong here showOpenSeedFiles, showOpenTorrentAddress, showOpenTorrentFile, diff --git a/main/shortcuts.js b/main/shortcuts.js index 664d5fc3..1ff8c127 100644 --- a/main/shortcuts.js +++ b/main/shortcuts.js @@ -1,7 +1,7 @@ module.exports = { init, - registerPlayerShortcuts, - unregisterPlayerShortcuts + onPlayerClose, + onPlayerOpen } var electron = require('electron') @@ -19,11 +19,13 @@ function init () { localShortcut.register('CmdOrCtrl+Shift+F', menu.toggleFullScreen) } -function registerPlayerShortcuts () { - // Special "media key" for play/pause, available on some keyboards - globalShortcut.register('MediaPlayPause', () => windows.main.send('dispatch', 'playPause')) +function onPlayerOpen () { + // Register special "media key" for play/pause, available on some keyboards + globalShortcut.register('MediaPlayPause', function () { + windows.main.send('dispatch', 'playPause') + }) } -function unregisterPlayerShortcuts () { +function onPlayerClose () { globalShortcut.unregister('MediaPlayPause') }