Fix webview is not resized when window is (un)maximized on Linux (#156)

This commit is contained in:
Quang Lam 2020-03-11 15:48:25 -05:00 committed by GitHub
parent 14d3d326fe
commit 6c29b38a1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 471 additions and 478 deletions

View file

@ -30,33 +30,33 @@
"electron-is-dev": "1.1.0",
"electron-settings": "3.2.0",
"electron-spellchecker": "2.2.1",
"electron-updater": "4.2.0",
"electron-updater": "4.2.4",
"electron-window-state": "5.0.3",
"follow-redirects": "1.10.0",
"fs-extra": "8.1.0",
"is-url": "1.2.4",
"jimp": "0.9.3",
"jimp": "0.9.5",
"menubar": "7.2.0",
"node-fetch": "2.6.0",
"semver": "7.1.3",
"tmp": "0.1.0",
"uuid": "3.4.0"
"uuid": "7.0.2"
},
"devDependencies": {
"@date-io/date-fns": "1.3.13",
"@material-ui/core": "3.9.4",
"@material-ui/icons": "3.0.2",
"algoliasearch": "4.0.3",
"algoliasearch": "4.1.0",
"babel-eslint": "10.0.3",
"babel-preset-env": "1.7.0",
"babel-preset-react": "6.24.1",
"blueimp-md5": "2.12.0",
"classnames": "2.2.6",
"concurrently": "5.1.0",
"cross-env": "7.0.0",
"cross-env": "7.0.2",
"date-fns": "2.9.0",
"electron": "6.1.6",
"electron-builder": "22.3.2",
"electron-builder": "22.4.0",
"electron-notarize": "0.2.1",
"eslint": "6.8.0",
"eslint-config-airbnb": "18.0.1",
@ -67,15 +67,15 @@
"lodash.camelcase": "4.3.0",
"material-ui-pickers": "2.2.4",
"prop-types": "15.7.2",
"react": "16.12.0",
"react-dom": "16.12.0",
"react": "16.13.0",
"react-dom": "16.13.0",
"react-redux": "6.0.1",
"react-scripts": "3.4.0",
"react-sortable-hoc": "1.11.0",
"redux": "4.0.5",
"redux-thunk": "2.3.0",
"typeface-roboto": "0.0.75",
"wait-on": "4.0.0"
"wait-on": "4.0.1"
},
"homepage": "./",
"private": true,

View file

@ -89,8 +89,6 @@ const addView = (browserWindow, workspace) => {
unreadCountBadge,
} = getPreferences();
const contentSize = browserWindow.getContentSize();
const view = new BrowserView({
webPreferences: {
nativeWindowOpen: true,
@ -147,6 +145,7 @@ const addView = (browserWindow, workspace) => {
// show browserView again when reloading after error
// see did-fail-load event
if (didFailLoad[workspace.id]) {
const contentSize = browserWindow.getContentSize();
view.setBounds(getViewBounds(contentSize));
}
didFailLoad[workspace.id] = false;
@ -184,6 +183,7 @@ const addView = (browserWindow, workspace) => {
sendToAllWindows('update-loading', false);
didFailLoad[workspace.id] = true;
const contentSize = browserWindow.getContentSize();
view.setBounds(
getViewBounds(contentSize, false, 0, 0),
); // hide browserView to show error message
@ -394,6 +394,7 @@ const addView = (browserWindow, workspace) => {
if (workspace.active) {
browserWindow.setBrowserView(view);
const contentSize = browserWindow.getContentSize();
view.setBounds(getViewBounds(contentSize));
view.setAutoResize({
width: true,

View file

@ -206,6 +206,24 @@ const createAsync = () => {
}
});
// Fix webview is not resized automatically
// when window is maximized on Linux
// https://github.com/atomery/webcatalog/issues/561
if (process.platform === 'linux') {
const handleMaximize = () => {
// getContentSize is not updated immediately
// try once after 0.2s (for fast computer), another one after 1s (to be sure)
setTimeout(() => {
ipcMain.emit('request-realign-active-workspace');
}, 200);
setTimeout(() => {
ipcMain.emit('request-realign-active-workspace');
}, 1000);
};
win.on('maximize', handleMaximize);
win.on('unmaximize', handleMaximize);
}
return new Promise((resolve) => {
win.once('ready-to-show', () => {
resolve();

908
yarn.lock

File diff suppressed because it is too large Load diff