| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "views/focus/focus_manager.h" |
| 6 |
| 7 #include "views/view.h" |
| 8 #include "views/widget/widget_win.h" |
| 9 |
| 10 namespace views { |
| 11 |
| 12 void FocusManager::ClearNativeFocus() { |
| 13 // Keep the top root window focused so we get keyboard events. |
| 14 ::SetFocus(widget_->GetNativeView()); |
| 15 } |
| 16 |
| 17 void FocusManager::FocusNativeView(gfx::NativeView native_view) { |
| 18 // Only reset focus if hwnd is not already focused. |
| 19 if (native_view && ::GetFocus() != native_view) |
| 20 ::SetFocus(native_view); |
| 21 } |
| 22 |
| 23 // static |
| 24 FocusManager* FocusManager::GetFocusManagerForNativeView( |
| 25 gfx::NativeView native_view) { |
| 26 HWND root = ::GetAncestor(native_view, GA_ROOT); |
| 27 if (!root) |
| 28 return NULL; |
| 29 WidgetWin* widget = WidgetWin::GetWidget(root); |
| 30 return widget ? widget->GetFocusManager() : NULL; |
| 31 } |
| 32 |
| 33 } // namespace views |
| OLD | NEW |