mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-17 22:18:41 -09:00
[WIP] Add proper window support (#547)
* Add proper window support to both the top menu, and the dock * Sort out linting * Only create dockMenu on Mac * Remove label from menu as it is not needed when using role * Fix spacing
This commit is contained in:
parent
f175268912
commit
77a103fbf1
2 changed files with 14 additions and 4 deletions
16
app/index.js
16
app/index.js
|
|
@ -97,7 +97,6 @@ app.on('ready', () => {
|
||||||
const browserOptions = plugins.getDecoratedBrowserOptions(browserDefaults);
|
const browserOptions = plugins.getDecoratedBrowserOptions(browserDefaults);
|
||||||
|
|
||||||
const win = new BrowserWindow(browserOptions);
|
const win = new BrowserWindow(browserOptions);
|
||||||
|
|
||||||
windowSet.add(win);
|
windowSet.add(win);
|
||||||
|
|
||||||
win.loadURL(url);
|
win.loadURL(url);
|
||||||
|
|
@ -159,6 +158,7 @@ app.on('ready', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
session.on('title', (title) => {
|
session.on('title', (title) => {
|
||||||
|
win.setTitle(title);
|
||||||
rpc.emit('session title', { uid, title });
|
rpc.emit('session title', { uid, title });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -174,14 +174,15 @@ 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 (typeof session !== 'undefined' && typeof session.lastTitle !== 'undefined') {
|
||||||
|
win.setTitle(session.lastTitle);
|
||||||
|
}
|
||||||
if (session) {
|
if (session) {
|
||||||
session.focus();
|
session.focus();
|
||||||
} else {
|
} else {
|
||||||
console.log('session not found by', uid);
|
console.log('session not found by', uid);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
rpc.on('blur', ({ uid }) => {
|
rpc.on('blur', ({ uid }) => {
|
||||||
const session = sessions.get(uid);
|
const session = sessions.get(uid);
|
||||||
|
|
||||||
|
|
@ -309,6 +310,15 @@ app.on('ready', () => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// If we're on Mac make a Dock Menu
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
const { app, Menu } = require('electron');
|
||||||
|
const dockMenu = Menu.buildFromTemplate([
|
||||||
|
{label: 'New Window', click () { createWindow(); }}
|
||||||
|
]);
|
||||||
|
app.dock.setMenu(dockMenu);
|
||||||
|
}
|
||||||
|
|
||||||
Menu.setApplicationMenu(Menu.buildFromTemplate(tpl));
|
Menu.setApplicationMenu(Menu.buildFromTemplate(tpl));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ module.exports = function createMenu ({ createWindow, updatePlugins }) {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Window',
|
role: 'window',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
role: 'minimize'
|
role: 'minimize'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue