Index: views/widget/widget_gtk.cc |
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc |
index 1e73e38e678fa0f5b123185ccc4b1fd627983ac8..c9144d7729008883f1bacccbf7ab1ba815b52eeb 100644 |
--- a/views/widget/widget_gtk.cc |
+++ b/views/widget/widget_gtk.cc |
@@ -500,6 +500,8 @@ void WidgetGtk::Init(GtkWidget* parent, |
GDK_KEY_RELEASE_MASK); |
SetRootViewForWidget(widget_, root_view_.get()); |
+ g_signal_connect_after(G_OBJECT(window_contents_), "size_request", |
+ G_CALLBACK(&OnSizeRequestThunk), this); |
g_signal_connect_after(G_OBJECT(window_contents_), "size_allocate", |
G_CALLBACK(&OnSizeAllocateThunk), this); |
gtk_widget_set_app_paintable(window_contents_, true); |
@@ -883,6 +885,18 @@ int WidgetGtk::GetFlagsForEventButton(const GdkEventButton& event) { |
return flags; |
} |
+void WidgetGtk::OnSizeRequest(GtkWidget* widget, GtkRequisition* requisition) { |
+ // Do only return the preferred size for child windows. GtkWindow interprets |
+ // the requisition as a minimum size for top level windows, returning a |
+ // preferred size for these would prevents us from setting smaller window |
+ // sizes. |
+ if (type_ == TYPE_CHILD) { |
+ gfx::Size size(root_view_->GetPreferredSize()); |
+ requisition->width = size.width(); |
+ requisition->height = size.height(); |
+ } |
+} |
+ |
void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { |
// See comment next to size_ as to why we do this. Also note, it's tempting |
// to put this in the static method so subclasses don't need to worry about |