diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-30 21:07:03 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-30 21:07:03 +0000 |
commit | 2700f1fbc312341d938e4a1dee36c762bb298aa9 (patch) | |
tree | 957aa7106fe2eff9c015b3b060a20126a82d99a6 | |
parent | 04c7c13c6901e5488f3a49a11c04b989d81b1649 (diff) | |
download | chromium_src-2700f1fbc312341d938e4a1dee36c762bb298aa9.zip chromium_src-2700f1fbc312341d938e4a1dee36c762bb298aa9.tar.gz chromium_src-2700f1fbc312341d938e4a1dee36c762bb298aa9.tar.bz2 |
Makes WidgetGtk specify a size before realizing the window. Without
this we might not end up with the correct size.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/149111
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19657 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | views/widget/widget_gtk.cc | 12 | ||||
-rw-r--r-- | views/widget/widget_gtk.h | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 8d274ea..64493c4 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -87,7 +87,7 @@ void WidgetGtk::Init(GtkWidget* parent, #endif // Make container here. - CreateGtkWidget(parent); + CreateGtkWidget(parent, bounds); // Make sure we receive our motion events. @@ -403,7 +403,7 @@ void WidgetGtk::DidProcessEvent(GdkEvent* event) { //////////////////////////////////////////////////////////////////////////////// // TODO(beng): organize into sections: -void WidgetGtk::CreateGtkWidget(GtkWidget* parent) { +void WidgetGtk::CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds) { if (type_ == TYPE_CHILD) { window_contents_ = widget_ = gtk_fixed_new(); gtk_fixed_set_has_window(GTK_FIXED(widget_), true); @@ -418,6 +418,14 @@ void WidgetGtk::CreateGtkWidget(GtkWidget* parent) { } else { widget_ = gtk_window_new( type_ == TYPE_WINDOW ? GTK_WINDOW_TOPLEVEL : GTK_WINDOW_POPUP); + + if (!bounds.size().IsEmpty()) { + // When we realize the window, the window manager is given a size. If we + // don't specify a size before then GTK defaults to 200x200. Specify + // a size now so that the window manager sees the requested size. + GtkAllocation alloc = { 0, 0, bounds.width(), bounds.height() }; + gtk_widget_size_allocate(widget_, &alloc); + } gtk_window_set_decorated(GTK_WINDOW(widget_), false); // We'll take care of positioning our window. gtk_window_set_position(GTK_WINDOW(widget_), GTK_WIN_POS_NONE); diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index b5dd6a0..193910b 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -184,7 +184,7 @@ class WidgetGtk : public Widget, public MessageLoopForUI::Observer { static Window* GetWindowImpl(GtkWidget* widget); // Creates the GtkWidget. - void CreateGtkWidget(GtkWidget* parent); + void CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds); // Attaches the widget contents to the window's widget. void AttachGtkWidgetToWindow(); |