Remove focusWindow function
Not needed -- win.show() automatically focuses, unminimizes, and shows the window.
This commit is contained in:
@@ -106,7 +106,7 @@ function onOpen (e, torrentId) {
|
|||||||
// The confirmation dialog Chrome shows causes Chrome to steal back the focus.
|
// The confirmation dialog Chrome shows causes Chrome to steal back the focus.
|
||||||
// Electron issue: https://github.com/atom/electron/issues/4338
|
// Electron issue: https://github.com/atom/electron/issues/4338
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
windows.main.focus()
|
windows.main.show()
|
||||||
}, 100)
|
}, 100)
|
||||||
} else {
|
} else {
|
||||||
argv.push(torrentId)
|
argv.push(torrentId)
|
||||||
@@ -119,7 +119,7 @@ function onAppOpen (newArgv) {
|
|||||||
|
|
||||||
if (app.ipcReady) {
|
if (app.ipcReady) {
|
||||||
log('Second app instance opened, but was prevented:', newArgv)
|
log('Second app instance opened, but was prevented:', newArgv)
|
||||||
windows.main.focus()
|
windows.main.show()
|
||||||
|
|
||||||
processArgv(newArgv)
|
processArgv(newArgv)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ function init () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('openItem', function (e, path) {
|
ipcMain.on('openItem', function (e, path) {
|
||||||
|
ipc.on('show', (e, ...args) => windows.main.show(...args))
|
||||||
log('open item: ' + path)
|
log('open item: ' + path)
|
||||||
electron.shell.openItem(path)
|
electron.shell.openItem(path)
|
||||||
})
|
})
|
||||||
@@ -87,10 +88,6 @@ function init () {
|
|||||||
shortcuts.onPlayerOpen()
|
shortcuts.onPlayerOpen()
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('focusWindow', function (e, windowName) {
|
|
||||||
windows.focusWindow(windows[windowName])
|
|
||||||
})
|
|
||||||
|
|
||||||
ipcMain.on('downloadFinished', function (e, filePath) {
|
ipcMain.on('downloadFinished', function (e, filePath) {
|
||||||
if (app.dock) {
|
if (app.dock) {
|
||||||
// Bounces the Downloads stack if the filePath is inside the Downloads folder.
|
// Bounces the Downloads stack if the filePath is inside the Downloads folder.
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ var about = module.exports = {
|
|||||||
win: null
|
win: null
|
||||||
}
|
}
|
||||||
|
|
||||||
var electron = require('electron')
|
|
||||||
|
|
||||||
var config = require('../../config')
|
var config = require('../../config')
|
||||||
var util = require('./util')
|
var electron = require('electron')
|
||||||
|
|
||||||
function create () {
|
function create () {
|
||||||
if (about.win) {
|
if (about.win) {
|
||||||
return util.focusWindow(about.win)
|
return about.win.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
var win = about.win = new electron.BrowserWindow({
|
var win = about.win = new electron.BrowserWindow({
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
var main = module.exports = {
|
var main = module.exports = {
|
||||||
create,
|
create,
|
||||||
focus,
|
|
||||||
hide,
|
hide,
|
||||||
send,
|
send,
|
||||||
show,
|
show,
|
||||||
@@ -16,14 +15,13 @@ var config = require('../../config')
|
|||||||
var log = require('../log')
|
var log = require('../log')
|
||||||
var menu = require('../menu')
|
var menu = require('../menu')
|
||||||
var tray = require('../tray')
|
var tray = require('../tray')
|
||||||
var util = require('./util')
|
|
||||||
|
|
||||||
var HEADER_HEIGHT = 37
|
var HEADER_HEIGHT = 37
|
||||||
var TORRENT_HEIGHT = 100
|
var TORRENT_HEIGHT = 100
|
||||||
|
|
||||||
function create () {
|
function create () {
|
||||||
if (main.win) {
|
if (main.win) {
|
||||||
return util.focusWindow(main.win)
|
return main.win.show()
|
||||||
}
|
}
|
||||||
var win = main.win = new electron.BrowserWindow({
|
var win = main.win = new electron.BrowserWindow({
|
||||||
backgroundColor: '#1E1E1E',
|
backgroundColor: '#1E1E1E',
|
||||||
@@ -109,7 +107,4 @@ function hide () {
|
|||||||
main.win.hide()
|
main.win.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
function focus () {
|
|
||||||
if (!main.win) return
|
|
||||||
util.focusWindow(main.win)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -1320,7 +1320,7 @@ function showDoneNotification (torrent) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
notif.onclick = function () {
|
notif.onclick = function () {
|
||||||
ipcRenderer.send('focusWindow', 'main')
|
ipcRenderer.send('show')
|
||||||
}
|
}
|
||||||
|
|
||||||
sound.play('DONE')
|
sound.play('DONE')
|
||||||
|
|||||||
Reference in New Issue
Block a user