| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMEOS_IME_XKEYBOARD_H_ | |
| 6 #define CHROMEOS_IME_XKEYBOARD_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "chromeos/chromeos_export.h" | |
| 13 | |
| 14 namespace chromeos { | |
| 15 namespace input_method { | |
| 16 | |
| 17 struct AutoRepeatRate { | |
| 18 AutoRepeatRate() : initial_delay_in_ms(0), repeat_interval_in_ms(0) {} | |
| 19 unsigned int initial_delay_in_ms; | |
| 20 unsigned int repeat_interval_in_ms; | |
| 21 }; | |
| 22 | |
| 23 enum ModifierKey { | |
| 24 kSearchKey = 0, // Customizable. | |
| 25 kControlKey, // Customizable. | |
| 26 kAltKey, // Customizable. | |
| 27 kVoidKey, | |
| 28 kCapsLockKey, | |
| 29 kEscapeKey, | |
| 30 // IMPORTANT: You should update kCustomizableKeys[] in .cc file, if you | |
| 31 // add a customizable key. | |
| 32 kNumModifierKeys, | |
| 33 }; | |
| 34 | |
| 35 class InputMethodUtil; | |
| 36 | |
| 37 class CHROMEOS_EXPORT XKeyboard { | |
| 38 public: | |
| 39 virtual ~XKeyboard() {} | |
| 40 | |
| 41 // Sets the current keyboard layout to |layout_name|. This function does not | |
| 42 // change the current mapping of the modifier keys. Returns true on success. | |
| 43 virtual bool SetCurrentKeyboardLayoutByName( | |
| 44 const std::string& layout_name) = 0; | |
| 45 | |
| 46 // Sets the current keyboard layout again. We have to call the function every | |
| 47 // time when "XI_HierarchyChanged" XInput2 event is sent to Chrome. See | |
| 48 // xinput_hierarchy_changed_event_listener.h for details. | |
| 49 virtual bool ReapplyCurrentKeyboardLayout() = 0; | |
| 50 | |
| 51 // Updates keyboard LEDs on all keyboards. | |
| 52 // XKB asymmetrically propagates keyboard modifier indicator state changes to | |
| 53 // slave keyboards. If the state change is initiated from a client to the | |
| 54 // "core/master keyboard", XKB changes global state and pushes an indication | |
| 55 // change down to all keyboards. If the state change is initiated by one slave | |
| 56 // (physical) keyboard, it changes global state but only pushes an indicator | |
| 57 // state change down to that one keyboard. | |
| 58 // This function changes LEDs on all keyboards by explicitly updating the | |
| 59 // core/master keyboard. | |
| 60 virtual void ReapplyCurrentModifierLockStatus() = 0; | |
| 61 | |
| 62 // Disables the num lock. | |
| 63 virtual void DisableNumLock() = 0; | |
| 64 | |
| 65 // Sets the caps lock status to |enable_caps_lock|. Do not call the function | |
| 66 // from non-UI threads. | |
| 67 virtual void SetCapsLockEnabled(bool enable_caps_lock) = 0; | |
| 68 | |
| 69 // Returns true if caps lock is enabled. Do not call the function from non-UI | |
| 70 // threads. | |
| 71 virtual bool CapsLockIsEnabled() = 0; | |
| 72 | |
| 73 // Returns true if the current layout supports ISO Level 5 shift. | |
| 74 virtual bool IsISOLevel5ShiftAvailable() const = 0; | |
| 75 | |
| 76 // Returns true if the current layout supports alt gr. | |
| 77 virtual bool IsAltGrAvailable() const = 0; | |
| 78 | |
| 79 // Turns on and off the auto-repeat of the keyboard. Returns true on success. | |
| 80 // Do not call the function from non-UI threads. | |
| 81 virtual bool SetAutoRepeatEnabled(bool enabled) = 0; | |
| 82 | |
| 83 // Sets the auto-repeat rate of the keyboard, initial delay in ms, and repeat | |
| 84 // interval in ms. Returns true on success. Do not call the function from | |
| 85 // non-UI threads. | |
| 86 virtual bool SetAutoRepeatRate(const AutoRepeatRate& rate) = 0; | |
| 87 | |
| 88 // Returns true if auto repeat is enabled. This function is protected: for | |
| 89 // testability. | |
| 90 static CHROMEOS_EXPORT bool GetAutoRepeatEnabledForTesting(); | |
| 91 | |
| 92 // On success, set current auto repeat rate on |out_rate| and returns true. | |
| 93 // Returns false otherwise. This function is protected: for testability. | |
| 94 static CHROMEOS_EXPORT bool GetAutoRepeatRateForTesting( | |
| 95 AutoRepeatRate* out_rate); | |
| 96 | |
| 97 // Returns false if |layout_name| contains a bad character. | |
| 98 static CHROMEOS_EXPORT bool CheckLayoutNameForTesting( | |
| 99 const std::string& layout_name); | |
| 100 | |
| 101 // Note: At this moment, classes other than InputMethodManager should not | |
| 102 // instantiate the XKeyboard class. | |
| 103 static XKeyboard* Create(); | |
| 104 }; | |
| 105 | |
| 106 } // namespace input_method | |
| 107 } // namespace chromeos | |
| 108 | |
| 109 #endif // CHROMEOS_IME_XKEYBOARD_H_ | |
| OLD | NEW |