| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "ui/base/accelerators/accelerator.h" | 13 #include "ui/base/accelerators/accelerator.h" |
| 14 #include "ui/base/accelerators/accelerator_history.h" |
| 14 #include "ui/base/ime/input_method.h" | 15 #include "ui/base/ime/input_method.h" |
| 15 #include "ui/base/ime/text_input_client.h" | 16 #include "ui/base/ime/text_input_client.h" |
| 16 #include "ui/base/ime/text_input_focus_manager.h" | 17 #include "ui/base/ime/text_input_focus_manager.h" |
| 17 #include "ui/base/ui_base_switches_util.h" | 18 #include "ui/base/ui_base_switches_util.h" |
| 18 #include "ui/events/event.h" | 19 #include "ui/events/event.h" |
| 19 #include "ui/events/keycodes/keyboard_codes.h" | 20 #include "ui/events/keycodes/keyboard_codes.h" |
| 20 #include "ui/views/focus/focus_manager_delegate.h" | 21 #include "ui/views/focus/focus_manager_delegate.h" |
| 21 #include "ui/views/focus/focus_search.h" | 22 #include "ui/views/focus/focus_search.h" |
| 22 #include "ui/views/focus/view_storage.h" | 23 #include "ui/views/focus/view_storage.h" |
| 23 #include "ui/views/focus/widget_focus_manager.h" | 24 #include "ui/views/focus/widget_focus_manager.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 52 | 53 |
| 53 bool FocusManager::OnKeyEvent(const ui::KeyEvent& event) { | 54 bool FocusManager::OnKeyEvent(const ui::KeyEvent& event) { |
| 54 const int key_code = event.key_code(); | 55 const int key_code = event.key_code(); |
| 55 | 56 |
| 56 if (event.type() != ui::ET_KEY_PRESSED && event.type() != ui::ET_KEY_RELEASED) | 57 if (event.type() != ui::ET_KEY_PRESSED && event.type() != ui::ET_KEY_RELEASED) |
| 57 return false; | 58 return false; |
| 58 | 59 |
| 59 if (shortcut_handling_suspended()) | 60 if (shortcut_handling_suspended()) |
| 60 return true; | 61 return true; |
| 61 | 62 |
| 62 int modifiers = ui::EF_NONE; | 63 ui::Accelerator accelerator(ui::AcceleratorHistory::GetInstance()-> |
| 63 if (event.IsShiftDown()) | 64 GetCurrentAccelerator()); |
| 64 modifiers |= ui::EF_SHIFT_DOWN; | |
| 65 if (event.IsControlDown()) | |
| 66 modifiers |= ui::EF_CONTROL_DOWN; | |
| 67 if (event.IsAltDown()) | |
| 68 modifiers |= ui::EF_ALT_DOWN; | |
| 69 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) | |
| 70 if (event.IsCommandDown()) | |
| 71 modifiers |= ui::EF_COMMAND_DOWN; | |
| 72 #endif | |
| 73 ui::Accelerator accelerator(event.key_code(), modifiers); | |
| 74 accelerator.set_type(event.type()); | |
| 75 accelerator.set_is_repeat(event.IsRepeat()); | |
| 76 | 65 |
| 77 if (event.type() == ui::ET_KEY_PRESSED) { | 66 if (event.type() == ui::ET_KEY_PRESSED) { |
| 78 // If the focused view wants to process the key event as is, let it be. | 67 // If the focused view wants to process the key event as is, let it be. |
| 79 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event) && | 68 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event) && |
| 80 !accelerator_manager_->HasPriorityHandler(accelerator)) | 69 !accelerator_manager_->HasPriorityHandler(accelerator)) |
| 81 return true; | 70 return true; |
| 82 | 71 |
| 83 // Intercept Tab related messages for focus traversal. | 72 // Intercept Tab related messages for focus traversal. |
| 84 // Note that we don't do focus traversal if the root window is not part of | 73 // Note that we don't do focus traversal if the root window is not part of |
| 85 // the active window hierarchy as this would mean we have no focused view | 74 // the active window hierarchy as this would mean we have no focused view |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 } | 593 } |
| 605 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) { | 594 if (key_code == ui::VKEY_RIGHT || key_code == ui::VKEY_DOWN) { |
| 606 AdvanceFocus(false); | 595 AdvanceFocus(false); |
| 607 return true; | 596 return true; |
| 608 } | 597 } |
| 609 | 598 |
| 610 return false; | 599 return false; |
| 611 } | 600 } |
| 612 | 601 |
| 613 } // namespace views | 602 } // namespace views |
| OLD | NEW |