| 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 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 if ((key_code == ui::VKEY_MENU) && | 59 if ((key_code == ui::VKEY_MENU) && |
| 60 (event.flags() & ~ui::EF_ALT_DOWN) == 0) { | 60 (event.flags() & ~ui::EF_ALT_DOWN) == 0) { |
| 61 should_handle_menu_key_release_ = true; | 61 should_handle_menu_key_release_ = true; |
| 62 return false; | 62 return false; |
| 63 } | 63 } |
| 64 // Pass through to the rest of OnKeyEvent. | 64 // Pass through to the rest of OnKeyEvent. |
| 65 } else if (key_code == ui::VKEY_MENU && should_handle_menu_key_release_ && | 65 } else if (key_code == ui::VKEY_MENU && should_handle_menu_key_release_ && |
| 66 (event.flags() & ~ui::EF_ALT_DOWN) == 0) { | 66 (event.flags() & ~ui::EF_ALT_DOWN) == 0) { |
| 67 // Trigger VKEY_MENU when only this key is pressed and released, and both | 67 // Trigger VKEY_MENU when only this key is pressed and released, and both |
| 68 // press and release events are not handled by others. | 68 // press and release events are not handled by others. |
| 69 ui::Accelerator accelerator(ui::VKEY_MENU, ui::EF_NONE); | 69 ui::Accelerator accelerator(ui::VKEY_MENU, ui::EF_NONE, ui::ET_KEY_PRESSED); |
| 70 return ProcessAccelerator(accelerator); | 70 return ProcessAccelerator(accelerator); |
| 71 } else if (event.type() != ui::ET_KEY_RELEASED) { | 71 } else if (event.type() != ui::ET_KEY_RELEASED) { |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 #else | 74 #else |
| 75 if (event.type() != ui::ET_KEY_PRESSED && event.type() != ui::ET_KEY_RELEASED) | 75 if (event.type() != ui::ET_KEY_PRESSED && event.type() != ui::ET_KEY_RELEASED) |
| 76 return false; | 76 return false; |
| 77 #endif | 77 #endif |
| 78 | 78 |
| 79 int modifiers = ui::EF_NONE; | 79 int modifiers = ui::EF_NONE; |
| 80 if (event.IsShiftDown()) | 80 if (event.IsShiftDown()) |
| 81 modifiers |= ui::EF_SHIFT_DOWN; | 81 modifiers |= ui::EF_SHIFT_DOWN; |
| 82 if (event.IsControlDown()) | 82 if (event.IsControlDown()) |
| 83 modifiers |= ui::EF_CONTROL_DOWN; | 83 modifiers |= ui::EF_CONTROL_DOWN; |
| 84 if (event.IsAltDown()) | 84 if (event.IsAltDown()) |
| 85 modifiers |= ui::EF_ALT_DOWN; | 85 modifiers |= ui::EF_ALT_DOWN; |
| 86 ui::Accelerator accelerator(event.key_code(), modifiers); | 86 ui::Accelerator accelerator(event.key_code(), modifiers, event.type()); |
| 87 accelerator.set_type(event.type()); | |
| 88 | 87 |
| 89 if (event.type() == ui::ET_KEY_PRESSED) { | 88 if (event.type() == ui::ET_KEY_PRESSED) { |
| 90 #if defined(OS_WIN) | 89 #if defined(OS_WIN) |
| 91 // If the focused view wants to process the key event as is, let it be. | 90 // If the focused view wants to process the key event as is, let it be. |
| 92 // This is not used for linux/aura. | 91 // This is not used for linux/aura. |
| 93 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event) && | 92 if (focused_view_ && focused_view_->SkipDefaultKeyEventProcessing(event) && |
| 94 !accelerator_manager_->HasPriorityHandler(accelerator)) | 93 !accelerator_manager_->HasPriorityHandler(accelerator)) |
| 95 return true; | 94 return true; |
| 96 #endif | 95 #endif |
| 97 | 96 |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 478 |
| 480 void FocusManager::AddFocusChangeListener(FocusChangeListener* listener) { | 479 void FocusManager::AddFocusChangeListener(FocusChangeListener* listener) { |
| 481 focus_change_listeners_.AddObserver(listener); | 480 focus_change_listeners_.AddObserver(listener); |
| 482 } | 481 } |
| 483 | 482 |
| 484 void FocusManager::RemoveFocusChangeListener(FocusChangeListener* listener) { | 483 void FocusManager::RemoveFocusChangeListener(FocusChangeListener* listener) { |
| 485 focus_change_listeners_.RemoveObserver(listener); | 484 focus_change_listeners_.RemoveObserver(listener); |
| 486 } | 485 } |
| 487 | 486 |
| 488 } // namespace views | 487 } // namespace views |
| OLD | NEW |