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

@@ -249,7 +249,8 @@ ClientHandler::ClientHandler(Delegate* delegate,
browser_count_(0),
console_log_file_(MainContext::Get()->GetConsoleLogPath()),
first_console_message_(true),
focus_on_editable_field_(false) {
focus_on_editable_field_(false),
initial_navigation_(true) {
DCHECK(!console_log_file_.empty());
#if defined(OS_LINUX)
@@ -497,6 +498,22 @@ void ClientHandler::OnTakeFocus(CefRefPtr<CefBrowser> browser, bool next) {
NotifyTakeFocus(next);
}
bool ClientHandler::OnSetFocus(CefRefPtr<CefBrowser> browser,
FocusSource source) {
CEF_REQUIRE_UI_THREAD();
if (initial_navigation_) {
CefRefPtr<CefCommandLine> command_line =
CefCommandLine::GetGlobalCommandLine();
if (command_line->HasSwitch(switches::kNoActivate)) {
// Don't give focus to the browser on creation.
return true;
}
}
return false;
}
bool ClientHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
const CefKeyEvent& event,
CefEventHandle os_event,
@@ -606,6 +623,10 @@ void ClientHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
bool canGoForward) {
CEF_REQUIRE_UI_THREAD();
if (!isLoading && initial_navigation_) {
initial_navigation_ = false;
}
NotifyLoadingState(isLoading, canGoBack, canGoForward);
}