From 08948e8258b19da5e025fa853024956dd765f0b6 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Tue, 5 Apr 2016 19:31:23 -0700 Subject: [PATCH] Prevent killing the WebTorrent process Also, add shortcut for opening webtorrent inspector --- main/menu.js | 3 ++- main/windows.js | 13 +++++++++---- renderer/webtorrent.html | 25 +++++++++++++++++++++---- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/main/menu.js b/main/menu.js index c2025cb4..6626d758 100644 --- a/main/menu.js +++ b/main/menu.js @@ -67,7 +67,7 @@ function toggleDevTools () { function showWebTorrentWindow () { windows.webtorrent.show() - windows.webtorrent.webContents.openDevTools({detach: true}) + windows.webtorrent.webContents.openDevTools({ detach: true }) } function reloadWindow () { @@ -262,6 +262,7 @@ function getAppMenuTemplate () { }, { label: 'Show WebTorrent Process', + accelerator: 'CmdOrCtrl+Alt+P', click: showWebTorrentWindow }, { diff --git a/main/windows.js b/main/windows.js index 4b6d9678..add3837e 100644 --- a/main/windows.js +++ b/main/windows.js @@ -54,8 +54,8 @@ function createWebTorrentHiddenWindow () { center: true, title: 'webtorrent-hidden-window', useContentSize: true, - width: 368, - height: 388, + width: 150, + height: 150, minimizable: false, maximizable: false, resizable: false, @@ -65,8 +65,13 @@ function createWebTorrentHiddenWindow () { }) win.loadURL(config.WINDOW_WEBTORRENT) - // To debug the WebTorrent process, set `show` to true above and uncomment: - // win.webContents.openDevTools({detached: false}) + // Prevent killing the WebTorrent process + win.on('close', function (e) { + if (!electron.app.isQuitting) { + e.preventDefault() + win.hide() + } + }) } function createMainWindow () { diff --git a/renderer/webtorrent.html b/renderer/webtorrent.html index 3a2abe95..2146ee84 100644 --- a/renderer/webtorrent.html +++ b/renderer/webtorrent.html @@ -1,5 +1,22 @@ - - - - + + + + + + + + + + +