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:
parent
cad7054e4f
commit
0bc906853e
2 changed files with 22 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue