Fix #176: close window on OSX
This commit is contained in:
@@ -66,10 +66,10 @@ function setBounds (bounds, maximize) {
|
|||||||
// Maximize or minimize, if the second argument is present
|
// Maximize or minimize, if the second argument is present
|
||||||
var willBeMaximized
|
var willBeMaximized
|
||||||
if (maximize === true) {
|
if (maximize === true) {
|
||||||
if (!windows.main.isMaximized) windows.main.maximize()
|
if (!windows.main.isMaximized()) windows.main.maximize()
|
||||||
willBeMaximized = true
|
willBeMaximized = true
|
||||||
} else if (maximize === false) {
|
} else if (maximize === false) {
|
||||||
if (windows.main.isMaximized) windows.main.unmaximize()
|
if (windows.main.isMaximized()) windows.main.unmaximize()
|
||||||
willBeMaximized = false
|
willBeMaximized = false
|
||||||
} else {
|
} else {
|
||||||
willBeMaximized = windows.main.isMaximized()
|
willBeMaximized = windows.main.isMaximized()
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ var windows = module.exports = {
|
|||||||
var electron = require('electron')
|
var electron = require('electron')
|
||||||
|
|
||||||
var app = electron.app
|
var app = electron.app
|
||||||
var ipcMain = electron.ipcMain
|
|
||||||
|
|
||||||
var config = require('../config')
|
var config = require('../config')
|
||||||
var menu = require('./menu')
|
var menu = require('./menu')
|
||||||
@@ -44,14 +43,8 @@ function createMainWindow () {
|
|||||||
win.on('close', function (e) {
|
win.on('close', function (e) {
|
||||||
if (process.platform === 'darwin' && !app.isQuitting) {
|
if (process.platform === 'darwin' && !app.isQuitting) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
// When the window is hidden, the update() loop (which uses
|
|
||||||
// requestAnimationFrame) ceases to run. We need to make sure
|
|
||||||
// the video pauses before hiding or it will continue to play.
|
|
||||||
|
|
||||||
win.send('dispatch', 'pause')
|
win.send('dispatch', 'pause')
|
||||||
ipcMain.once('paused-video', function (e) {
|
|
||||||
win.hide()
|
win.hide()
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -225,6 +225,12 @@ function dispatch (action, ...args) {
|
|||||||
if (action === 'playPause') {
|
if (action === 'playPause') {
|
||||||
playPause()
|
playPause()
|
||||||
}
|
}
|
||||||
|
if (action === 'play') {
|
||||||
|
playPause(false)
|
||||||
|
}
|
||||||
|
if (action === 'pause') {
|
||||||
|
playPause(true)
|
||||||
|
}
|
||||||
if (action === 'playbackJump') {
|
if (action === 'playbackJump') {
|
||||||
jumpToTime(args[0] /* seconds */)
|
jumpToTime(args[0] /* seconds */)
|
||||||
}
|
}
|
||||||
@@ -234,7 +240,6 @@ function dispatch (action, ...args) {
|
|||||||
}
|
}
|
||||||
if (action === 'videoPaused') {
|
if (action === 'videoPaused') {
|
||||||
state.video.isPaused = true
|
state.video.isPaused = true
|
||||||
ipcRenderer.send('paused-video')
|
|
||||||
ipcRenderer.send('unblockPowerSave')
|
ipcRenderer.send('unblockPowerSave')
|
||||||
}
|
}
|
||||||
if (action === 'toggleFullScreen') {
|
if (action === 'toggleFullScreen') {
|
||||||
@@ -251,7 +256,12 @@ function dispatch (action, ...args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function playPause () {
|
// Plays or pauses the video. If isPaused is undefined, acts as a toggle
|
||||||
|
function playPause (isPaused) {
|
||||||
|
if (isPaused === state.video.isPaused) {
|
||||||
|
return // Nothing to do
|
||||||
|
}
|
||||||
|
// Either isPaused is undefined, or it's the opposite of the current state. Toggle.
|
||||||
if (Cast.isCasting()) {
|
if (Cast.isCasting()) {
|
||||||
Cast.playPause()
|
Cast.playPause()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module.exports = {
|
|||||||
video: { /* state of the video player screen */
|
video: { /* state of the video player screen */
|
||||||
currentTime: 0, /* seconds */
|
currentTime: 0, /* seconds */
|
||||||
duration: 1, /* seconds */
|
duration: 1, /* seconds */
|
||||||
isPaused: false,
|
isPaused: true,
|
||||||
mouseStationarySince: 0 /* Unix time in ms */
|
mouseStationarySince: 0 /* Unix time in ms */
|
||||||
},
|
},
|
||||||
dock: {
|
dock: {
|
||||||
|
|||||||
Reference in New Issue
Block a user