From d4efebd694c88b1685db8462fe1f2fdf4c21cdf9 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 28 May 2016 19:10:55 -0700 Subject: [PATCH] Remove focusWindow function Not needed -- win.show() automatically focuses, unminimizes, and shows the window. --- main/index.js | 4 ++-- main/ipc.js | 5 +---- main/windows/about.js | 6 ++---- main/windows/main.js | 7 +------ main/windows/util.js | 11 ----------- renderer/main.js | 2 +- 6 files changed, 7 insertions(+), 28 deletions(-) delete mode 100644 main/windows/util.js diff --git a/main/index.js b/main/index.js index 79ad638979..eebdc44dec 100644 --- a/main/index.js +++ b/main/index.js @@ -106,7 +106,7 @@ function onOpen (e, torrentId) { // The confirmation dialog Chrome shows causes Chrome to steal back the focus. // Electron issue: https://github.com/atom/electron/issues/4338 setTimeout(function () { - windows.main.focus() + windows.main.show() }, 100) } else { argv.push(torrentId) @@ -119,7 +119,7 @@ function onAppOpen (newArgv) { if (app.ipcReady) { log('Second app instance opened, but was prevented:', newArgv) - windows.main.focus() + windows.main.show() processArgv(newArgv) } else { diff --git a/main/ipc.js b/main/ipc.js index 6498f21e5d..c03c9cb099 100644 --- a/main/ipc.js +++ b/main/ipc.js @@ -65,6 +65,7 @@ function init () { }) ipcMain.on('openItem', function (e, path) { + ipc.on('show', (e, ...args) => windows.main.show(...args)) log('open item: ' + path) electron.shell.openItem(path) }) @@ -87,10 +88,6 @@ function init () { shortcuts.onPlayerOpen() }) - ipcMain.on('focusWindow', function (e, windowName) { - windows.focusWindow(windows[windowName]) - }) - ipcMain.on('downloadFinished', function (e, filePath) { if (app.dock) { // Bounces the Downloads stack if the filePath is inside the Downloads folder. diff --git a/main/windows/about.js b/main/windows/about.js index 0022c6e9c5..31e27f69af 100644 --- a/main/windows/about.js +++ b/main/windows/about.js @@ -3,14 +3,12 @@ var about = module.exports = { win: null } -var electron = require('electron') - var config = require('../../config') -var util = require('./util') +var electron = require('electron') function create () { if (about.win) { - return util.focusWindow(about.win) + return about.win.show() } var win = about.win = new electron.BrowserWindow({ diff --git a/main/windows/main.js b/main/windows/main.js index 29c52b0654..c60251e574 100644 --- a/main/windows/main.js +++ b/main/windows/main.js @@ -1,6 +1,5 @@ var main = module.exports = { create, - focus, hide, send, show, @@ -16,14 +15,13 @@ var config = require('../../config') var log = require('../log') var menu = require('../menu') var tray = require('../tray') -var util = require('./util') var HEADER_HEIGHT = 37 var TORRENT_HEIGHT = 100 function create () { if (main.win) { - return util.focusWindow(main.win) + return main.win.show() } var win = main.win = new electron.BrowserWindow({ backgroundColor: '#1E1E1E', @@ -109,7 +107,4 @@ function hide () { main.win.hide() } -function focus () { - if (!main.win) return - util.focusWindow(main.win) } diff --git a/main/windows/util.js b/main/windows/util.js deleted file mode 100644 index d927ed2546..0000000000 --- a/main/windows/util.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - focusWindow -} - -function focusWindow (win) { - if (win.isMinimized()) { - // TODO: can this be removed? - win.restore() - } - win.show() // shows and gives focus -} diff --git a/renderer/main.js b/renderer/main.js index 19ad69fd82..3e7c4b536c 100644 --- a/renderer/main.js +++ b/renderer/main.js @@ -1320,7 +1320,7 @@ function showDoneNotification (torrent) { }) notif.onclick = function () { - ipcRenderer.send('focusWindow', 'main') + ipcRenderer.send('show') } sound.play('DONE')