fix: macOS modal focus (#24286)

This commit is contained in:
Shelley Vohr 2020-06-29 13:15:28 -07:00 committed by GitHub
parent d9d07c65b2
commit af4876296c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 10 deletions

View file

@ -284,22 +284,14 @@ void BrowserWindow::OnWindowClosed() {
void BrowserWindow::OnWindowBlur() {
web_contents()->StoreFocus();
#if defined(OS_MACOSX)
auto* rwhv = web_contents()->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetActive(false);
#endif
BaseWindow::OnWindowBlur();
}
void BrowserWindow::OnWindowFocus() {
web_contents()->RestoreFocus();
#if defined(OS_MACOSX)
auto* rwhv = web_contents()->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetActive(true);
#else
#if !defined(OS_MACOSX)
if (!api_web_contents_->IsDevToolsOpened())
web_contents()->Focus();
#endif
@ -307,6 +299,14 @@ void BrowserWindow::OnWindowFocus() {
BaseWindow::OnWindowFocus();
}
void BrowserWindow::OnWindowIsKeyChanged(bool is_key) {
#if defined(OS_MACOSX)
auto* rwhv = web_contents()->GetRenderWidgetHostView();
if (rwhv)
rwhv->SetActive(is_key);
#endif
}
void BrowserWindow::OnWindowResize() {
#if defined(OS_MACOSX)
if (!draggable_regions_.empty())