Skip to content

Commit

Permalink
Remove focusWindow function
Browse files Browse the repository at this point in the history
Not needed -- win.show() automatically focuses, unminimizes, and shows
the window.
  • Loading branch information
feross committed May 29, 2016
1 parent 7833f6b commit d4efebd
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 28 deletions.
4 changes: 2 additions & 2 deletions main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions main/ipc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand All @@ -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.
Expand Down
6 changes: 2 additions & 4 deletions main/windows/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
7 changes: 1 addition & 6 deletions main/windows/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var main = module.exports = {
create,
focus,
hide,
send,
show,
Expand All @@ -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',
Expand Down Expand Up @@ -109,7 +107,4 @@ function hide () {
main.win.hide()
}

function focus () {
if (!main.win) return
util.focusWindow(main.win)
}
11 changes: 0 additions & 11 deletions main/windows/util.js

This file was deleted.

2 changes: 1 addition & 1 deletion renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ function showDoneNotification (torrent) {
})

notif.onclick = function () {
ipcRenderer.send('focusWindow', 'main')
ipcRenderer.send('show')
}

sound.play('DONE')
Expand Down

0 comments on commit d4efebd

Please sign in to comment.