mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-17 05:58:41 -09:00
Add support for opening the terminal on the correct display (#519)
* Add support for opening the terminal on the correct display * Fix whitespace issue * Start from the top left again when we run out of space * Add semicolon
This commit is contained in:
parent
aa84fde6b3
commit
c9fe3d82db
1 changed files with 30 additions and 1 deletions
31
app/index.js
31
app/index.js
|
|
@ -50,6 +50,33 @@ app.on('ready', () => {
|
||||||
let cfg = plugins.getDecoratedConfig();
|
let cfg = plugins.getDecoratedConfig();
|
||||||
|
|
||||||
const [width, height] = cfg.windowSize || [540, 380];
|
const [width, height] = cfg.windowSize || [540, 380];
|
||||||
|
const { screen } = require('electron');
|
||||||
|
|
||||||
|
let startX = 50;
|
||||||
|
let startY = 50;
|
||||||
|
|
||||||
|
// Open the new window roughly the height of the header away from the
|
||||||
|
// previous window. This also ensures in multi monitor setups that the
|
||||||
|
// new terminal is on the correct screen.
|
||||||
|
if (BrowserWindow.getFocusedWindow() !== null) {
|
||||||
|
const currentWindow = BrowserWindow.getFocusedWindow();
|
||||||
|
const points = currentWindow.getPosition();
|
||||||
|
const currentScreen = screen.getDisplayNearestPoint({ x: points[0], y: points[1] });
|
||||||
|
|
||||||
|
const biggestX = ((points[0] + 100 + width) - currentScreen.bounds.x);
|
||||||
|
const biggestY = ((points[1] + 100 + height) - currentScreen.bounds.y);
|
||||||
|
|
||||||
|
if (biggestX > currentScreen.size.width) {
|
||||||
|
startX = 50;
|
||||||
|
} else {
|
||||||
|
startX = points[0] + 34;
|
||||||
|
}
|
||||||
|
if (biggestY > currentScreen.size.height) {
|
||||||
|
startY = 50;
|
||||||
|
} else {
|
||||||
|
startY = points[1] + 34;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const browserDefaults = {
|
const browserDefaults = {
|
||||||
width,
|
width,
|
||||||
|
|
@ -63,7 +90,9 @@ app.on('ready', () => {
|
||||||
icon: resolve(__dirname, 'static/icon.png'),
|
icon: resolve(__dirname, 'static/icon.png'),
|
||||||
// we only want to show when the prompt
|
// we only want to show when the prompt
|
||||||
// is ready for user input
|
// is ready for user input
|
||||||
show: process.env.HYPERTERM_DEBUG || isDev
|
show: process.env.HYPERTERM_DEBUG || isDev,
|
||||||
|
x: startX,
|
||||||
|
y: startY
|
||||||
};
|
};
|
||||||
const browserOptions = plugins.getDecoratedBrowserOptions(browserDefaults);
|
const browserOptions = plugins.getDecoratedBrowserOptions(browserDefaults);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue