pitaya-launcher/main.js

57 lines
1.5 KiB
JavaScript

var app = require('app'); // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.
var Menu = require('menu');
var isDev = process.env.NODE_ENV === 'development';
var Util = require('./'+(isDev ? 'src': 'dist')+'/util');
var mainWindow = null;
// Quit when all windows are closed.
app.on('window-all-closed', function() {
app.quit();
});
app.on('ready', function() {
// Create the browser window.
var electronScreen = require('screen');
var workArea = electronScreen.getPrimaryDisplay().workArea;
var asDesktop = process.env.PITAYA_AS_DESKTOP == 1;
mainWindow = new BrowserWindow({
type: asDesktop ? 'desktop' : undefined,
'skip-taskbar': asDesktop,
frame: !asDesktop,
width: asDesktop ? workArea.width : undefined,
height: asDesktop ? workArea.height : undefined,
'auto-hide-menu-bar': true,
x: asDesktop ? workArea.x : undefined,
y: asDesktop ? workArea.y : undefined,
});
if(isDev) {
mainWindow.openDevTools();
}
// and load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/index.html');
mainWindow.on('closed', function() {
mainWindow = null;
});
mainWindow.on('blur', function() {
Util.Logger.info('Focus loosed.');
});
mainWindow.on('focus', function() {
Util.Logger.info('Focus gained.');
mainWindow.show();
});
});
process.on('exit', function(code) {
Util.Logger.info('Exiting with code "%s"', code || 0);
});