Merge pull request #3622 from t3chguy/t3chguy/electron-persist-window-layout
Remember and Recall window layout/position state
This commit is contained in:
commit
2c36506342
|
@ -5,6 +5,7 @@
|
||||||
/key.pem
|
/key.pem
|
||||||
/lib
|
/lib
|
||||||
/node_modules
|
/node_modules
|
||||||
|
/electron/node_modules
|
||||||
/packages/
|
/packages/
|
||||||
/webapp
|
/webapp
|
||||||
/.npmrc
|
/.npmrc
|
||||||
|
|
|
@ -135,7 +135,7 @@ To run as a desktop app:
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install electron
|
npm install electron
|
||||||
node_modules/.bin/electron .
|
npm run electron
|
||||||
```
|
```
|
||||||
|
|
||||||
To build packages, use electron-builder. This is configured to output:
|
To build packages, use electron-builder. This is configured to output:
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"name": "riot-web",
|
||||||
|
"main": "src/electron-main.js",
|
||||||
|
"version": "0.9.8",
|
||||||
|
"description": "A feature-rich client for Matrix.org",
|
||||||
|
"author": "Vector Creations Ltd.",
|
||||||
|
"dependencies": {
|
||||||
|
"electron-window-state": "^4.1.0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,8 @@ const tray = require('./tray');
|
||||||
|
|
||||||
const VectorMenu = require('./vectormenu');
|
const VectorMenu = require('./vectormenu');
|
||||||
|
|
||||||
|
const windowStateKeeper = require('electron-window-state');
|
||||||
|
|
||||||
let vectorConfig = {};
|
let vectorConfig = {};
|
||||||
try {
|
try {
|
||||||
vectorConfig = require('../../webapp/config.json');
|
vectorConfig = require('../../webapp/config.json');
|
||||||
|
@ -187,11 +189,21 @@ electron.app.on('ready', () => {
|
||||||
process.platform == 'win32' ? 'ico' : 'png'
|
process.platform == 'win32' ? 'ico' : 'png'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Load the previous window state with fallback to defaults
|
||||||
|
let mainWindowState = windowStateKeeper({
|
||||||
|
defaultWidth: 1024,
|
||||||
|
defaultHeight: 768,
|
||||||
|
});
|
||||||
|
|
||||||
mainWindow = new electron.BrowserWindow({
|
mainWindow = new electron.BrowserWindow({
|
||||||
icon: icon_path,
|
icon: icon_path,
|
||||||
width: 1024, height: 768,
|
|
||||||
show: false,
|
show: false,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
|
|
||||||
|
x: mainWindowState.x,
|
||||||
|
y: mainWindowState.y,
|
||||||
|
width: mainWindowState.width,
|
||||||
|
height: mainWindowState.height,
|
||||||
});
|
});
|
||||||
mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`);
|
mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`);
|
||||||
electron.Menu.setApplicationMenu(VectorMenu);
|
electron.Menu.setApplicationMenu(VectorMenu);
|
||||||
|
@ -230,6 +242,8 @@ electron.app.on('ready', () => {
|
||||||
onLinkContextMenu(ev, params);
|
onLinkContextMenu(ev, params);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mainWindowState.manage(mainWindow);
|
||||||
});
|
});
|
||||||
|
|
||||||
electron.app.on('window-all-closed', () => {
|
electron.app.on('window-all-closed', () => {
|
||||||
|
|
17
package.json
17
package.json
|
@ -36,6 +36,8 @@
|
||||||
"build": "npm run build:res && npm run build:bundle",
|
"build": "npm run build:res && npm run build:bundle",
|
||||||
"build:dev": "npm run build:res && npm run build:bundle:dev",
|
"build:dev": "npm run build:res && npm run build:bundle:dev",
|
||||||
"dist": "scripts/package.sh",
|
"dist": "scripts/package.sh",
|
||||||
|
"install:electron": "install-app-deps",
|
||||||
|
"electron": "npm run install:electron && electron .",
|
||||||
"start:res": "node scripts/copy-res.js -w",
|
"start:res": "node scripts/copy-res.js -w",
|
||||||
"start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-file=bundles/_dev_/[name].js -w --progress",
|
"start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-file=bundles/_dev_/[name].js -w --progress",
|
||||||
"start:js:prod": "cross-env NODE_ENV=production webpack-dev-server -w --progress",
|
"start:js:prod": "cross-env NODE_ENV=production webpack-dev-server -w --progress",
|
||||||
|
@ -145,10 +147,12 @@
|
||||||
"dereference": true,
|
"dereference": true,
|
||||||
"//files": "We bundle everything, so we only need to include webapp/",
|
"//files": "We bundle everything, so we only need to include webapp/",
|
||||||
"files": [
|
"files": [
|
||||||
"electron/src/**",
|
"node_modules/**",
|
||||||
"electron/img/**",
|
"src/**",
|
||||||
"webapp/**",
|
"img/**"
|
||||||
"package.json"
|
],
|
||||||
|
"extraResources": [
|
||||||
|
"webapp/**/*"
|
||||||
],
|
],
|
||||||
"linux": {
|
"linux": {
|
||||||
"target": "deb",
|
"target": "deb",
|
||||||
|
@ -159,10 +163,11 @@
|
||||||
},
|
},
|
||||||
"win": {
|
"win": {
|
||||||
"target": "squirrel"
|
"target": "squirrel"
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"buildResources": "electron/build",
|
"buildResources": "electron/build",
|
||||||
"output": "electron/dist"
|
"output": "electron/dist",
|
||||||
|
"app": "electron"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
15
release.sh
15
release.sh
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Script to perform a release of vector-web.
|
# Script to perform a release of vector-web.
|
||||||
#
|
#
|
||||||
|
@ -9,4 +9,17 @@ set -e
|
||||||
|
|
||||||
cd `dirname $0`
|
cd `dirname $0`
|
||||||
|
|
||||||
|
|
||||||
|
# bump Electron's package.json first
|
||||||
|
release="${1#v}"
|
||||||
|
tag="v${release}"
|
||||||
|
echo "electron npm version"
|
||||||
|
|
||||||
|
cd electron
|
||||||
|
npm version --no-git-tag-version "$release"
|
||||||
|
git commit package.json -m "$tag"
|
||||||
|
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
exec ./node_modules/matrix-js-sdk/release.sh -z "$@"
|
exec ./node_modules/matrix-js-sdk/release.sh -z "$@"
|
||||||
|
|
Loading…
Reference in New Issue