From 72f917a7445397660a9655ebc620819fb0d4ae78 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 11 May 2016 23:43:27 +0200 Subject: [PATCH] OS X: Make controls use full window in fullscreen This bug was subtle. Basically, on OS X only, we use window.setAspectRatio() to make the player window match the video size. But this is maintained even in fullscreen mode, which makes the window actually not use up the fullscreen, and there are black bars above and below the video player controls, which looks really weird. Unset the aspect ratio in fullscreen mode, then set it again upon leaving fullscreen mode. --- main/menu.js | 4 ++++ renderer/index.js | 5 +++++ renderer/state.js | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/main/menu.js b/main/menu.js index be02e166..e897d112 100644 --- a/main/menu.js +++ b/main/menu.js @@ -35,6 +35,10 @@ function toggleFullScreen (flag) { log('toggleFullScreen %s', flag) if (windows.main && windows.main.isVisible()) { flag = flag != null ? flag : !windows.main.isFullScreen() + if (flag) { + // Allows the window to use the full screen in fullscreen mode (OS X). + windows.main.setAspectRatio(0) + } windows.main.setFullScreen(flag) } } diff --git a/renderer/index.js b/renderer/index.js index 46c31a0c..c0f0d18e 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -441,6 +441,10 @@ function setupIpc () { ipcRenderer.on('fullscreenChanged', function (e, isFullScreen) { state.window.isFullScreen = isFullScreen + if (!isFullScreen) { + // Aspect ratio gets reset in fullscreen mode, so restore it (OS X) + ipcRenderer.send('setAspectRatio', state.playing.aspectRatio) + } update() }) @@ -1079,6 +1083,7 @@ function setDimensions (dimensions) { ipcRenderer.send('setAspectRatio', aspectRatio) ipcRenderer.send('setBounds', {x: null, y: null, width, height}) + state.playing.aspectRatio = aspectRatio } function restoreBounds () { diff --git a/renderer/state.js b/renderer/state.js index 70edab78..0f1a3867 100644 --- a/renderer/state.js +++ b/renderer/state.js @@ -77,7 +77,8 @@ function getDefaultPlayState () { subtitles: { tracks: [], /* subtitles file (Buffer) */ enabled: false - } + }, + aspectRatio: 0 /* aspect ratio of the video */ } }