Skip to content

Commit

Permalink
Display the renderer type in the About dialog (#3441)
Browse files Browse the repository at this point in the history
* Now displaying the renderer type in the About dialog

* Show the number of renderers per type in the About dialog

* Use values instead of entries (key is unused)

Co-Authored-By: onecamp <[email protected]>
  • Loading branch information
juancampa authored Jan 24, 2019
1 parent 0dc8fb9 commit 8733ecc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/menus/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const helpMenu = require('./menus/help');
const darwinMenu = require('./menus/darwin');
const {getDecoratedKeymaps} = require('../plugins');
const {execCommand} = require('../commands');
const {getRendererTypes} = require('../utils/renderer-utils');

const appName = app.getName();
const appVersion = app.getVersion();
Expand All @@ -39,10 +40,18 @@ exports.createMenu = (createWindow, getLoadedPluginVersions) => {
const pluginList =
loadedPlugins.length === 0 ? 'none' : loadedPlugins.map(plugin => `\n ${plugin.name} (${plugin.version})`);

const rendererCounts = Object.values(getRendererTypes()).reduce((acc, type) => {
acc[type] = acc[type] ? acc[type] + 1 : 1;
return acc;
}, {});
const renderers = Object.entries(rendererCounts)
.map(([type, count]) => type + (count > 1 ? ` (${count})` : ''))
.join(', ');

dialog.showMessageBox({
title: `About ${appName}`,
message: `${appName} ${appVersion} (${updateChannel})`,
detail: `Plugins: ${pluginList}\n\nCreated by Guillermo Rauch\nCopyright © 2018 ZEIT, Inc.`,
detail: `Renderers: ${renderers}\nPlugins: ${pluginList}\n\nCreated by Guillermo Rauch\nCopyright © 2018 ZEIT, Inc.`,
buttons: [],
icon
});
Expand Down
6 changes: 6 additions & 0 deletions app/ui/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const fetchNotifications = require('../notifications');
const Session = require('../session');
const contextMenuTemplate = require('./contextmenu');
const {execCommand} = require('../commands');
const {setRendererType, unsetRendererType} = require('../utils/renderer-utils');

module.exports = class Window {
constructor(options_, cfg, fn) {
Expand Down Expand Up @@ -153,6 +154,7 @@ module.exports = class Window {

session.on('exit', () => {
rpc.emit('session exit', {uid: options.uid});
unsetRendererType(options.uid);
sessions.delete(options.uid);
});
});
Expand Down Expand Up @@ -192,6 +194,10 @@ module.exports = class Window {
}
}
});
rpc.on('info renderer', ({uid, type}) => {
// Used in the "About" dialog
setRendererType(uid, type);
});
rpc.on('open external', ({url}) => {
shell.openExternal(url);
});
Expand Down
19 changes: 19 additions & 0 deletions app/utils/renderer-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const rendererTypes = {};

function getRendererTypes() {
return rendererTypes;
}

function setRendererType(uid, type) {
rendererTypes[uid] = type;
}

function unsetRendererType(uid) {
delete rendererTypes[uid];
}

module.exports = {
getRendererTypes,
setRendererType,
unsetRendererType
};
12 changes: 12 additions & 0 deletions lib/components/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const getTermOptions = props => {
useWebGL = true;
}
}
Term.reportRenderer(props.uid, useWebGL ? 'WebGL' : 'Canvas');

return {
macOptionIsMeta: props.modifierKeys.altIsMeta,
scrollback: props.scrollback,
Expand Down Expand Up @@ -110,6 +112,16 @@ export default class Term extends React.PureComponent {
this.disposableListeners = [];
}

// The main process shows this in the About dialog
static reportRenderer(uid, type) {
const rendererTypes = Term.rendererTypes || {};
if (rendererTypes[uid] !== type) {
rendererTypes[uid] = type;
Term.rendererTypes = rendererTypes;
window.rpc.emit('info renderer', {uid, type});
}
}

componentDidMount() {
const {props} = this;

Expand Down

0 comments on commit 8733ecc

Please sign in to comment.