@@ -223,20 +223,24 @@ const createWindow = () => {
223223
224224 // Emitted when the window is closed.
225225 mainWindow . on ( 'close' , ( e ) => {
226+ debug ( 'Window: close window' ) ;
226227 // Dereference the window object, usually you would store windows
227228 // in an array if your app supports multi windows, this is the time
228229 // when you should delete the corresponding element.
229230 if ( ! willQuitApp && ( settings . get ( 'runInBackground' ) === undefined || settings . get ( 'runInBackground' ) ) ) {
230231 e . preventDefault ( ) ;
231232 if ( isWindows ) {
233+ debug ( 'Window: minimize' ) ;
232234 mainWindow . minimize ( ) ;
235+
236+ if ( settings . get ( 'minimizeToSystemTray' ) ) {
237+ debug ( 'Skip taskbar: true' ) ;
238+ mainWindow . setSkipTaskbar ( true ) ;
239+ }
233240 } else {
241+ debug ( 'Window: hide' ) ;
234242 mainWindow . hide ( ) ;
235243 }
236-
237- if ( isWindows ) {
238- mainWindow . setSkipTaskbar ( true ) ;
239- }
240244 } else {
241245 app . quit ( ) ;
242246 }
@@ -248,39 +252,47 @@ const createWindow = () => {
248252 app . wasMaximized = app . isMaximized ;
249253
250254 if ( settings . get ( 'minimizeToSystemTray' ) ) {
255+ debug ( 'Skip taskbar: true' ) ;
251256 mainWindow . setSkipTaskbar ( true ) ;
252257 trayIcon . show ( ) ;
253258 }
254259 } ) ;
255260
256261 mainWindow . on ( 'maximize' , ( ) => {
262+ debug ( 'Window: maximize' ) ;
257263 app . isMaximized = true ;
258264 } ) ;
259265
260266 mainWindow . on ( 'unmaximize' , ( ) => {
267+ debug ( 'Window: unmaximize' ) ;
261268 app . isMaximized = false ;
262269 } ) ;
263270
264271 mainWindow . on ( 'restore' , ( ) => {
272+ debug ( 'Window: restore' ) ;
265273 mainWindow . setSkipTaskbar ( false ) ;
266274
267275 if ( app . wasMaximized ) {
276+ debug ( 'Window: was maximized before, maximize window' ) ;
268277 mainWindow . maximize ( ) ;
269278 }
270279
271280 if ( ! settings . get ( 'enableSystemTray' ) ) {
281+ debug ( 'Tray: hiding tray icon' ) ;
272282 trayIcon . hide ( ) ;
273283 }
274284 } ) ;
275285
276286 mainWindow . on ( 'show' , ( ) => {
287+ debug ( 'Skip taskbar: false' ) ;
277288 mainWindow . setSkipTaskbar ( false ) ;
278289 } ) ;
279290
280291 app . mainWindow = mainWindow ;
281292 app . isMaximized = mainWindow . isMaximized ( ) ;
282293
283294 mainWindow . webContents . on ( 'new-window' , ( e , url ) => {
295+ debug ( 'Open url' , url ) ;
284296 e . preventDefault ( ) ;
285297 shell . openExternal ( url ) ;
286298 } ) ;
@@ -360,7 +372,10 @@ app.on('window-all-closed', () => {
360372 // to stay active until the user quits explicitly with Cmd + Q
361373 if ( settings . get ( 'runInBackground' ) === undefined
362374 || settings . get ( 'runInBackground' ) ) {
375+ debug ( 'Window: all windows closed, quit app' ) ;
363376 app . quit ( ) ;
377+ } else {
378+ debug ( 'Window: don\'t quit app' ) ;
364379 }
365380} ) ;
366381
0 commit comments