mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
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:
parent
46683cf703
commit
50fdbf2ef7
2 changed files with 25 additions and 0 deletions
|
|
@ -398,6 +398,22 @@ export default class HyperTerm extends Component {
|
|||
onHeaderMouseDown () {
|
||||
this.headerMouseDownWindowX = window.screenX;
|
||||
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 () {
|
||||
|
|
@ -406,6 +422,7 @@ export default class HyperTerm extends Component {
|
|||
if (this.keys) {
|
||||
this.keys.reset();
|
||||
}
|
||||
delete this.clicks;
|
||||
this.updateChecker.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
8
index.js
8
index.js
|
|
@ -85,6 +85,14 @@ app.on('ready', () => {
|
|||
sessions.get(uid).exit();
|
||||
});
|
||||
|
||||
rpc.on('unmaximize', () => {
|
||||
win.unmaximize();
|
||||
});
|
||||
|
||||
rpc.on('maximize', () => {
|
||||
win.maximize();
|
||||
});
|
||||
|
||||
rpc.on('resize', ({ cols, rows }) => {
|
||||
sessions.forEach((session) => {
|
||||
session.resize({ cols, rows });
|
||||
|
|
|
|||
Loading…
Reference in a new issue