views: Support configuration of initial window show state

Known issues:
- Exiting full-screen mode currently crashes with the Chrome runtime
  (see issue #3182).
This commit is contained in:
Marshall Greenblatt
2021-09-07 17:04:55 +03:00
parent 2b40cab3fe
commit dc1f934865
16 changed files with 147 additions and 17 deletions

View File

@@ -56,8 +56,6 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::Create(
ChromeBrowserHostImpl::GetBrowserForContents(web_contents);
CHECK(browser_host);
browser->window()->Show();
return browser_host;
}

View File

@@ -218,9 +218,15 @@ void CefBrowserPlatformDelegateViews::SendTouchEvent(
}
void CefBrowserPlatformDelegateViews::SendFocusEvent(bool setFocus) {
// Will result in a call to WebContents::Focus().
if (setFocus && browser_view_->root_view())
// Will activate the Widget and result in a call to WebContents::Focus().
if (setFocus && browser_view_->root_view()) {
if (auto widget = GetWindowWidget()) {
// Don't activate a minimized Widget, or it will be shown.
if (widget->IsMinimized())
return;
}
browser_view_->root_view()->RequestFocus();
}
}
gfx::Point CefBrowserPlatformDelegateViews::GetScreenPoint(

View File

@@ -276,6 +276,22 @@ void CefWindowView::CreateWidget() {
SetCanResize(cef_delegate()->CanResize(cef_window));
const auto show_state = cef_delegate()->GetInitialShowState(cef_window);
switch (show_state) {
case CEF_SHOW_STATE_NORMAL:
params.show_state = ui::SHOW_STATE_NORMAL;
break;
case CEF_SHOW_STATE_MINIMIZED:
params.show_state = ui::SHOW_STATE_MINIMIZED;
break;
case CEF_SHOW_STATE_MAXIMIZED:
params.show_state = ui::SHOW_STATE_MAXIMIZED;
break;
case CEF_SHOW_STATE_FULLSCREEN:
params.show_state = ui::SHOW_STATE_FULLSCREEN;
break;
}
bool is_menu = false;
bool can_activate_menu = true;
CefRefPtr<CefWindow> parent_window = cef_delegate()->GetParentWindow(