diff options
author | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-07 00:55:16 +0000 |
---|---|---|
committer | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-07 00:55:16 +0000 |
commit | bda9556c63579835dd14055a048f4e2094e7b3f5 (patch) | |
tree | f215d883f2ded85f48bc14d27edd4048f12c364b /views/widget/widget_gtk.cc | |
parent | c83c9e683a9376cea1ef675bfe92f7dbb98d45f5 (diff) | |
download | chromium_src-bda9556c63579835dd14055a048f4e2094e7b3f5.zip chromium_src-bda9556c63579835dd14055a048f4e2094e7b3f5.tar.gz chromium_src-bda9556c63579835dd14055a048f4e2094e7b3f5.tar.bz2 |
Addded notification when ancestor gets changed. So windows that lack focus manager, because of being
created on inactive tab, could do the necessary work when focus manager is actually attached.
This is relevant for Windows only, but some support functions (FindAllRootViews) could be useful for
other architectures as well.
BUG=22481
TEST=in the bug
Review URL: http://codereview.chromium.org/492025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget/widget_gtk.cc')
-rw-r--r-- | views/widget/widget_gtk.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index a2d699f..e10bf60 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -1302,6 +1302,42 @@ RootView* Widget::FindRootView(GtkWindow* window) { return root_view; } +static void AllRootViewsLocatorCallback(GtkWidget* widget, + gpointer root_view_p) { + std::set<RootView*>* root_views_set = + reinterpret_cast<std::set<RootView*>*>(root_view_p); + RootView *root_view = WidgetGtk::GetRootViewForWidget(widget); + if (!root_view && GTK_IS_CONTAINER(widget)) { + // gtk_container_foreach only iterates over children, not all descendants, + // so we have to recurse here to get all descendants. + gtk_container_foreach(GTK_CONTAINER(widget), AllRootViewsLocatorCallback, + root_view_p); + } else { + if (root_view) + root_views_set->insert(root_view); + } +} + +// static +void Widget::FindAllRootViews(GtkWindow* window, + std::vector<RootView*>* root_views) { + RootView* root_view = WidgetGtk::GetRootViewForWidget(GTK_WIDGET(window)); + if (root_view) + root_views->push_back(root_view); + + std::set<RootView*> root_views_set; + + // Enumerate all children and check if they have a RootView. + gtk_container_foreach(GTK_CONTAINER(window), AllRootViewsLocatorCallback, + reinterpret_cast<gpointer>(&root_views_set)); + root_views->clear(); + root_views->reserve(root_views_set.size()); + for (std::set<RootView*>::iterator it = root_views_set.begin(); + it != root_views_set.end(); + ++it) + root_views->push_back(*it); +} + // static Widget* Widget::GetWidgetFromNativeView(gfx::NativeView native_view) { gpointer raw_widget = g_object_get_data(G_OBJECT(native_view), kWidgetKey); |