diff --git a/menus/darwin.cson b/menus/darwin.cson index 7273fd8c6..9e5bd271b 100644 --- a/menus/darwin.cson +++ b/menus/darwin.cson @@ -48,7 +48,8 @@ { label: 'View' submenu: [ - { label: 'Toggle Full Screen', command: 'window:toggle-full-screen' } + { label: 'Enter Full Screen', command: 'window:toggle-full-screen' } + { label: 'Exit Full Screen', command: 'window:toggle-full-screen', visible: false } ] } { diff --git a/src/browser/application-menu.coffee b/src/browser/application-menu.coffee index 02342bb26..08abd9721 100644 --- a/src/browser/application-menu.coffee +++ b/src/browser/application-menu.coffee @@ -36,6 +36,7 @@ class ApplicationMenu Menu.setApplicationMenu(@menu) @showUpdateMenuItem(global.application.autoUpdateManager.getState()) + @showFullscreenMenuItem(@lastFocusedWindow?.isFullScreen()) # Register a BrowserWindow with this application menu. addWindow: (window) -> @@ -47,10 +48,14 @@ class ApplicationMenu @setActiveTemplate(template) window.on 'focus', focusHandler + window.on 'enter-full-screen', focusHandler + window.on 'leave-full-screen', focusHandler window.once 'closed', => @lastFocusedWindow = null if window is @lastFocusedWindow @windowTemplates.delete(window) window.removeListener 'focus', focusHandler + window.removeListener 'enter-full-screen', focusHandler + window.removeListener 'leave-full-screen', focusHandler @enableWindowSpecificItems(true) @@ -111,6 +116,13 @@ class ApplicationMenu when 'update-available' installUpdateItem.visible = true + showFullscreenMenuItem: (fullscreen) -> + enterItem = _.find(@flattenMenuItems(@menu), ({label}) -> label == 'Enter Full Screen') + exitItem = _.find(@flattenMenuItems(@menu), ({label}) -> label == 'Exit Full Screen') + return unless enterItem and exitItem + enterItem.visible = !fullscreen + exitItem.visible = fullscreen + # Default list of menu items. # # Returns an Array of menu item Objects.