From a47b3273dd2c0662b50bb230292cd26beddc1490 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 3 Oct 2013 18:14:01 -0700 Subject: [PATCH] Send events to browser window even when not focused The window:open-path event regressed and was not being sent to Atom which prevented windows from being opened with specific file(s) in the editor. Also this allows context menus to work even when the dev tools are open. --- src/atom-window.coffee | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/atom-window.coffee b/src/atom-window.coffee index 909715da8..350aac6f5 100644 --- a/src/atom-window.coffee +++ b/src/atom-window.coffee @@ -99,16 +99,23 @@ class AtomWindow @browserWindow.once 'window:loaded', => @openPath(pathToOpen, initialLine) sendCommand: (command, args...) -> - if @handlesAtomCommands() - @sendAtomCommand(command, args...) + if @isSpecWindow() + unless @sendCommandToFirstResponder(command) + switch command + when 'window:reload' then @reload() + when 'window:toggle-dev-tools' then @toggleDevTools() + when 'window:close' then @close() + else if @isWebViewFocused() + @sendCommandToBrowserWindow(command, args...) else - @sendNativeCommand(command) + unless @sendCommandToFirstResponder(command) + @sendCommandToBrowserWindow(command, args...) - sendAtomCommand: (command, args...) -> + sendCommandToBrowserWindow: (command, args...) -> action = if args[0]?.contextCommand then 'context-command' else 'command' ipc.sendChannel @browserWindow.getProcessId(), @browserWindow.getRoutingId(), action, command, args... - sendNativeCommand: (command) -> + sendCommandToFirstResponder: (command) -> switch command when 'core:undo' then Menu.sendActionToFirstResponder('undo:') when 'core:redo' then Menu.sendActionToFirstResponder('redo:') @@ -116,9 +123,8 @@ class AtomWindow 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() + else return false + true close: -> @browserWindow.close()