ELECTRON-647 - Fixing fullscreen mode disappears after reloading app (#482)

This commit is contained in:
VICTOR RAPHAEL BRAGA DE SALES MASCARENHAS
2018-08-29 13:59:40 -03:00
committed by Vishwas Shashidhar
parent 154b66e195
commit 558f2cb61e
2 changed files with 9 additions and 10 deletions

View File

@@ -19,7 +19,7 @@ const apiCmds = apiEnums.cmds;
const apiName = apiEnums.apiName;
const getMediaSources = require('../desktopCapturer/getSources');
const getMediaSource = require('../desktopCapturer/getSource');
const { TitleBar, updateContentHeight } = require('../windowsTitlebar');
const { TitleBar } = require('../windowsTitlebar');
const titleBar = new TitleBar();
const { buildNumber } = require('../../package.json');
const memoryMonitorInterval = 1000 * 60 * 60;
@@ -479,7 +479,6 @@ function createAPI() {
local.ipcRenderer.on('initiate-windows-title-bar', (event, arg) => {
if (arg && typeof arg === 'string') {
titleBar.initiateWindowsTitleBar(arg);
updateContentHeight();
}
});

View File

@@ -32,19 +32,18 @@ class TitleBar {
}
const updateIcon = TitleBar.updateIcons;
const updateTitleBar = TitleBar.updateTitleBar;
// Event to capture and update icons
this.window.on('maximize', updateIcon.bind(this, true));
this.window.on('unmaximize', updateIcon.bind(this, false));
this.window.on('enter-full-screen', updateTitleBar.bind(this, true));
this.window.on('leave-full-screen', updateTitleBar.bind(this, false));
this.window.on('enter-full-screen', this.updateTitleBar.bind(this, true));
this.window.on('leave-full-screen', this.updateTitleBar.bind(this, false));
window.addEventListener('beforeunload', () => {
this.window.removeListener('maximize', updateIcon);
this.window.removeListener('unmaximize', updateIcon);
this.window.removeListener('enter-full-screen', updateTitleBar);
this.window.removeListener('leave-full-screen', updateTitleBar);
this.window.removeListener('enter-full-screen', this.updateTitleBar);
this.window.removeListener('leave-full-screen', this.updateTitleBar);
});
document.body.appendChild(this.titleBar);
@@ -66,6 +65,8 @@ class TitleBar {
this.closeButton = document.getElementById('title-bar-close-button');
this.initiateEventListeners();
this.updateTitleBar(this.window.isFullScreen());
}
/**
@@ -154,7 +155,7 @@ class TitleBar {
* based on the full screen event
* @param isFullScreen {Boolean}
*/
static updateTitleBar(isFullScreen) {
updateTitleBar(isFullScreen) {
if (isFullScreen) {
this.titleBar.style.display = 'none';
updateContentHeight('0px');
@@ -266,6 +267,5 @@ function updateContentHeight(height = titleBarHeight) {
}
module.exports = {
TitleBar,
updateContentHeight
TitleBar
};