From c58bf15345bf990a739c96ec44efbcc19190f2fb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 9 Sep 2014 17:54:37 +0800 Subject: [PATCH] mac: Send focus/blur event to devtools web contents. --- .../mac/bry_inspectable_web_contents_view.mm | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/brightray/browser/mac/bry_inspectable_web_contents_view.mm b/brightray/browser/mac/bry_inspectable_web_contents_view.mm index 0fa06f2077d3..4db0d8ac050f 100644 --- a/brightray/browser/mac/bry_inspectable_web_contents_view.mm +++ b/brightray/browser/mac/bry_inspectable_web_contents_view.mm @@ -148,4 +148,30 @@ using namespace brightray; inspectableWebContentsView_->inspectable_web_contents()->CloseDevTools(); } +- (void)windowDidBecomeMain:(NSNotification*)notification { + content::WebContents* web_contents = + inspectableWebContentsView_->inspectable_web_contents()->devtools_web_contents(); + if (!web_contents) + return; + + web_contents->RestoreFocus(); + + content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); + if (rwhv) + rwhv->SetActive(true); +} + +- (void)windowDidResignMain:(NSNotification*)notification { + content::WebContents* web_contents = + inspectableWebContentsView_->inspectable_web_contents()->devtools_web_contents(); + if (!web_contents) + return; + + web_contents->StoreFocus(); + + content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); + if (rwhv) + rwhv->SetActive(false); +} + @end