Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.

Commit c54d5f7

Browse files
committed
Fix #21
1 parent 7d082f7 commit c54d5f7

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/index.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
if (require('electron-squirrel-startup')) process.exit();
1+
const electron = require('electron');
2+
const {app} = electron;
3+
4+
if (require('electron-squirrel-startup')) app.quit();
25

36
const Config = require('./writable-file-config');
47
const Tasks = require('gitlab-time-tracker/src/include/tasks');
58
const Base = require('gitlab-time-tracker/src/models/base');
69

7-
const electron = require('electron');
8-
const {app, dialog, Tray, BrowserWindow, Menu, ipcMain} = electron;
10+
const {dialog, Tray, BrowserWindow, Menu, ipcMain} = electron;
911
const path = require('path');
1012
const events = require('events');
1113
const chokidar = require('chokidar');
@@ -20,6 +22,8 @@ log.transports.file.appName = 'gtt-taskbar';
2022
let gtt = new events.EventEmitter(),
2123
trayIcon = null,
2224
trayWindow = null,
25+
trayWindowSize = null,
26+
trayWindowOpen = false,
2327
trayPos = null,
2428
contextMenu = null,
2529
settingsWindow = null,
@@ -193,21 +197,30 @@ gtt.openContextMenu = () => {
193197
* Create and set the tray window.
194198
*/
195199
gtt.setTrayWindow = () => {
200+
trayWindowSize = {
201+
w: 370,
202+
h: gtt._platform == 'win' ? 420 : 390,
203+
};
204+
196205
trayWindow = new BrowserWindow({
197-
width: 370,
198-
height: gtt._platform == 'win' ? 420 : 390,
206+
width: trayWindowSize.w,
207+
height: trayWindowSize.h,
199208
show: false,
200209
frame: false,
201210
resizable: false,
202211
transparent: true,
212+
skipTaskbar: true,
203213
icon: path.join(__dirname, '/icons/png/64x64.png')
204214
});
205215

206216
trayWindow.loadURL('file://' + __dirname + '/index.html');
207217
if (debug) trayWindow.openDevTools();
208218

209219
trayWindow.on('blur', function () {
210-
if (!debug) trayWindow.hide();
220+
if (!debug) {
221+
trayWindow.hide();
222+
setTimeout(() => trayWindowOpen = false, 100);
223+
}
211224
});
212225

213226
trayWindow.on('closed', function () {
@@ -245,6 +258,10 @@ gtt.setTray = () => {
245258
* @param bounds
246259
*/
247260
gtt.toggleTrayWindow = bounds => {
261+
if ((trayWindow && trayWindow.isVisible()) || trayWindowOpen) {
262+
return;
263+
}
264+
248265
let x, y, trayWindowBounds = trayWindow.getBounds();
249266

250267
if (gtt._platform != 'linux') {
@@ -264,12 +281,11 @@ gtt.toggleTrayWindow = bounds => {
264281
Math.ceil(y)
265282
);
266283

267-
if (trayWindow && trayWindow.isVisible()) {
268-
return trayWindow.hide();
269-
}
270-
284+
trayWindowOpen = true;
271285
trayWindow.setVisibleOnAllWorkspaces(true);
286+
trayWindow.setSize(0, 0);
272287
trayWindow.show();
288+
trayWindow.setSize(trayWindowSize.w, trayWindowSize.h);
273289
trayWindow.setVisibleOnAllWorkspaces(false);
274290
};
275291

0 commit comments

Comments
 (0)