OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 ViewStorage::GetSharedInstance()->CreateStorageID(); | 74 ViewStorage::GetSharedInstance()->CreateStorageID(); |
75 } | 75 } |
76 | 76 |
77 FocusManager::~FocusManager() { | 77 FocusManager::~FocusManager() { |
78 // If there are still registered FocusChange listeners, chances are they were | 78 // If there are still registered FocusChange listeners, chances are they were |
79 // leaked so warn about them. | 79 // leaked so warn about them. |
80 DCHECK(focus_change_listeners_.empty()); | 80 DCHECK(focus_change_listeners_.empty()); |
81 } | 81 } |
82 | 82 |
83 bool FocusManager::OnKeyEvent(const KeyEvent& event) { | 83 bool FocusManager::OnKeyEvent(const KeyEvent& event) { |
| 84 #if defined(OS_WIN) |
84 // If the focused view wants to process the key event as is, let it be. | 85 // If the focused view wants to process the key event as is, let it be. |
| 86 // On Linux we always dispatch key events to the focused view first, so |
| 87 // we should not do this check here. See also WidgetGtk::OnKeyEvent(). |
85 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event)) | 88 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event)) |
86 return true; | 89 return true; |
| 90 #endif |
87 | 91 |
88 // Intercept Tab related messages for focus traversal. | 92 // Intercept Tab related messages for focus traversal. |
89 // Note that we don't do focus traversal if the root window is not part of the | 93 // Note that we don't do focus traversal if the root window is not part of the |
90 // active window hierarchy as this would mean we have no focused view and | 94 // active window hierarchy as this would mean we have no focused view and |
91 // would focus the first focusable view. | 95 // would focus the first focusable view. |
92 #if defined(OS_WIN) | 96 #if defined(OS_WIN) |
93 HWND top_window = widget_->GetNativeView(); | 97 HWND top_window = widget_->GetNativeView(); |
94 HWND active_window = ::GetActiveWindow(); | 98 HWND active_window = ::GetActiveWindow(); |
95 if ((active_window == top_window || ::IsChild(active_window, top_window)) && | 99 if ((active_window == top_window || ::IsChild(active_window, top_window)) && |
96 IsTabTraversalKeyEvent(event)) { | 100 IsTabTraversalKeyEvent(event)) { |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(), | 515 std::find(focus_change_listeners_.begin(), focus_change_listeners_.end(), |
512 listener); | 516 listener); |
513 if (place == focus_change_listeners_.end()) { | 517 if (place == focus_change_listeners_.end()) { |
514 NOTREACHED() << "Removing a listener that isn't registered."; | 518 NOTREACHED() << "Removing a listener that isn't registered."; |
515 return; | 519 return; |
516 } | 520 } |
517 focus_change_listeners_.erase(place); | 521 focus_change_listeners_.erase(place); |
518 } | 522 } |
519 | 523 |
520 } // namespace views | 524 } // namespace views |
OLD | NEW |