add standard behavior when you double click window (#32)

* add standard behavior when you double click window title to maximize/unmaximize the window

* reset on unmount and added comments about click vs. double click
This commit is contained in:
Jeff Haynie 2016-07-04 17:48:38 -07:00 committed by Guillermo Rauch
parent 46683cf703
commit 50fdbf2ef7
2 changed files with 25 additions and 0 deletions

View file

@ -398,6 +398,22 @@ export default class HyperTerm extends Component {
onHeaderMouseDown () { onHeaderMouseDown () {
this.headerMouseDownWindowX = window.screenX; this.headerMouseDownWindowX = window.screenX;
this.headerMouseDownWindowY = window.screenY; this.headerMouseDownWindowY = window.screenY;
this.clicks = this.clicks || 1;
if (this.clicks++ >= 2) {
if (this.maximized) {
this.rpc.emit('unmaximize');
} else {
this.rpc.emit('maximize');
}
this.clicks = 0;
this.maximized = !this.maximized;
} else {
// http://www.quirksmode.org/dom/events/click.html
// https://en.wikipedia.org/wiki/Double-click
this.clickTimer = setTimeout(() => this.clicks = 0, 500);
}
} }
componentWillUnmount () { componentWillUnmount () {
@ -406,6 +422,7 @@ export default class HyperTerm extends Component {
if (this.keys) { if (this.keys) {
this.keys.reset(); this.keys.reset();
} }
delete this.clicks;
this.updateChecker.destroy(); this.updateChecker.destroy();
} }
} }

View file

@ -85,6 +85,14 @@ app.on('ready', () => {
sessions.get(uid).exit(); sessions.get(uid).exit();
}); });
rpc.on('unmaximize', () => {
win.unmaximize();
});
rpc.on('maximize', () => {
win.maximize();
});
rpc.on('resize', ({ cols, rows }) => { rpc.on('resize', ({ cols, rows }) => {
sessions.forEach((session) => { sessions.forEach((session) => {
session.resize({ cols, rows }); session.resize({ cols, rows });