From 265dd76fd5f34d28cb567554b540f5d8cce1b8f6 Mon Sep 17 00:00:00 2001 From: "dpolukhin@chromium.org" Date: Fri, 21 May 2010 08:57:33 +0000 Subject: NativeViewHostGtk should use gtk_views_fixed instead of gtk_fixed and avoid calling gtk_widget_set_size_request to don't spoil preferred size for native controls. BUG=crosbug.com/2876 TEST=See bug description. Review URL: http://codereview.chromium.org/2068006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47900 0039d316-1c4b-4281-b951-d872f2087c98 --- views/controls/native/native_view_host_gtk.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'views') diff --git a/views/controls/native/native_view_host_gtk.cc b/views/controls/native/native_view_host_gtk.cc index 79a144d..40af166 100644 --- a/views/controls/native/native_view_host_gtk.cc +++ b/views/controls/native/native_view_host_gtk.cc @@ -10,6 +10,7 @@ #include "base/logging.h" #include "views/controls/native/native_view_host.h" #include "views/focus/focus_manager.h" +#include "views/widget/gtk_views_fixed.h" #include "views/widget/widget_gtk.h" namespace views { @@ -228,13 +229,17 @@ void NativeViewHostGtk::ShowWidget(int x, int y, int w, int h) { fixed_h = std::min(installed_clip_bounds_.height(), h); } + // Size and place the hosted NativeView. It should be done BEFORE placing + // fixed_ itself, otherwise controls will initially appear at 0,0 of fixed_ + // parent. + GtkAllocation alloc = { child_x, child_y, child_w, child_h }; + gtk_widget_size_allocate(host_->native_view(), &alloc); + gtk_views_fixed_set_use_allocated_size(host_->native_view(), true); + gtk_fixed_move(GTK_FIXED(fixed_), host_->native_view(), child_x, child_y); + // Size and place the fixed_. GetHostWidget()->PositionChild(fixed_, fixed_x, fixed_y, fixed_w, fixed_h); - // Size and place the hosted NativeView. - gtk_widget_set_size_request(host_->native_view(), child_w, child_h); - gtk_fixed_move(GTK_FIXED(fixed_), host_->native_view(), child_x, child_y); - gtk_widget_show(fixed_); gtk_widget_show(host_->native_view()); } @@ -272,7 +277,7 @@ void NativeViewHostGtk::CreateFixed(bool needs_window) { DestroyFixed(); - fixed_ = gtk_fixed_new(); + fixed_ = gtk_views_fixed_new(); gtk_widget_set_name(fixed_, "views-native-view-host-fixed"); gtk_fixed_set_has_window(GTK_FIXED(fixed_), needs_window); // Defeat refcounting. We need to own the fixed. -- cgit v1.1