mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Windows: Use WS_EX_NOACTIVATE to control initial window activation (issue #1856)
This commit is contained in:
@@ -207,8 +207,27 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
gfx::Rect(0, 0, point.x(), point.y()));
|
||||
|
||||
window_widget_ = delegate_view->GetWidget();
|
||||
|
||||
const HWND widget_hwnd = HWNDForWidget(window_widget_);
|
||||
DCHECK(widget_hwnd);
|
||||
const DWORD widget_ex_styles = GetWindowLongPtr(widget_hwnd, GWL_EXSTYLE);
|
||||
|
||||
if (window_info_.ex_style & WS_EX_NOACTIVATE) {
|
||||
// Add the WS_EX_NOACTIVATE style on the DesktopWindowTreeHostWin HWND
|
||||
// so that HWNDMessageHandler::Show() called via Widget::Show() does not
|
||||
// activate the window.
|
||||
SetWindowLongPtr(widget_hwnd, GWL_EXSTYLE,
|
||||
widget_ex_styles | WS_EX_NOACTIVATE);
|
||||
}
|
||||
|
||||
window_widget_->Show();
|
||||
|
||||
if (window_info_.ex_style & WS_EX_NOACTIVATE) {
|
||||
// Remove the WS_EX_NOACTIVATE style so that future mouse clicks inside the
|
||||
// browser correctly activate and focus the window.
|
||||
SetWindowLongPtr(widget_hwnd, GWL_EXSTYLE, widget_ex_styles);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user