Windows: Use WS_EX_NOACTIVATE to control initial window activation (issue #1856)

This commit is contained in:
Marshall Greenblatt
2019-02-07 16:36:31 -05:00
parent 84a5749f9f
commit b8eaec0db2
10 changed files with 107 additions and 7 deletions

View File

@@ -26,6 +26,11 @@ void BrowserWindowStdWin::CreateBrowser(
RECT wnd_rect = {rect.x, rect.y, rect.x + rect.width, rect.y + rect.height};
window_info.SetAsChild(parent_handle, wnd_rect);
if (GetWindowLongPtr(parent_handle, GWL_EXSTYLE) & WS_EX_NOACTIVATE) {
// Don't activate the browser window on creation.
window_info.ex_style |= WS_EX_NOACTIVATE;
}
CefBrowserHost::CreateBrowser(window_info, client_handler_,
client_handler_->startup_url(), settings,
request_context);
@@ -39,6 +44,10 @@ void BrowserWindowStdWin::GetPopupConfig(CefWindowHandle temp_handle,
// The window will be properly sized after the browser is created.
windowInfo.SetAsChild(temp_handle, RECT());
// Don't activate the hidden browser window on creation.
windowInfo.ex_style |= WS_EX_NOACTIVATE;
client = client_handler_;
}
@@ -53,8 +62,11 @@ void BrowserWindowStdWin::ShowPopup(ClientWindowHandle parent_handle,
if (hwnd) {
SetParent(hwnd, parent_handle);
SetWindowPos(hwnd, NULL, x, y, static_cast<int>(width),
static_cast<int>(height), SWP_NOZORDER);
ShowWindow(hwnd, SW_SHOW);
static_cast<int>(height), SWP_NOZORDER | SWP_NOACTIVATE);
const bool no_activate =
GetWindowLongPtr(parent_handle, GWL_EXSTYLE) & WS_EX_NOACTIVATE;
ShowWindow(hwnd, no_activate ? SW_SHOWNOACTIVATE : SW_SHOW);
}
}