Skip to content

Commit

Permalink
fix(windows): try fix html fullscreen but failed
Browse files Browse the repository at this point in the history
  • Loading branch information
ipy committed Sep 17, 2019
1 parent 0309d29 commit 33c9f45
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/main/helpers/BrowserViewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class BrowserViewManager implements IBrowserViewManager {
webPreferences: {
preload: `${require('path').resolve(__static, 'pip/preload.js')}`,
nativeWindowOpen: true,
// disableHtmlFullscreenWindowResize: true, // Electron 6 required
},
}),
};
Expand Down
42 changes: 26 additions & 16 deletions src/main/helpers/electronPrototypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,28 +117,38 @@ if (process.platform !== 'darwin') {
}
};

// fix isMaximized always returns false
const originMaximize = BrowserWindow.prototype.maximize;
BrowserWindow.prototype.maximize = function maximize(...args) {
this._isMaximized = true;
originMaximize.apply(this, args);
};
const originUnmaximize = BrowserWindow.prototype.unmaximize;
BrowserWindow.prototype.unmaximize = function unmaximize(...args) {
this._isMaximized = false;
originUnmaximize.apply(this, args);
// fix isMaximized and isFullScreen always returns false
const originLoadURL = BrowserWindow.prototype.loadURL;
BrowserWindow.prototype.loadURL = function loadURl(...args) {
if (!this._customPrototypeInited) {
this._customPrototypeInited = true;
this.on('maximize', function onMaximize() {
this._isMaximized = true;
});
this.on('unmaximize', function onUnmaximize() {
this._isMaximized = false;
});
this.on('enter-full-screen', function onEnterFullScreen() {
this._isFullScreen = true;
});
this.on('leave-full-screen', function onLeaveFullScreen() {
this._isFullScreen = false;
});
this.on('enter-html-full-screen', function onEnterFullScreen() {
this._isFullScreen = true;
});
this.on('leave-html-full-screen', function onLeaveFullScreen() {
this._isFullScreen = false;
});
}
originLoadURL.apply(this, args);
};

const originIsMaximize = BrowserWindow.prototype.isMaximized;
BrowserWindow.prototype.isMaximized = function isMaximized(...args) {
return originIsMaximize.apply(this, args) || this._isMaximized;
};

// fix isFullScreen always returns false
const originSetFullScreen = BrowserWindow.prototype.setFullScreen;
BrowserWindow.prototype.setFullScreen = function setFullScreen(isFullScreen, ...args) {
this._isFullScreen = isFullScreen;
originSetFullScreen.call(this, isFullScreen, ...args);
};
const originIsFullScreen = BrowserWindow.prototype.isFullScreen;
BrowserWindow.prototype.isFullScreen = function isFullScreen(...args) {
return originIsFullScreen.apply(this, args) || this._isFullScreen;
Expand Down

0 comments on commit 33c9f45

Please sign in to comment.