summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/root_view.cc5
-rw-r--r--views/widget/root_view.h4
-rw-r--r--views/widget/widget.h6
-rw-r--r--views/widget/widget_gtk.cc36
-rw-r--r--views/widget/widget_win.cc32
5 files changed, 83 insertions, 0 deletions
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 5d2b6e4..862d000 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -764,6 +764,11 @@ void RootView::SetFocusTraversableParentView(View* view) {
focus_traversable_parent_view_ = view;
}
+void RootView::NotifyNativeViewHierarchyChanged(bool attached,
+ gfx::NativeView native_view) {
+ PropagateNativeViewHierarchyChanged(attached, native_view, this);
+}
+
// static
View* RootView::FindSelectedViewForGroup(View* view) {
if (view->IsGroupFocusTraversable() ||
diff --git a/views/widget/root_view.h b/views/widget/root_view.h
index dbb480f..d175c63 100644
--- a/views/widget/root_view.h
+++ b/views/widget/root_view.h
@@ -152,6 +152,10 @@ class RootView : public View,
// Used to set the View parent after the view has been created.
virtual void SetFocusTraversableParentView(View* view);
+ // Called when parent of the host changed.
+ void NotifyNativeViewHierarchyChanged(bool attached,
+ gfx::NativeView native_view);
+
// Returns the name of this class: views/RootView
virtual std::string GetClassName() const;
diff --git a/views/widget/widget.h b/views/widget/widget.h
index 8de4b6c..fa8111e 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -5,6 +5,7 @@
#ifndef VIEWS_WIDGET_WIDGET_H_
#define VIEWS_WIDGET_WIDGET_H_
+#include <vector>
#include "app/gfx/native_widget_types.h"
class ThemeProvider;
@@ -71,6 +72,11 @@ class Widget {
// one is found. If a root view isn't found, null is returned.
static RootView* FindRootView(gfx::NativeWindow native_window);
+ // Returns list of all root views for the native window and its
+ // children.
+ static void FindAllRootViews(gfx::NativeWindow native_window,
+ std::vector<RootView*>* root_views);
+
// Retrieve the Widget corresponding to the specified native_view, or NULL
// if there is no such Widget.
static Widget* GetWidgetFromNativeView(gfx::NativeView native_view);
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);
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 76f58e4..6f75506 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -1205,6 +1205,38 @@ RootView* Widget::FindRootView(HWND hwnd) {
return root_view;
}
+// Enumerate child windows as they could have RootView distinct from
+// the HWND's root view.
+BOOL CALLBACK EnumAllRootViewsChildProc(HWND hwnd, LPARAM l_param) {
+ RootView* root_view =
+ reinterpret_cast<RootView*>(GetProp(hwnd, kRootViewWindowProperty));
+ if (root_view) {
+ std::set<RootView*>* root_views_set =
+ reinterpret_cast<std::set<RootView*>*>(l_param);
+ root_views_set->insert(root_view);
+ }
+ return TRUE; // Keep enumerating.
+}
+
+void Widget::FindAllRootViews(HWND window,
+ std::vector<RootView*>* root_views) {
+ RootView* root_view =
+ reinterpret_cast<RootView*>(GetProp(window, kRootViewWindowProperty));
+ std::set<RootView*> root_views_set;
+ if (root_view)
+ root_views_set.insert(root_view);
+ // Enumerate all children and check if they have a RootView.
+ EnumChildWindows(window, EnumAllRootViewsChildProc,
+ reinterpret_cast<LPARAM>(&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);
+}
+
+
////////////////////////////////////////////////////////////////////////////////
// Widget, public: