pitaya-launcher/main.js

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2015-10-07 14:25:30 +02:00
var app = require('app'); // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.
2015-10-13 20:44:55 +02:00
var Menu = require('menu');
var isDev = process.env.NODE_ENV === 'development';
2015-10-30 12:01:44 +01:00
var Util = require('./'+(isDev ? 'src': 'dist')+'/util');
2015-10-07 14:25:30 +02:00
var mainWindow = null;
// Set log level to "debug" if NODE_ENV==devlopment
if(isDev) Util.Logger.level = 'debug';
2015-10-07 14:25:30 +02:00
// 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');
2015-10-29 16:36:44 +01:00
var workArea = electronScreen.getPrimaryDisplay().workArea;
2015-10-07 14:25:30 +02:00
var asDesktop = process.env.PITAYA_AS_DESKTOP == 1;
2015-10-07 14:25:30 +02:00
mainWindow = new BrowserWindow({
type: asDesktop ? 'desktop' : undefined,
'skip-taskbar': asDesktop,
frame: !asDesktop,
2015-10-29 16:36:44 +01:00
width: asDesktop ? workArea.width : undefined,
height: asDesktop ? workArea.height : undefined,
2015-10-13 20:44:55 +02:00
'auto-hide-menu-bar': true,
2015-10-29 16:36:44 +01:00
x: asDesktop ? workArea.x : undefined,
y: asDesktop ? workArea.y : undefined,
2015-10-07 14:25:30 +02:00
});
if(isDev) {
2015-10-07 14:25:30 +02:00
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.debug('Focus loosed.');
});
mainWindow.on('focus', function() {
Util.Logger.debug('Focus gained.');
mainWindow.show();
});
2015-10-07 14:25:30 +02:00
});
2015-10-30 12:01:44 +01:00
process.on('exit', function(code) {
Util.Logger.info('Exiting with code "%s"', code || 0);
});