fix: call focus on native window on call to webContents.focus on mac (#22323)

* fix: call focus on native window on call to webContents.focus on mac

On mac call to web_contents()->Focus() is not enough so it's
necessary to call it on native window.

* fixup! fix: call focus on native window on call to webContents.focus on mac

* fixup! fix: call focus on native window on call to webContents.focus on mac

* test: close all windows after test

* fix: also match the behavior on Linux

Co-authored-by: Cheng Zhao <zcbenz@github.com>
This commit is contained in:
CezaryKulakowski 2020-03-02 08:51:02 +01:00 committed by GitHub
parent cad7054e4f
commit 0bc906853e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View file

@ -2071,6 +2071,12 @@ void WebContents::CopyImageAt(int x, int y) {
}
void WebContents::Focus() {
// Focusing on WebContents does not automatically focus the window on macOS
// and Linux, do it manually to match the behavior on Windows.
#if defined(OS_MACOSX) || defined(OS_LINUX)
if (owner_window())
owner_window()->Focus(true);
#endif
web_contents()->Focus();
}