Skip to content

Commit f9567e6

Browse files
author
Emmanouil Konstantinidis
committed
Create browser window on load of the app
1 parent f3a5d12 commit f9567e6

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

main.js

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var iconGreen = path.join('./images/', 'github-tray-green.png');
1313

1414
app.on('ready', function(){
1515
appIcon = new Tray(iconPlain);
16+
initWindow();
1617

1718
appIcon.on('clicked', function clicked (e, bounds) {
1819
if (appIcon.window && appIcon.window.isVisible()) {
@@ -22,38 +23,30 @@ app.on('ready', function(){
2223
}
2324
});
2425

25-
function showWindow (bounds) {
26-
var options = {
27-
x: bounds.x - 200 + (bounds.width / 2),
28-
y: bounds.y,
26+
function initWindow () {
27+
var defaults = {
2928
width: 400,
3029
height: 350,
31-
index: path.join('./', 'index.html')
32-
};
33-
34-
if (appIcon.window) {
35-
// BrowserWindow exists - Do not Create
36-
appIcon.window.show();
37-
} else {
38-
initWindow(options);
39-
}
40-
}
41-
42-
function initWindow (options) {
43-
// Create BrowserWindow
44-
var defaults = {
45-
width: options.width,
46-
height: options.height,
47-
show: true,
30+
show: false,
4831
frame: false,
4932
resizable: false,
5033
'standard-window': false
5134
};
5235

5336
appIcon.window = new BrowserWindow(defaults);
54-
appIcon.window.setPosition(options.x, options.y);
55-
appIcon.window.on('blur', hideWindow);
5637
appIcon.window.loadUrl('file://' + __dirname + '/index.html');
38+
appIcon.window.on('blur', hideWindow);
39+
}
40+
41+
function showWindow (bounds) {
42+
var options = {
43+
x: bounds.x - 200 + (bounds.width / 2),
44+
y: bounds.y,
45+
index: path.join('./', 'index.html')
46+
};
47+
48+
appIcon.window.setPosition(options.x, options.y);
49+
appIcon.window.show();
5750
}
5851

5952
function hideWindow () {

0 commit comments

Comments
 (0)