From dd5ee28b2ff8389239089c7876a76d1a7950f998 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 23 Aug 2016 09:51:54 -0700 Subject: [PATCH] Access window through native view --- atom/browser/api/atom_api_web_contents.cc | 2 +- atom/browser/api/atom_api_web_contents_mac.mm | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index e77338253fde..b1ef28e7312b 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/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; } diff --git a/atom/browser/api/atom_api_web_contents_mac.mm b/atom/browser/api/atom_api_web_contents_mac.mm index 913951737fe8..c60639f16131 100644 --- a/atom/browser/api/atom_api_web_contents_mac.mm +++ b/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 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])