summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-01 21:10:22 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-01 21:10:22 +0000
commitb7a763ad855baecbbf22a617164d5b5fd43ae899 (patch)
treeb5af064882a0dcf112e59378f7b2f3f01ca0bb06 /views
parentae1eeb8d890e96db6ccb20e50e023c494fb9b024 (diff)
downloadchromium_src-b7a763ad855baecbbf22a617164d5b5fd43ae899.zip
chromium_src-b7a763ad855baecbbf22a617164d5b5fd43ae899.tar.gz
chromium_src-b7a763ad855baecbbf22a617164d5b5fd43ae899.tar.bz2
Fixes a couple of related bugs:
. gdk_display_get_pointer requires a display. . Don't do anything in NativeViewHostGtk if asked to remove and there is no native view. . Make NativeViewHostGtk deal with the native view already having the same parent. . Implement a couple of methods in NativeTabContentsContainerGtk. BUG=none TEST=none Review URL: http://codereview.chromium.org/115989 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17349 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/native/native_view_host_gtk.cc37
1 files changed, 27 insertions, 10 deletions
diff --git a/views/controls/native/native_view_host_gtk.cc b/views/controls/native/native_view_host_gtk.cc
index 223f3c2..4b88067c 100644
--- a/views/controls/native/native_view_host_gtk.cc
+++ b/views/controls/native/native_view_host_gtk.cc
@@ -41,19 +41,33 @@ void NativeViewHostGtk::SetViewForNative(GtkWidget* widget, View* view) {
void NativeViewHostGtk::NativeViewAttached() {
DCHECK(host_->native_view());
- // Adds a mapping between the GtkWidget and us.
- SetViewForNative(host_->native_view(), host_);
+ GtkWidget* current_parent = gtk_widget_get_parent(host_->native_view());
+ GtkWidget* new_parent = host_->GetWidget()->GetNativeView();
+ // Only adjust the parent if the parent actually changed.
+ if (current_parent != new_parent) {
+ // First hide the new window. We don't want anything to draw (like sub-hwnd
+ // borders), when we change the parent below.
+ gtk_widget_hide(host_->native_view());
- destroy_signal_id_ = g_signal_connect(G_OBJECT(host_->native_view()),
- "destroy", G_CALLBACK(CallDestroy),
- NULL);
+ if (current_parent) {
+ gtk_container_remove(GTK_CONTAINER(current_parent),
+ host_->native_view());
+ }
- // First hide the new window. We don't want anything to draw (like sub-hwnd
- // borders), when we change the parent below.
- gtk_widget_hide(host_->native_view());
+ // Adds a mapping between the GtkWidget and us.
+ SetViewForNative(host_->native_view(), host_);
+
+ if (!destroy_signal_id_) {
+ destroy_signal_id_ = g_signal_connect(G_OBJECT(host_->native_view()),
+ "destroy", G_CALLBACK(CallDestroy),
+ NULL);
+ }
+
+ // Set the parent.
+ static_cast<WidgetGtk*>(host_->GetWidget())->AddChild(host_->native_view());
+ }
- // Set the parent.
- static_cast<WidgetGtk*>(host_->GetWidget())->AddChild(host_->native_view());
+ // Always layout though.
host_->Layout();
// TODO(port): figure out focus.
@@ -95,6 +109,9 @@ void NativeViewHostGtk::AddedToWidget() {
}
void NativeViewHostGtk::RemovedFromWidget() {
+ if (!host_->native_view())
+ return;
+
WidgetGtk* parent_widget = static_cast<WidgetGtk*>(host_->GetWidget());
gtk_widget_hide(host_->native_view());
if (parent_widget) {