mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user