diff --git a/src/atom-application.coffee b/src/atom-application.coffee index 373275104..c8fe95c8c 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -141,26 +141,8 @@ class AtomApplication @emit(command) sendCommand: (command, args...) -> - return if @emit(command, args...) - return if @interceptAlternativeWindowCommands(command) - - @focusedWindow()?.sendCommand(command, args...) - - interceptAlternativeWindowCommands: (command) -> - return if not @focusedWindow()?.isSpecWindow() and @focusedWindow()?.isWebViewFocused() - - switch command - when 'core:undo' then Menu.sendActionToFirstResponder('undo:') - when 'core:redo' then Menu.sendActionToFirstResponder('redo:') - when 'core:copy' then Menu.sendActionToFirstResponder('copy:') - when 'core:cut' then Menu.sendActionToFirstResponder('cut:') - when 'core:paste' then Menu.sendActionToFirstResponder('paste:') - when 'core:select-all' then Menu.sendActionToFirstResponder('selectAll:') - when 'window:reload' then @focusedWindow()?.reload() - when 'window:toggle-dev-tools' then @focusedWindow()?.toggleDevTools() - when 'window:close' then @focusedWindow()?.close() - else return false - return true + unless @emit(command, args...) + @focusedWindow()?.sendCommand(command, args...) windowForPath: (pathToOpen) -> for atomWindow in @windows diff --git a/src/atom-window.coffee b/src/atom-window.coffee index e7ee2708c..8973ef4b7 100644 --- a/src/atom-window.coffee +++ b/src/atom-window.coffee @@ -115,12 +115,33 @@ class AtomWindow @contextMenu.append(@inspectElementMenuItem) sendCommand: (command, args...) -> + if @handlesAtomCommands() + @sendAtomCommand(command, args...) + else + @sendNativeCommand(command) + + sendAtomCommand: (command, args...) -> ipc.sendChannel @browserWindow.getProcessId(), @browserWindow.getRoutingId(), 'command', command, args... + sendNativeCommand: (command) -> + switch command + when 'core:undo' then Menu.sendActionToFirstResponder('undo:') + when 'core:redo' then Menu.sendActionToFirstResponder('redo:') + when 'core:copy' then Menu.sendActionToFirstResponder('copy:') + when 'core:cut' then Menu.sendActionToFirstResponder('cut:') + when 'core:paste' then Menu.sendActionToFirstResponder('paste:') + when 'core:select-all' then Menu.sendActionToFirstResponder('selectAll:') + when 'window:reload' then @reload() + when 'window:toggle-dev-tools' then @toggleDevTools() + when 'window:close' then @close() + close: -> @browserWindow.close() focus: -> @browserWindow.focus() + handlesAtomCommands: -> + not @isSpecWindow() and @isWebViewFocused() + isFocused: -> @browserWindow.isFocused() isWebViewFocused: -> @browserWindow.isWebViewFocused()