]> khamidou — GitHub mirrors - electron.git/commitdiff
BrowserWindow.focus() should not make window become visible, fixed #106. v0.5.4
authorCheng Zhao <zcbenz@gmail.com>
Thu, 3 Oct 2013 01:39:17 +0000 (09:39 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 3 Oct 2013 01:42:20 +0000 (09:42 +0800)
browser/native_window_mac.mm
spec/api/window.coffee

index d538d983ceeeadb6e69d2d0419ac0406bc0f0bfc..47fabbfa02b1135bdc073c7b36e07fcde0a03e38 100644 (file)
@@ -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 {
index a291af59487618d5c35d01fe5a495c9940af8840..ebaf69a422f69458b8f83e88d6266061e0117bb9 100644 (file)
@@ -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)