Browse Source

Access window through native view

Kevin Sawicki 8 years ago
parent
commit
dd5ee28b2f

+ 1 - 1
atom/browser/api/atom_api_web_contents.cc

@@ -1175,7 +1175,7 @@ bool WebContents::IsFocused() const {
   if (!view) return false;
 
   if (GetType() != BACKGROUND_PAGE) {
-    auto window = web_contents()->GetTopLevelNativeWindow();
+    auto window = web_contents()->GetNativeView()->GetTopLevelWindow();
     if (window && !window->IsVisible())
       return false;
   }

+ 2 - 4
atom/browser/api/atom_api_web_contents_mac.mm

@@ -4,9 +4,7 @@
 
 #include "atom/browser/api/atom_api_web_contents.h"
 
-@interface NSWindow
-- (BOOL)isKeyWindow;
-@end
+#import <Cocoa/Cocoa.h>
 
 namespace atom {
 
@@ -17,7 +15,7 @@ bool WebContents::IsFocused() const {
   if (!view) return false;
 
   if (GetType() != BACKGROUND_PAGE) {
-    auto window = web_contents()->GetTopLevelNativeWindow();
+    auto window = [web_contents()->GetNativeView() window];
     // On Mac the render widget host view does not lose focus when the window
     // loses focus so check if the top level window is the key window.
     if (window && ![window isKeyWindow])