summaryrefslogtreecommitdiffstats
path: root/ui/views/widget/widget.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-03 00:19:18 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-03 00:19:18 +0000
commitb281162d602ce55ad45d8ff0e6604b8afece3c89 (patch)
tree4d208049b39cb7e70a97527876313f7f7b3d56ad /ui/views/widget/widget.cc
parentfa4467a7d995cd64c5c728816e69873e75ec708b (diff)
downloadchromium_src-b281162d602ce55ad45d8ff0e6604b8afece3c89.zip
chromium_src-b281162d602ce55ad45d8ff0e6604b8afece3c89.tar.gz
chromium_src-b281162d602ce55ad45d8ff0e6604b8afece3c89.tar.bz2
More FocusManager hookup.
- One focus manager per Widget hierarchy - Create focus manager on widget initialization - Allow focus manager to be obtained from NativeView. - Adds a test to ensure focus manager is only created for the top level widget. BUG=none TEST=none Review URL: http://codereview.chromium.org/6349057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73551 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/widget/widget.cc')
-rw-r--r--ui/views/widget/widget.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index ba2daa6..1759c6b 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -6,6 +6,7 @@
#include "base/compiler_specific.h"
#include "base/message_loop.h"
+#include "ui/views/focus/focus_manager.h"
#include "ui/views/view.h"
#include "ui/views/widget/native_widget.h"
#include "ui/views/widget/root_view.h"
@@ -67,6 +68,12 @@ void Widget::InitWithViewParent(View* parent, const gfx::Rect& bounds) {
native_widget_->InitWithViewParent(parent, bounds);
}
+Widget* Widget::GetTopLevelWidget() const {
+ NativeWidget* native_widget =
+ NativeWidget::GetTopLevelNativeWidget(native_widget_->GetNativeView());
+ return native_widget->GetWidget();
+}
+
gfx::Rect Widget::GetWindowScreenBounds() const {
return native_widget_->GetWindowScreenBounds();
}
@@ -112,6 +119,10 @@ ThemeProvider* Widget::GetThemeProvider() const {
return NULL;
}
+FocusManager* Widget::GetFocusManager() const {
+ return GetTopLevelWidget()->focus_manager_.get();
+}
+
////////////////////////////////////////////////////////////////////////////////
// Widget, NativeWidgetListener implementation:
@@ -195,6 +206,8 @@ bool Widget::OnMouseWheelEvent(const MouseWheelEvent& event) {
}
void Widget::OnNativeWidgetCreated() {
+ if (GetTopLevelWidget() == this)
+ focus_manager_.reset(new FocusManager(this));
}
void Widget::OnPaint(gfx::Canvas* canvas) {
@@ -205,10 +218,24 @@ void Widget::OnSizeChanged(const gfx::Size& size) {
root_view_->SetSize(size);
}
+void Widget::OnNativeFocus(gfx::NativeView focused_view) {
+ GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent(
+ focused_view, native_widget_->GetNativeView());
+}
+
+void Widget::OnNativeBlur(gfx::NativeView focused_view) {
+ GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent(
+ native_widget_->GetNativeView(), focused_view);
+}
+
void Widget::OnWorkAreaChanged() {
}
+Widget* Widget::GetWidget() const {
+ return const_cast<Widget*>(this);
+}
+
////////////////////////////////////////////////////////////////////////////////
// Widget, private: