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 #ifndef ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 5 #ifndef ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
6 #define ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 6 #define ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 // or if the current accelerator is repeated or not. | 32 // or if the current accelerator is repeated or not. |
33 class ASH_EXPORT AcceleratorControllerContext { | 33 class ASH_EXPORT AcceleratorControllerContext { |
34 public: | 34 public: |
35 AcceleratorControllerContext(); | 35 AcceleratorControllerContext(); |
36 ~AcceleratorControllerContext() {} | 36 ~AcceleratorControllerContext() {} |
37 | 37 |
38 // Updates context - determines if the accelerator is repeated, as well as | 38 // Updates context - determines if the accelerator is repeated, as well as |
39 // event type of the previous accelerator. | 39 // event type of the previous accelerator. |
40 void UpdateContext(const ui::Accelerator& accelerator); | 40 void UpdateContext(const ui::Accelerator& accelerator); |
41 | 41 |
42 ui::EventType previous_event_type() const { return previous_event_type_; } | 42 const ui::Accelerator& previous_accelerator() const { |
43 bool repeated() const { return repeated_; } | 43 return previous_accelerator_; |
| 44 } |
| 45 bool repeated() const { |
| 46 return current_accelerator_ == previous_accelerator_ && |
| 47 current_accelerator_.type() != ui::ET_UNKNOWN; |
| 48 } |
44 | 49 |
45 private: | 50 private: |
46 ui::Accelerator current_accelerator_; | 51 ui::Accelerator current_accelerator_; |
47 | 52 // Used for NEXT_IME and DISABLE_CAPS_LOCK accelerator actions. |
48 // If the current accelerator was repeated. | 53 ui::Accelerator previous_accelerator_; |
49 bool repeated_; | |
50 | |
51 // Event type of the previous accelerator. Used for NEXT_IME and | |
52 // DISABLE_CAPS_LOCK accelerator actions. | |
53 ui::EventType previous_event_type_; | |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerContext); | 55 DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerContext); |
56 }; | 56 }; |
57 | 57 |
58 // AcceleratorController provides functions for registering or unregistering | 58 // AcceleratorController provides functions for registering or unregistering |
59 // global keyboard accelerators, which are handled earlier than any windows. It | 59 // global keyboard accelerators, which are handled earlier than any windows. It |
60 // also implements several handlers as an accelerator target. | 60 // also implements several handlers as an accelerator target. |
61 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { | 61 class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { |
62 public: | 62 public: |
63 AcceleratorController(); | 63 AcceleratorController(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 std::set<int> reserved_actions_; | 160 std::set<int> reserved_actions_; |
161 // Actions which will not be repeated while holding the accelerator key. | 161 // Actions which will not be repeated while holding the accelerator key. |
162 std::set<int> nonrepeatable_actions_; | 162 std::set<int> nonrepeatable_actions_; |
163 | 163 |
164 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); | 164 DISALLOW_COPY_AND_ASSIGN(AcceleratorController); |
165 }; | 165 }; |
166 | 166 |
167 } // namespace ash | 167 } // namespace ash |
168 | 168 |
169 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ | 169 #endif // ASH_ACCELERATORS_ACCELERATOR_CONTROLLER_H_ |
OLD | NEW |