From bf862d1d07c9e677b7df28dcab206e9073fe4b57 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 6 Mar 2018 15:17:42 +0900 Subject: [PATCH] views: Focus webContents in BrowserWindow --- atom/browser/api/atom_api_browser_window.cc | 3 +++ atom/browser/native_window_views.cc | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/atom/browser/api/atom_api_browser_window.cc b/atom/browser/api/atom_api_browser_window.cc index 0f8eb04a20..8c7aa222e2 100644 --- a/atom/browser/api/atom_api_browser_window.cc +++ b/atom/browser/api/atom_api_browser_window.cc @@ -379,6 +379,9 @@ void BrowserWindow::OnWindowFocus() { auto* rwhv = web_contents()->GetRenderWidgetHostView(); if (rwhv) rwhv->SetActive(true); +#else + if (!api_web_contents_->IsDevToolsOpened()) + web_contents()->Focus(); #endif Emit("focus"); diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 00075fcee2..4d945235fc 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -1183,10 +1183,6 @@ void NativeWindowViews::OnWidgetActivationChanged( &NativeWindow::NotifyWindowBlur, GetWeakPtr())); - if (active && inspectable_web_contents() && - !inspectable_web_contents()->IsDevToolsViewShowing()) - web_contents()->Focus(); - // Hide menu bar when window is blured. if (!active && menu_bar_autohide_ && menu_bar_visible_) SetMenuBarVisibility(false);