From 394bf0a8d9dc41cd5604b21a20321ef0092c2a87 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 16 May 2013 23:00:43 +0800 Subject: [PATCH] Add BrowserWindow.getFocusedWindow() API. --- browser/api/lib/browser_window.coffee | 5 +++++ browser/default_app/main.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/browser/api/lib/browser_window.coffee b/browser/api/lib/browser_window.coffee index 8467d848ee92..24810af2c906 100644 --- a/browser/api/lib/browser_window.coffee +++ b/browser/api/lib/browser_window.coffee @@ -1,6 +1,11 @@ EventEmitter = require('events').EventEmitter +objectsRegistry = require '../../atom/objects_registry.js' BrowserWindow = process.atomBinding('window').BrowserWindow BrowserWindow.prototype.__proto__ = EventEmitter.prototype +BrowserWindow.getFocusedWindow = -> + windows = objectsRegistry.getAllWindows() + return window for window in windows when window.isFocused() + module.exports = BrowserWindow diff --git a/browser/default_app/main.js b/browser/default_app/main.js index 37030eab46c9..7076058f5037 100644 --- a/browser/default_app/main.js +++ b/browser/default_app/main.js @@ -69,10 +69,12 @@ delegate.browserMainParts.preMainMessageLoopRun = function() { { label: 'Reload', accelerator: 'Command+R', + click: function() { BrowserWindow.getFocusedWindow().reloadIgnoringCache(); } }, { label: 'Show DevTools', accelerator: 'Alt+Command+I', + click: function() { BrowserWindow.getFocusedWindow().openDevTools(); } }, ] },