| Index: content/shell/shell_gtk.cc
|
| diff --git a/content/shell/shell_gtk.cc b/content/shell/shell_gtk.cc
|
| index 227d82b8520355155c2bc26b601044fd3e11b905..6082cf49af11da1aa186dbec3943b25bc6c62122 100644
|
| --- a/content/shell/shell_gtk.cc
|
| +++ b/content/shell/shell_gtk.cc
|
| @@ -101,10 +101,11 @@ void Shell::PlatformSetIsLoading(bool loading) {
|
| }
|
|
|
| void Shell::PlatformCreateWindow(int width, int height) {
|
| - SizeTo(width, height);
|
| -
|
| - if (headless_)
|
| + ui_elements_height_ = 0;
|
| + if (headless_) {
|
| + SizeTo(width, height);
|
| return;
|
| + }
|
|
|
| window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
|
| gtk_window_set_title(window_, "Content Shell");
|
| @@ -201,6 +202,25 @@ void Shell::PlatformCreateWindow(int width, int height) {
|
| gtk_box_pack_start(GTK_BOX(vbox_), toolbar, FALSE, FALSE, 0);
|
|
|
| gtk_container_add(GTK_CONTAINER(window_), vbox_);
|
| +
|
| + // Trigger layout of the UI elements, so that we can measure their
|
| + // heights. The width and height passed to this method are meant for the web
|
| + // contents view, not the top-level window. Since Gtk only seems to provide a
|
| + // suitable resizing function for top-level windows, we need to know how to
|
| + // convert from web contents view size to top-level window size.
|
| + gtk_widget_show_all(GTK_WIDGET(vbox_));
|
| +
|
| + // Measure the heights of the UI elements, now that they have been laid out.
|
| + GtkRequisition elm_size;
|
| + gtk_widget_size_request(menu_bar, &elm_size);
|
| + ui_elements_height_ += elm_size.height;
|
| + gtk_widget_size_request(toolbar, &elm_size);
|
| + ui_elements_height_ += elm_size.height;
|
| +
|
| + // We're ready to set an initial window size.
|
| + SizeTo(width, height);
|
| +
|
| + // Finally, show the window.
|
| gtk_widget_show_all(GTK_WIDGET(window_));
|
| }
|
|
|
| @@ -215,7 +235,13 @@ void Shell::PlatformSetContents() {
|
| void Shell::SizeTo(int width, int height) {
|
| content_width_ = width;
|
| content_height_ = height;
|
| - if (web_contents_) {
|
| +
|
| + // Prefer setting the top level window's size (if we have one), rather than
|
| + // setting the inner widget's minimum size (so that the user can shrink the
|
| + // window if she wants).
|
| + if (window_) {
|
| + gtk_window_resize(window_, width, height + ui_elements_height_);
|
| + } else if (web_contents_) {
|
| gtk_widget_set_size_request(web_contents_->GetView()->GetNativeView(),
|
| width, height);
|
| }
|
|
|