canvas: canvas glitches when hardware acceleration is disabled (--disable-gpu) (built-in gui only)
117 lines
3 KiB
JavaScript
117 lines
3 KiB
JavaScript
var {app, Menu, shell} = require('electron'),
|
|
settings = require('./settings'),
|
|
infos = require('../package.json')
|
|
|
|
app.commandLine.appendSwitch('--touch-events')
|
|
|
|
if (settings.read('noVsync') || (!settings.cli && settings.read('argv')['disable-vsync'])) {
|
|
app.commandLine.appendSwitch('--disable-gpu-vsync')
|
|
}
|
|
|
|
if (settings.read('noGpu') || (!settings.cli && settings.read('argv')['disable-gpu'])) {
|
|
app.disableHardwareAcceleration()
|
|
app._noGpu = true
|
|
}
|
|
|
|
if (settings.read('forceGpu') || (!settings.cli && settings.read('argv')['force-gpu'])) {
|
|
app.commandLine.appendSwitch('--ignore-gpu-blacklist')
|
|
}
|
|
|
|
|
|
|
|
var template = [{
|
|
label: 'Edit',
|
|
submenu: [
|
|
{role: 'undo', accelerator: 'CmdOrCtrl+Z'},
|
|
{role: 'redo', accelerator: 'Shift+CmdOrCtrl+Z'},
|
|
{type: 'separator'},
|
|
{role: 'cut', accelerator: 'CmdOrCtrl+X'},
|
|
{role: 'copy', accelerator: 'CmdOrCtrl+C'},
|
|
{role: 'paste', accelerator: 'CmdOrCtrl+V'}
|
|
]
|
|
}]
|
|
|
|
if (process.platform === 'darwin') {
|
|
// Add app menu (OS X)
|
|
template.unshift({
|
|
label: settings.read('appName'),
|
|
submenu: [
|
|
{
|
|
label: 'Hide ' + infos.productName,
|
|
accelerator: 'Command+H',
|
|
role: 'hide'
|
|
},
|
|
{
|
|
label: 'Hide Others',
|
|
accelerator: 'Command+Alt+H',
|
|
role: 'hideothers'
|
|
},
|
|
{
|
|
label: 'Show All',
|
|
role: 'unhide'
|
|
},
|
|
{
|
|
type: 'separator'
|
|
},
|
|
{
|
|
label: 'Quit',
|
|
accelerator: 'Command+Q',
|
|
click: ()=>app.quit()
|
|
}
|
|
]
|
|
})
|
|
template.push(
|
|
{
|
|
label: 'Window',
|
|
role: 'window',
|
|
submenu: [
|
|
{
|
|
label: 'Minimize',
|
|
accelerator: 'CmdOrCtrl+M',
|
|
role: 'minimize'
|
|
},
|
|
{
|
|
type: 'separator'
|
|
},
|
|
{
|
|
label: 'Bring All to Front',
|
|
role: 'front'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
label: 'Help',
|
|
role: 'help',
|
|
submenu: [
|
|
{
|
|
label: 'Documentation',
|
|
click: ()=>shell.openExternal(infos.homepage)
|
|
},
|
|
{
|
|
type: 'separator'
|
|
},
|
|
{
|
|
label: 'Report an Issue',
|
|
click: ()=>shell.openExternal(infos.repository.url + '/issues')
|
|
}
|
|
]
|
|
}
|
|
)
|
|
}
|
|
|
|
app.on('before-quit',()=>{
|
|
process.exit()
|
|
})
|
|
|
|
app.on('ready',()=>{
|
|
var menu = Menu.buildFromTemplate(template)
|
|
Menu.setApplicationMenu(menu)
|
|
})
|
|
|
|
app.on('window-all-closed', function() {
|
|
if (process.platform !== 'darwin') {
|
|
app.quit()
|
|
}
|
|
})
|
|
|
|
module.exports = app
|