mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 05:38:41 -09:00
Bring focus to main window when clicking preferences (#235)
This commit is contained in:
parent
08fc3311f9
commit
fa4033937e
2 changed files with 8 additions and 1 deletions
7
index.js
7
index.js
|
|
@ -41,10 +41,10 @@ app.on('window-all-closed', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
let winCount = 0;
|
let winCount = 0;
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
function createWindow (fn) {
|
function createWindow (fn) {
|
||||||
const cfg = plugins.getDecoratedConfig();
|
const cfg = plugins.getDecoratedConfig();
|
||||||
|
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
width: 540,
|
width: 540,
|
||||||
height: 380,
|
height: 380,
|
||||||
|
|
@ -59,6 +59,7 @@ app.on('ready', () => {
|
||||||
// is ready for user input
|
// is ready for user input
|
||||||
show: process.env.HYPERTERM_DEBUG || isDev
|
show: process.env.HYPERTERM_DEBUG || isDev
|
||||||
});
|
});
|
||||||
|
|
||||||
winCount++;
|
winCount++;
|
||||||
win.loadURL(url);
|
win.loadURL(url);
|
||||||
|
|
||||||
|
|
@ -72,6 +73,7 @@ app.on('ready', () => {
|
||||||
|
|
||||||
rpc.on('init', () => {
|
rpc.on('init', () => {
|
||||||
win.show();
|
win.show();
|
||||||
|
if (fn) fn(win);
|
||||||
|
|
||||||
// auto updates
|
// auto updates
|
||||||
if (!isDev) {
|
if (!isDev) {
|
||||||
|
|
@ -112,6 +114,7 @@ app.on('ready', () => {
|
||||||
// on Session and focus/blur to subscribe
|
// on Session and focus/blur to subscribe
|
||||||
rpc.on('focus', ({ uid }) => {
|
rpc.on('focus', ({ uid }) => {
|
||||||
const session = sessions.get(uid);
|
const session = sessions.get(uid);
|
||||||
|
|
||||||
if (session) {
|
if (session) {
|
||||||
session.focus();
|
session.focus();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -121,6 +124,7 @@ app.on('ready', () => {
|
||||||
|
|
||||||
rpc.on('blur', ({ uid }) => {
|
rpc.on('blur', ({ uid }) => {
|
||||||
const session = sessions.get(uid);
|
const session = sessions.get(uid);
|
||||||
|
|
||||||
if (session) {
|
if (session) {
|
||||||
session.blur();
|
session.blur();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -218,6 +222,7 @@ app.on('ready', () => {
|
||||||
plugins.updatePlugins({ force: true });
|
plugins.updatePlugins({ force: true });
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Menu.setApplicationMenu(Menu.buildFromTemplate(tpl));
|
Menu.setApplicationMenu(Menu.buildFromTemplate(tpl));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
2
menu.js
2
menu.js
|
|
@ -23,6 +23,8 @@ module.exports = function createMenu ({ createWindow, updatePlugins }) {
|
||||||
click (item, focusedWindow) {
|
click (item, focusedWindow) {
|
||||||
if (focusedWindow) {
|
if (focusedWindow) {
|
||||||
focusedWindow.rpc.emit('preferences');
|
focusedWindow.rpc.emit('preferences');
|
||||||
|
} else {
|
||||||
|
createWindow(win => win.rpc.emit('preferences'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue