{"action":"opened","issue":{"url":"https://api.github.com/repos/atom/electron/issues/4696","repository_url":"https://api.github.com/repos/atom/electron","labels_url":"https://api.github.com/repos/atom/electron/issues/4696/labels{/name}","comments_url":"https://api.github.com/repos/atom/electron/issues/4696/comments","events_url":"https://api.github.com/repos/atom/electron/issues/4696/events","html_url":"https://github.com/atom/electron/issues/4696","id":138833691,"number":4696,"title":"minimzable, maximizable, etc. on Linux","user":{"login":"kminehart","id":5140827,"avatar_url":"https://avatars.githubusercontent.com/u/5140827?v=3","gravatar_id":"","url":"https://api.github.com/users/kminehart","html_url":"https://github.com/kminehart","followers_url":"https://api.github.com/users/kminehart/followers","following_url":"https://api.github.com/users/kminehart/following{/other_user}","gists_url":"https://api.github.com/users/kminehart/gists{/gist_id}","starred_url":"https://api.github.com/users/kminehart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kminehart/subscriptions","organizations_url":"https://api.github.com/users/kminehart/orgs","repos_url":"https://api.github.com/users/kminehart/repos","events_url":"https://api.github.com/users/kminehart/events{/privacy}","received_events_url":"https://api.github.com/users/kminehart/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-06T20:24:37Z","updated_at":"2016-03-06T20:24:37Z","closed_at":null,"body":"* Electron version: 0.36.10\r\n* Operating system: Arch Linux x64, i3 WM\r\n\r\nWorking on an issue where when the user opts to minimize the application to the tray, it prevents the default close event from firing, and instead minimizes the application.\r\n\r\nThis does not work on Window Managers which do not have the ability to minimize or maximize, so any efforts to close the application with this option selected results in the window staying open and nothing happening.\r\n\r\nSee this code for an example:\r\n\r\n```JavaScript\r\nmainWindow.on('close', (event) => {\r\n  if ((Settings.get('minToTray', true) || process.platform === 'darwin')) {\r\n    if (process.platform !== 'darwin') {\r\n      mainWindow.minimize();\r\n      mainWindow.setSkipTaskbar(true);\r\n    } else {\r\n      var test2 = mainWindow.hide();\r\n    }\r\n    event.preventDefault();\r\n    return;\r\n  }\r\n});\r\n```\r\n\r\nI have tried changing the code to include:\r\n\r\n```JavaScript\r\nif(!window.isMinimized()) {\r\n    event.preventDefault();\r\n}\r\n```\r\n\r\nHowever, this does not work in any Window Manager, as window.isMinimized at that point is still false for some reason, even if the WM can correctly handle minimizing.\r\n\r\nI've also tried adding an event handler for `minimize`, but on i3, this event is never fired because a minimize never happens.\r\n\r\nIdeally I would like to handle it with `window.minimzable`, but this is not possible on Linux because according to the documents it always returns true.\r\n\r\nEither way, if `window.minimizable` on Linux is not possible, then why is `window.isMinimized()` returning false after calling `window.minimize()`, even if it is minimized?  Is `window.minimized()` asynchronous?"}}