Access window through native view

This commit is contained in:
Kevin Sawicki 2016-08-23 09:51:54 -07:00
parent 88979a9844
commit dd5ee28b2f
2 changed files with 3 additions and 5 deletions

View file

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

View file

@ -4,9 +4,7 @@
#include "atom/browser/api/atom_api_web_contents.h" #include "atom/browser/api/atom_api_web_contents.h"
@interface NSWindow #import <Cocoa/Cocoa.h>
- (BOOL)isKeyWindow;
@end
namespace atom { namespace atom {
@ -17,7 +15,7 @@ bool WebContents::IsFocused() const {
if (!view) return false; if (!view) return false;
if (GetType() != BACKGROUND_PAGE) { 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 // 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. // loses focus so check if the top level window is the key window.
if (window && ![window isKeyWindow]) if (window && ![window isKeyWindow])