summaryrefslogtreecommitdiffstats
path: root/views/focus/focus_manager_win.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-20 04:22:44 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-20 04:22:44 +0000
commit3c3ba740c63a178807cc0c1a563080e0adbfe143 (patch)
tree78bcd84e7870d8009165df0e7a9fca87f4e91903 /views/focus/focus_manager_win.cc
parent76724d00d3498f952d945d775a3f33f751624121 (diff)
downloadchromium_src-3c3ba740c63a178807cc0c1a563080e0adbfe143.zip
chromium_src-3c3ba740c63a178807cc0c1a563080e0adbfe143.tar.gz
chromium_src-3c3ba740c63a178807cc0c1a563080e0adbfe143.tar.bz2
Relanding focus manager refactoring with build fix, see:http://codereview.chromium.org/125148BUG=NoneTEST=NoneTBR=ben
Review URL: http://codereview.chromium.org/141013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18889 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus/focus_manager_win.cc')
-rw-r--r--views/focus/focus_manager_win.cc33
1 files changed, 33 insertions, 0 deletions
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