OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "views/focus/focus_manager.h" | 5 #include "views/focus/focus_manager.h" |
6 | 6 |
7 #include "views/view.h" | 7 #include "views/view.h" |
8 #include "views/widget/widget_win.h" | 8 #include "views/widget/widget_win.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
11 | 11 |
12 void FocusManager::ClearNativeFocus() { | 12 void FocusManager::ClearNativeFocus() { |
13 // Keep the top root window focused so we get keyboard events. | 13 // Keep the top root window focused so we get keyboard events. |
14 ::SetFocus(widget_->GetNativeView()); | 14 ::SetFocus(widget_->GetNativeView()); |
15 | 15 |
16 // We need to let assistive technologies know which child view got focus so | 16 // We need to let assistive technologies know which child view got focus so |
17 // they can obtain the proper accessibility object for that child view. | 17 // they can obtain the proper accessibility object for that child view. |
18 if (focused_view_) { | 18 if (focused_view_) { |
19 ::NotifyWinEvent(EVENT_OBJECT_FOCUS, widget_->GetNativeView(), OBJID_CLIENT, | 19 focused_view_->NotifyAccessibilityEvent(AccessibilityTypes::EVENT_FOCUS); |
20 static_cast<LONG>(focused_view_->GetID())); | |
21 } | 20 } |
22 } | 21 } |
23 | 22 |
24 void FocusManager::FocusNativeView(gfx::NativeView native_view) { | 23 void FocusManager::FocusNativeView(gfx::NativeView native_view) { |
25 // Only reset focus if hwnd is not already focused. | 24 // Only reset focus if hwnd is not already focused. |
26 if (native_view && ::GetFocus() != native_view) | 25 if (native_view && ::GetFocus() != native_view) |
27 ::SetFocus(native_view); | 26 ::SetFocus(native_view); |
28 } | 27 } |
29 | 28 |
30 // static | 29 // static |
31 FocusManager* FocusManager::GetFocusManagerForNativeView( | 30 FocusManager* FocusManager::GetFocusManagerForNativeView( |
32 gfx::NativeView native_view) { | 31 gfx::NativeView native_view) { |
33 WidgetWin* widget = WidgetWin::GetRootWidget(native_view); | 32 WidgetWin* widget = WidgetWin::GetRootWidget(native_view); |
34 return widget ? widget->GetFocusManager() : NULL; | 33 return widget ? widget->GetFocusManager() : NULL; |
35 } | 34 } |
36 | 35 |
37 // static | 36 // static |
38 FocusManager* FocusManager::GetFocusManagerForNativeWindow( | 37 FocusManager* FocusManager::GetFocusManagerForNativeWindow( |
39 gfx::NativeWindow native_window) { | 38 gfx::NativeWindow native_window) { |
40 return GetFocusManagerForNativeView(native_window); | 39 return GetFocusManagerForNativeView(native_window); |
41 } | 40 } |
42 | 41 |
43 } // namespace views | 42 } // namespace views |
OLD | NEW |