From 64e6971099db51a2079cf9d44195ee3d8ceb5613 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 25 Aug 2017 14:41:30 -0700 Subject: [PATCH] views: Linux: Support CefWindowDelegate::CanResize restriction --- libcef/browser/views/window_view.cc | 24 +++++++++++++ libcef/browser/views/window_view.h | 2 ++ patch/patch.cfg | 2 ++ ...views_widget_180_1481_1565_1677_1749.patch | 34 ++++++++++++++++++- 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/libcef/browser/views/window_view.cc b/libcef/browser/views/window_view.cc index 5f856c156..7e56692ee 100644 --- a/libcef/browser/views/window_view.cc +++ b/libcef/browser/views/window_view.cc @@ -436,6 +436,30 @@ bool CefWindowView::ShouldDescendIntoChildForEventHandling( !draggable_region_->contains(location.x(), location.y()); } +bool CefWindowView::MaybeGetMinimumSize(gfx::Size* size) const { +#if defined(OS_LINUX) + // Resize is disabled on Linux by returning the preferred size as the min/max + // size. + if (!CanResize()) { + *size = CalculatePreferredSize(); + return true; + } +#endif + return false; +} + +bool CefWindowView::MaybeGetMaximumSize(gfx::Size* size) const { +#if defined(OS_LINUX) + // Resize is disabled on Linux by returning the preferred size as the min/max + // size. + if (!CanResize()) { + *size = CalculatePreferredSize(); + return true; + } +#endif + return false; +} + void CefWindowView::ViewHierarchyChanged( const views::View::ViewHierarchyChangedDetails& details) { if (details.child == this) { diff --git a/libcef/browser/views/window_view.h b/libcef/browser/views/window_view.h index 005668c71..2cb333d56 100644 --- a/libcef/browser/views/window_view.h +++ b/libcef/browser/views/window_view.h @@ -68,6 +68,8 @@ class CefWindowView bool ShouldDescendIntoChildForEventHandling( gfx::NativeView child, const gfx::Point& location) override; + bool MaybeGetMinimumSize(gfx::Size* size) const override; + bool MaybeGetMaximumSize(gfx::Size* size) const override; // views::View methods: void ViewHierarchyChanged( diff --git a/patch/patch.cfg b/patch/patch.cfg index 37c211ff1..1fa83177c 100644 --- a/patch/patch.cfg +++ b/patch/patch.cfg @@ -79,6 +79,8 @@ patches = [ # and WS_SYSMENU styles. Otherwise Windows 10 enforces a minimum window # width of ~116 units that cannot be overridden. # Linux: Allow creation of activatable menu windows. + # Linux: Support CefWindowDelegate::CanResize restriction by specifying + # min/max Widget size values. # https://bitbucket.org/chromiumembedded/cef/issues/1947 # # Support configuration of RWHVGuest device scale factor. diff --git a/patch/patches/views_widget_180_1481_1565_1677_1749.patch b/patch/patches/views_widget_180_1481_1565_1677_1749.patch index 9e1ea04f5..e69f506b0 100644 --- a/patch/patches/views_widget_180_1481_1565_1677_1749.patch +++ b/patch/patches/views_widget_180_1481_1565_1677_1749.patch @@ -335,7 +335,7 @@ index cb18967..0c143d2 100644 base::WeakPtrFactory weak_factory_; diff --git ui/views/widget/widget.cc ui/views/widget/widget.cc -index 32a50e8..06d39f0 100644 +index 32a50e8..43191a9 100644 --- ui/views/widget/widget.cc +++ ui/views/widget/widget.cc @@ -130,6 +130,7 @@ Widget::InitParams::InitParams(Type type) @@ -369,6 +369,23 @@ index 32a50e8..06d39f0 100644 } // This must come after SetContentsView() or it might not be able to find // the correct NativeTheme (on Linux). See http://crbug.com/384492 +@@ -1098,10 +1104,16 @@ void Widget::OnNativeWidgetDestroyed() { + } + + gfx::Size Widget::GetMinimumSize() const { ++ gfx::Size size; ++ if (widget_delegate_->MaybeGetMinimumSize(&size)) ++ return size; + return non_client_view_ ? non_client_view_->GetMinimumSize() : gfx::Size(); + } + + gfx::Size Widget::GetMaximumSize() const { ++ gfx::Size size; ++ if (widget_delegate_->MaybeGetMaximumSize(&size)) ++ return size; + return non_client_view_ ? non_client_view_->GetMaximumSize() : gfx::Size(); + } + diff --git ui/views/widget/widget.h ui/views/widget/widget.h index 63fcb9d..7237ae6 100644 --- ui/views/widget/widget.h @@ -381,6 +398,21 @@ index 63fcb9d..7237ae6 100644 // Specifies the initial bounds of the Widget. Default is empty, which means // the NativeWidget may specify a default size. If the parent is specified, // |bounds| is in the parent's coordinate system. If the parent is not +diff --git ui/views/widget/widget_delegate.h ui/views/widget/widget_delegate.h +index bd4d8a7..998cfa0 100644 +--- ui/views/widget/widget_delegate.h ++++ ui/views/widget/widget_delegate.h +@@ -187,6 +187,10 @@ class VIEWS_EXPORT WidgetDelegate { + // be cycled through with keyboard focus. + virtual void GetAccessiblePanes(std::vector* panes) {} + ++ // CEF supports override of min/max size values. ++ virtual bool MaybeGetMinimumSize(gfx::Size* size) const { return false; } ++ virtual bool MaybeGetMaximumSize(gfx::Size* size) const { return false; } ++ + protected: + virtual ~WidgetDelegate() {} + diff --git ui/views/widget/widget_hwnd_utils.cc ui/views/widget/widget_hwnd_utils.cc index 163e4b5..58f594db 100644 --- ui/views/widget/widget_hwnd_utils.cc