Skip to content

Commit

Permalink
Merge pull request #966 from ipy/develop
Browse files Browse the repository at this point in the history
fix(windows): fix isMaximized and isFullScreen
  • Loading branch information
ipy authored Sep 17, 2019
2 parents 9d65ce5 + 33c9f45 commit d716eac
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
21 changes: 0 additions & 21 deletions .electron-vue/webpack.main.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ process.env.BABEL_ENV = 'main';
const path = require('path');
const childProcess = require('child_process');
const webpack = require('webpack');
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
const { dependencies, optionalDependencies, _moduleAliases } = require('../package.json');
const TerserPlugin = require('terser-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
Expand Down Expand Up @@ -103,7 +102,6 @@ const sharedDefinedVariables = {};
*/
if (process.env.NODE_ENV !== 'production') {
mainConfig.plugins.push(
new ForkTsCheckerWebpackPlugin({ eslint: true }),
new webpack.DefinePlugin(Object.assign(sharedDefinedVariables, {
'process.env.SAGI_API': `"${process.env.SAGI_API || 'apis.stage.sagittarius.ai:8443'}"`,
__static: `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`,
Expand Down Expand Up @@ -137,25 +135,6 @@ if (process.env.NODE_ENV === 'production') {
// only check on mac, to speed up Windows build
mainConfig.plugins.push(new ForkTsCheckerWebpackPlugin({ eslint: true }));
}

if (release && process.env.SENTRY_AUTH_TOKEN) {
mainConfig.plugins.push(
new SentryWebpackPlugin({
release,
include: './dist',
urlPrefix: 'app:///dist/',
ext: ['js', 'map'],
ignore: ['node_modules'],
}),
new SentryWebpackPlugin({
release,
include: './src',
urlPrefix: 'webpack:///./src/',
ext: ['js', 'ts', 'vue'],
ignore: ['node_modules'],
}),
);
}
}

module.exports = mainConfig;
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
37 changes: 37 additions & 0 deletions src/main/helpers/electronPrototypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,41 @@ if (process.platform !== 'darwin') {
};
}
};

// 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;
};

const originIsFullScreen = BrowserWindow.prototype.isFullScreen;
BrowserWindow.prototype.isFullScreen = function isFullScreen(...args) {
return originIsFullScreen.apply(this, args) || this._isFullScreen;
};
}

0 comments on commit d716eac

Please sign in to comment.