From 3bc68b91ba54b44cd0eadcc3518752f07e2cfd0c Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 4 Sep 2015 14:08:21 -0600 Subject: [PATCH] Handle document/window commands via command registry --- src/window-event-handler.coffee | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/window-event-handler.coffee b/src/window-event-handler.coffee index 7c786297d..4f52f7115 100644 --- a/src/window-event-handler.coffee +++ b/src/window-event-handler.coffee @@ -19,14 +19,7 @@ class WindowEventHandler @addEventListener(window, 'blur', @handleWindowBlur) @addEventListener(window, 'beforeunload', @handleWindowBeforeunload) @addEventListener(window, 'unload', @handleWindowUnload) - @addEventListener(window, 'window:toggle-full-screen', @handleWindowToggleFullScreen) - @addEventListener(window, 'window:close', @handleWindowClose) - @addEventListener(window, 'window:reload', @handleWindowReload) - @addEventListener(window, 'window:toggle-dev-tools', @handleWindowToggleDevTools) - @addEventListener(window, 'window:toggle-menu-bar', @handleWindowToggleMenuBar) if process.platform in ['win32', 'linux'] - @addEventListener(document, 'core:focus-next', @handleFocusNext) - @addEventListener(document, 'core:focus-previous', @handleFocusPrevious) @addEventListener(document, 'keydown', @handleDocumentKeydown) @addEventListener(document, 'drop', @handleDocumentDrop) @addEventListener(document, 'dragover', @handleDocumentDragover) @@ -34,6 +27,20 @@ class WindowEventHandler @addEventListener(document, 'submit', @handleDocumentSubmit) @addEventListener(document, 'contextmenu', @handleDocumentContextmenu) + @subscriptions.add atom.commands.add window, + 'window:toggle-full-screen': @handleWindowToggleFullScreen + 'window:close': @handleWindowClose + 'window:reload': @handleWindowReload + 'window:toggle-dev-tools': @handleWindowToggleDevTools + + if process.platform in ['win32', 'linux'] + @subscriptions.add atom.commands.add window, + 'window:toggle-menu-bar': @handleWindowToggleMenuBar + + @subscriptions.add atom.commands.add document, + 'core:focus-next': @handleFocusNext + 'core:focus-previous': @handleFocusPrevious + @handleNativeKeybindings() # Wire commands that should be handled by Chromium for elements with the