diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-03 00:19:18 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-03 00:19:18 +0000 |
commit | b281162d602ce55ad45d8ff0e6604b8afece3c89 (patch) | |
tree | 4d208049b39cb7e70a97527876313f7f7b3d56ad /ui/views/widget/native_widget_win.cc | |
parent | fa4467a7d995cd64c5c728816e69873e75ec708b (diff) | |
download | chromium_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/native_widget_win.cc')
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index e435592..15e9aff 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -12,7 +12,6 @@ #include "ui/base/view_prop.h" #include "ui/base/win/hwnd_util.h" #include "ui/views/view.h" -#include "ui/views/widget/native_widget_listener.h" #include "ui/views/widget/widget.h" namespace ui { @@ -217,6 +216,22 @@ void NativeWidgetWin::Paint() { } } +void NativeWidgetWin::FocusNativeView(gfx::NativeView native_view) { + if (IsWindow(native_view)) { + if (GetFocus() != native_view) + SetFocus(native_view); + } else { + // NULL or invalid |native_view| passed, we consider this to be clearing + // focus. Keep the top level window focused so we continue to receive + // key events. + SetFocus(hwnd()); + } +} + +Widget* NativeWidgetWin::GetWidget() const { + return listener_->GetWidget(); +} + //////////////////////////////////////////////////////////////////////////////// // NativeWidetWin, MessageLoopForUI::Observer implementation @@ -267,6 +282,7 @@ void NativeWidgetWin::OnCommand(UINT notification_code, int command_id, LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) { SetNativeWindowProperty(kNativeWidgetKey, this); + listener_->OnNativeWidgetCreated(); MessageLoopForUI::current()->AddObserver(this); return 0; } @@ -347,7 +363,7 @@ LRESULT NativeWidgetWin::OnKeyUp(UINT message, WPARAM w_param, LPARAM l_param) { } void NativeWidgetWin::OnKillFocus(HWND focused_window) { - // TODO(beng): focus + listener_->OnNativeBlur(focused_window); SetMsgHandled(FALSE); } @@ -474,7 +490,7 @@ LRESULT NativeWidgetWin::OnReflectedMessage(UINT message, WPARAM w_param, } void NativeWidgetWin::OnSetFocus(HWND focused_window) { - // TODO(beng): focus + listener_->OnNativeFocus(focused_window); SetMsgHandled(FALSE); } |