views: Fix multiple issues with hide-frame (fixes issue #3168)

This commit is contained in:
Marshall Greenblatt 2021-08-04 14:20:31 -04:00
parent 39dbdf8ddb
commit ad71ec9fdf
3 changed files with 28 additions and 7 deletions

View File

@ -182,6 +182,7 @@ class CaptionlessFrameView : public views::NonClientFrameView {
void Layout() override {
client_view_bounds_.SetRect(0, 0, width(), height());
views::NonClientFrameView::Layout();
}
gfx::Size CalculatePreferredSize() const override {

View File

@ -488,13 +488,7 @@ void ViewsWindow::OnWindowCreated(CefRefPtr<CefWindow> window) {
delegate_->OnViewsWindowCreated(this);
CefRect bounds = delegate_->GetWindowBounds();
if (bounds.IsEmpty()) {
// Use the default size.
bounds.width = 800;
bounds.height = 600;
}
const CefRect bounds = GetInitialBounds();
if (bounds.x == 0 && bounds.y == 0) {
// Size the Window and center it.
window_->CenterWindow(CefSize(bounds.width, bounds.height));
@ -569,6 +563,18 @@ CefRefPtr<CefWindow> ViewsWindow::GetParentWindow(CefRefPtr<CefWindow> window,
return parent_window;
}
CefRect ViewsWindow::GetInitialBounds(CefRefPtr<CefWindow> window) {
CEF_REQUIRE_UI_THREAD();
if (frameless_) {
// Need to provide a size for frameless windows that will be centered.
const CefRect bounds = GetInitialBounds();
if (bounds.x == 0 && bounds.y == 0) {
return bounds;
}
}
return CefRect();
}
bool ViewsWindow::IsFrameless(CefRefPtr<CefWindow> window) {
CEF_REQUIRE_UI_THREAD();
return frameless_;
@ -1016,4 +1022,15 @@ void ViewsWindow::OnExtensionWindowClosed() {
extension_button_pressed_lock_ = nullptr;
}
CefRect ViewsWindow::GetInitialBounds() const {
CEF_REQUIRE_UI_THREAD();
CefRect bounds = delegate_->GetWindowBounds();
if (bounds.IsEmpty()) {
// Use the default size.
bounds.width = 800;
bounds.height = 600;
}
return bounds;
}
} // namespace client

View File

@ -154,6 +154,7 @@ class ViewsWindow : public CefBrowserViewDelegate,
CefRefPtr<CefWindow> GetParentWindow(CefRefPtr<CefWindow> window,
bool* is_menu,
bool* can_activate_menu) override;
CefRect GetInitialBounds(CefRefPtr<CefWindow> window) override;
bool IsFrameless(CefRefPtr<CefWindow> window) override;
bool CanResize(CefRefPtr<CefWindow> window) override;
bool CanClose(CefRefPtr<CefWindow> window) override;
@ -207,6 +208,8 @@ class ViewsWindow : public CefBrowserViewDelegate,
const ImageCache::ImageSet& images);
void OnExtensionWindowClosed();
CefRect GetInitialBounds() const;
Delegate* delegate_; // Not owned by this object.
CefRefPtr<CefBrowserView> browser_view_;
bool frameless_;