| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 if (event.type() == ui::ET_KEY_PRESSED) { | 68 if (event.type() == ui::ET_KEY_PRESSED) { |
| 69 // If the focused view wants to process the key event as is, let it be. | 69 // If the focused view wants to process the key event as is, let it be. |
| 70 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event) && | 70 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event) && |
| 71 !accelerator_manager_->HasPriorityHandler(accelerator)) | 71 !accelerator_manager_->HasPriorityHandler(accelerator)) |
| 72 return true; | 72 return true; |
| 73 | 73 |
| 74 // Intercept Tab related messages for focus traversal. | 74 // Intercept Tab related messages for focus traversal. |
| 75 // Note that we don't do focus traversal if the root window is not part of | 75 // Note that we don't do focus traversal if the root window is not part of |
| 76 // the active window hierarchy as this would mean we have no focused view | 76 // the active window hierarchy as this would mean we have no focused view |
| 77 // and would focus the first focusable view. | 77 // and would focus the first focusable view. |
| 78 #if defined(OS_WIN) && !defined(USE_AURA) | |
| 79 HWND top_window = widget_->GetNativeView(); | |
| 80 HWND active_window = ::GetActiveWindow(); | |
| 81 if ((active_window == top_window || ::IsChild(active_window, top_window)) && | |
| 82 IsTabTraversalKeyEvent(event)) { | |
| 83 AdvanceFocus(event.IsShiftDown()); | |
| 84 return false; | |
| 85 } | |
| 86 #else | |
| 87 if (IsTabTraversalKeyEvent(event)) { | 78 if (IsTabTraversalKeyEvent(event)) { |
| 88 AdvanceFocus(event.IsShiftDown()); | 79 AdvanceFocus(event.IsShiftDown()); |
| 89 return false; | 80 return false; |
| 90 } | 81 } |
| 91 #endif | |
| 92 | 82 |
| 93 if (arrow_key_traversal_enabled_ && ProcessArrowKeyTraversal(event)) | 83 if (arrow_key_traversal_enabled_ && ProcessArrowKeyTraversal(event)) |
| 94 return false; | 84 return false; |
| 95 | 85 |
| 96 // Intercept arrow key messages to switch between grouped views. | 86 // Intercept arrow key messages to switch between grouped views. |
| 97 if (focused_view_ && focused_view_->GetGroup() != -1 && | 87 if (focused_view_ && focused_view_->GetGroup() != -1 && |
| 98 (key_code == ui::VKEY_UP || key_code == ui::VKEY_DOWN || | 88 (key_code == ui::VKEY_UP || key_code == ui::VKEY_DOWN || |
| 99 key_code == ui::VKEY_LEFT || key_code == ui::VKEY_RIGHT)) { | 89 key_code == ui::VKEY_LEFT || key_code == ui::VKEY_RIGHT)) { |
| 100 bool next = (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN); | 90 bool next = (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN); |
| 101 View::Views views; | 91 View::Views views; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 } | 531 } |
| 542 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) { | 532 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) { |
| 543 AdvanceFocus(false); | 533 AdvanceFocus(false); |
| 544 return true; | 534 return true; |
| 545 } | 535 } |
| 546 | 536 |
| 547 return false; | 537 return false; |
| 548 } | 538 } |
| 549 | 539 |
| 550 } // namespace views | 540 } // namespace views |
| OLD | NEW |