Skip to content

Commit

Permalink
Tweak show window rule again (keybase#4076)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel authored Aug 30, 2016
1 parent b2f0459 commit f8ab3c0
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions desktop/app/main-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ export default function () {
mainWindow.window.setPosition(forceMainWindowPosition.x, forceMainWindowPosition.y)
}

const openedAtLogin = app.getLoginItemSettings().wasOpenedAtLogin
const isRestore = getenv.boolish('KEYBASE_RESTORE_UI', false) || app.getLoginItemSettings().restoreState
const openHidden = (getenv.string('KEYBASE_START_UI', '') === 'hideWindow') || app.getLoginItemSettings().wasOpenedAsHidden
console.log('Opened at login:', openedAtLogin)
console.log('Is restore:', isRestore)
console.log('Open hidden:', openHidden)

// We show the main window on startup if:
// - We are restoring UI and the window was previously visible (in app state)
// - and, we are not set to open hidden
const showMainWindow = (isRestore && !appState.state.windowHidden) && !openHidden
console.log('Show main window: %s', showMainWindow)
if (showMainWindow) {
// Don't show main window:
// - If we are set to open hidden,
// - or, if we are restoring and window was hidden
// - or, if we were opened from login (but not restoring)
const hideMainWindow = openHidden || (isRestore && appState.state.windowHidden) || (openedAtLogin && !isRestore)

console.log('Hide main window:', hideMainWindow)
if (!hideMainWindow) {
// On Windows we can try showing before Windows is ready
// This will result in a dropped .show request
// We add a listener to `did-finish-load` so we can show it when
Expand All @@ -52,11 +58,11 @@ export default function () {
})
}

// Hide the dock icon if:
// - We are not restoring
// - or, we are restoring and dock was hidden
// - or, we are set to open hidden
const shouldHideDockIcon = !isRestore || (isRestore && appState.state.dockHidden) || openHidden
// Don't show dock:
// - If we are set to open hidden,
// - or, if we are restoring and dock was hidden
// - or, if we were opened from login (but not restoring)
const shouldHideDockIcon = openHidden || (isRestore && appState.state.dockHidden) || (openedAtLogin && !isRestore)
console.log('Hide dock icon: %s', shouldHideDockIcon)
if (shouldHideDockIcon) {
hideDockIcon()
Expand Down

0 comments on commit f8ab3c0

Please sign in to comment.