From bbb9c37f70f49a3e794fcd7573f332bb98dab17e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 3 Oct 2013 09:39:17 +0800 Subject: [PATCH] BrowserWindow.focus() should not make window become visible, fixed #106. --- browser/native_window_mac.mm | 5 ++++- spec/api/window.coffee | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/browser/native_window_mac.mm b/browser/native_window_mac.mm index d538d983ceee..47fabbfa02b1 100644 --- a/browser/native_window_mac.mm +++ b/browser/native_window_mac.mm @@ -209,7 +209,10 @@ void NativeWindowMac::Move(const gfx::Rect& pos) { } void NativeWindowMac::Focus(bool focus) { - if (focus && [window() isVisible]) { + if (!IsVisible()) + return; + + if (focus) { [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; [window() makeKeyAndOrderFront:nil]; } else { diff --git a/spec/api/window.coffee b/spec/api/window.coffee index a291af594876..ebaf69a422f6 100644 --- a/spec/api/window.coffee +++ b/spec/api/window.coffee @@ -67,6 +67,14 @@ describe 'window module', -> ++count w.loadUrl 'about:blank' + describe 'BrowserWindow.focus()', -> + it 'does not make the window become visible', -> + w = new BrowserWindow(show: false) + assert.equal w.isVisible(), false + w.focus() + assert.equal w.isVisible(), false + w.close() + describe 'beforeunload handler', -> it 'returning true would not prevent close', (done) -> w = new BrowserWindow(show: false)