OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_HOTKEY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_HOTKEY_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_HOTKEY_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_HOTKEY_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 | 13 |
14 typedef union _XEvent XEvent; | 14 typedef union _XEvent XEvent; |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 namespace input_method { | 17 namespace input_method { |
18 | 18 |
19 // A class which holds all hotkeys for input method switching. | 19 // A class which holds all hotkeys for input method switching. |
20 class HotkeyManager { | 20 class HotkeyManager { |
21 public: | 21 public: |
22 class Observer { | 22 class Observer { |
23 public: | 23 public: |
24 virtual ~Observer() {} | 24 virtual ~Observer() {} |
25 // Called when one of the input method hotkeys is pressed. | 25 // Called when one of the input method hotkeys is pressed. |
26 virtual void HotkeyPressed(HotkeyManager* manager, int event_id) = 0; | 26 virtual void HotkeyPressed(HotkeyManager* manager, int event_id) = 0; |
27 }; | 27 }; |
28 | 28 |
29 HotkeyManager(); | 29 HotkeyManager(); |
30 ~HotkeyManager() {} | 30 ~HotkeyManager(); |
31 | 31 |
32 void AddObserver(Observer* observer); | 32 void AddObserver(Observer* observer); |
33 void RemoveObserver(Observer* observer); | 33 void RemoveObserver(Observer* observer); |
34 | 34 |
35 // Registers a hotkey to the manager. For example, to handle Control+space, | 35 // Registers a hotkey to the manager. For example, to handle Control+space, |
36 // you can call AddHotkey(kNextInputMethod, XK_space, ControlMask, true). | 36 // you can call AddHotkey(kNextInputMethod, XK_space, ControlMask, true). |
37 // Returns false if |event_id| is negative, or the same hotkey is already | 37 // Returns false if |event_id| is negative, or the same hotkey is already |
38 // registered. | 38 // registered. |
39 bool AddHotkey(int event_id, | 39 bool AddHotkey(int event_id, |
40 uint32 keysym, // one of XK_* in X11/keysymdef.h. | 40 uint32 keysym, // one of XK_* in X11/keysymdef.h. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 ObserverList<Observer> observers_; | 81 ObserverList<Observer> observers_; |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(HotkeyManager); | 83 DISALLOW_COPY_AND_ASSIGN(HotkeyManager); |
84 }; | 84 }; |
85 | 85 |
86 } // namespace input_method | 86 } // namespace input_method |
87 } // namespace chromeos | 87 } // namespace chromeos |
88 | 88 |
89 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_HOTKEY_MANAGER_H_ | 89 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_HOTKEY_MANAGER_H_ |
OLD | NEW |