]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Emit focus/blur events after page has actually focus/blur-ed.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 31 Jul 2014 09:35:08 +0000 (17:35 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 31 Jul 2014 09:35:08 +0000 (17:35 +0800)
Otherwise the page would receive the blur event when it has not blured
yet.

Fixes atom/atom#3124.

atom/browser/native_window_mac.mm

index 804595edbcfc06f69d35fe8417810c20c6433beb..919ffcf1a25cf584e5cc5f6231797b7415d8dadd 100644 (file)
@@ -49,8 +49,6 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
 }
 
 - (void)windowDidBecomeMain:(NSNotification*)notification {
-  shell_->NotifyWindowFocus();
-
   content::WebContents* web_contents = shell_->GetWebContents();
   if (!web_contents)
     return;
@@ -60,11 +58,11 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
   content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
   if (rwhv)
     rwhv->SetActive(true);
+
+  shell_->NotifyWindowFocus();
 }
 
 - (void)windowDidResignMain:(NSNotification*)notification {
-  shell_->NotifyWindowBlur();
-
   content::WebContents* web_contents = shell_->GetWebContents();
   if (!web_contents)
     return;
@@ -74,6 +72,8 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
   content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
   if (rwhv)
     rwhv->SetActive(false);
+
+  shell_->NotifyWindowBlur();
 }
 
 - (void)windowDidResize:(NSNotification*)otification {