From a109d02492863aeb537dea09bfb445eb6f5d94c5 Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Fri, 19 Jun 2009 22:57:54 +0000 Subject: Removed the last Windows specific part out of the focus manager. HWNDs are not subclassed anymore.The FocusManager is now created and owned by top-level WidgetWins.BUG=NoneTEST=Run the unit tests, UI tests, interactive UI tests. Fully test the focus behavior in the browser: activate/deactivate the browser windows, make sure focus is remembered. Switch tabs, make sure focus is remembered for each tab. make sure accelerators work as expected. Test focus traversal in a web page, in the option dialog. Review URL: http://codereview.chromium.org/125148 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18872 0039d316-1c4b-4281-b951-d872f2087c98 --- views/focus/focus_manager_win.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 views/focus/focus_manager_win.cc (limited to 'views/focus/focus_manager_win.cc') diff --git a/views/focus/focus_manager_win.cc b/views/focus/focus_manager_win.cc new file mode 100644 index 0000000..a3d01f9 --- /dev/null +++ b/views/focus/focus_manager_win.cc @@ -0,0 +1,33 @@ +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "views/focus/focus_manager.h" + +#include "views/view.h" +#include "views/widget/widget_win.h" + +namespace views { + +void FocusManager::ClearNativeFocus() { + // Keep the top root window focused so we get keyboard events. + ::SetFocus(widget_->GetNativeView()); +} + +void FocusManager::FocusNativeView(gfx::NativeView native_view) { + // Only reset focus if hwnd is not already focused. + if (native_view && ::GetFocus() != native_view) + ::SetFocus(native_view); +} + +// static +FocusManager* FocusManager::GetFocusManagerForNativeView( + gfx::NativeView native_view) { + HWND root = ::GetAncestor(native_view, GA_ROOT); + if (!root) + return NULL; + WidgetWin* widget = WidgetWin::GetWidget(root); + return widget ? widget->GetFocusManager() : NULL; +} + +} // namespace views -- cgit v1.1