Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: views/widget/widget_gtk.cc

Issue 338067: Gets AutomationProxyVisibleTest.WindowGetViewBounds to pass on... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/widget/widget_gtk.h ('k') | views/widget/widget_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/widget/widget_gtk.cc
===================================================================
--- views/widget/widget_gtk.cc (revision 30355)
+++ views/widget/widget_gtk.cc (working copy)
@@ -836,6 +836,12 @@
}
// static
+RootView* WidgetGtk::GetRootViewForWidget(GtkWidget* widget) {
+ gpointer user_data = g_object_get_data(G_OBJECT(widget), "root-view");
+ return static_cast<RootView*>(user_data);
+}
+
+// static
int WidgetGtk::GetFlagsForEventButton(const GdkEventButton& event) {
int flags = Event::GetFlagsFromGdkState(event.state);
switch (event.button) {
@@ -948,12 +954,6 @@
}
// static
-RootView* WidgetGtk::GetRootViewForWidget(GtkWidget* widget) {
- gpointer user_data = g_object_get_data(G_OBJECT(widget), "root-view");
- return static_cast<RootView*>(user_data);
-}
-
-// static
void WidgetGtk::SetRootViewForWidget(GtkWidget* widget, RootView* root_view) {
g_object_set_data(G_OBJECT(widget), "root-view", root_view);
}
@@ -1236,4 +1236,32 @@
return popup;
}
+// Callback from gtk_container_foreach. Locates the first root view of widget
+// or one of it's descendants.
+static void RootViewLocatorCallback(GtkWidget* widget,
+ gpointer root_view_p) {
+ RootView** root_view = static_cast<RootView**>(root_view_p);
+ if (!*root_view) {
+ *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), RootViewLocatorCallback,
+ root_view_p);
+ }
+ }
+}
+
+// static
+RootView* Widget::FindRootView(GtkWindow* window) {
+ RootView* root_view = WidgetGtk::GetRootViewForWidget(GTK_WIDGET(window));
+ if (root_view)
+ return root_view;
+
+ // Enumerate all children and check if they have a RootView.
+ gtk_container_foreach(GTK_CONTAINER(window), RootViewLocatorCallback,
+ static_cast<gpointer>(&root_view));
+ return root_view;
+}
+
} // namespace views
« no previous file with comments | « views/widget/widget_gtk.h ('k') | views/widget/widget_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698