Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Side by Side Diff: chrome/browser/chromeos/input_method/xkeyboard.h

Issue 8356040: Reapply Caps Lock and Num Lock to core keyboard whenever new X input device is added (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move chrome_browser_main_chromeos.cc to an another CL Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_XKEYBOARD_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_
7 #pragma once 7 #pragma once
8 8
9 #include <queue> 9 #include <queue>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 namespace input_method { 17 namespace input_method {
18 18
19 struct AutoRepeatRate { 19 struct AutoRepeatRate {
20 AutoRepeatRate() : initial_delay_in_ms(0), repeat_interval_in_ms(0) {} 20 AutoRepeatRate() : initial_delay_in_ms(0), repeat_interval_in_ms(0) {}
21 unsigned int initial_delay_in_ms; 21 unsigned int initial_delay_in_ms;
22 unsigned int repeat_interval_in_ms; 22 unsigned int repeat_interval_in_ms;
23 }; 23 };
24 24
25 enum ModifierLockStatus {
26 kDisableLock = 0,
27 kEnableLock,
28 kDontChange,
29 };
30
25 enum ModifierKey { 31 enum ModifierKey {
26 kSearchKey = 0, // Customizable. 32 kSearchKey = 0, // Customizable.
27 kLeftControlKey, // Customizable. 33 kLeftControlKey, // Customizable.
28 kLeftAltKey, // Customizable. 34 kLeftAltKey, // Customizable.
29 kVoidKey, 35 kVoidKey,
30 kCapsLockKey, 36 kCapsLockKey,
31 // IMPORTANT: You should update kCustomizableKeys[] in .cc file, if you 37 // IMPORTANT: You should update kCustomizableKeys[] in .cc file, if you
32 // add a customizable key. 38 // add a customizable key.
33 kNumModifierKeys, 39 kNumModifierKeys,
34 }; 40 };
(...skipping 26 matching lines...) Expand all
61 // Remaps modifier keys. This function does not change the current keyboard 67 // Remaps modifier keys. This function does not change the current keyboard
62 // layout. Returns true on success. For now, you can't remap Left Control and 68 // layout. Returns true on success. For now, you can't remap Left Control and
63 // Left Alt keys to caps lock. 69 // Left Alt keys to caps lock.
64 bool RemapModifierKeys(const ModifierMap& modifier_map); 70 bool RemapModifierKeys(const ModifierMap& modifier_map);
65 71
66 // Sets the current keyboard layout again. We have to call the function every 72 // Sets the current keyboard layout again. We have to call the function every
67 // time when "XI_HierarchyChanged" XInput2 event is sent to Chrome. See 73 // time when "XI_HierarchyChanged" XInput2 event is sent to Chrome. See
68 // xinput_hierarchy_changed_event_listener.h for details. 74 // xinput_hierarchy_changed_event_listener.h for details.
69 bool ReapplyCurrentKeyboardLayout(); 75 bool ReapplyCurrentKeyboardLayout();
70 76
77 // Updates keyboard LEDs on all keyboards.
78 // XKB asymmetrically propagates keyboard modifier indicator state changes to
79 // slave keyboards. If the state change is initiated from a client to the
80 // "core/master keyboard", XKB changes global state and pushes an indication
81 // change down to all keyboards. If the state change is initiated by one slave
82 // (physical) keyboard, it changes global state but only pushes an indicator
83 // state change down to that one keyboard.
84 // This function changes LEDs on all keyboards by explicitly updating the
85 // core/master keyboard.
86 void ReapplyCurrentModifierLockStatus();
87
88 // Sets the Caps Lock and Num Lock status. Do not call the function from
89 // non-UI threads.
90 void SetLockedModifiers(ModifierLockStatus new_caps_lock_status,
91 ModifierLockStatus new_num_lock_status);
92
93 // Sets the num lock status to |enable_num_lock|. Do not call the function
94 // from non-UI threads.
95 void SetNumLockEnabled(bool enable_num_lock);
96
97 // Sets the caps lock status to |enable_caps_lock|. Do not call the function
98 // from non-UI threads.
99 void SetCapsLockEnabled(bool enable_caps_lock);
100
101 // Set true on |out_caps_lock_enabled| if Caps Lock is enabled. Set true on
102 // |out_num_lock_enabled| if Num Lock (or to be precise, the modifier
103 // specified by |num_lock_mask|) is enabled. Both 'out' parameters can be
104 // NULL. When |out_num_lock_enabled| is NULL, |num_lock_mask| is ignored (you
105 // can pass 0 in this case). Do not call the function from non-UI threads.
106 static void GetLockedModifiers(unsigned int num_lock_mask,
107 bool* out_caps_lock_enabled,
108 bool* out_num_lock_enabled);
109
110 // Returns true if num lock is enabled. Do not call the function from non-UI
111 // threads.
112 static bool NumLockIsEnabled(unsigned int num_lock_mask);
113
114 // Returns true if caps lock is enabled. Do not call the function from non-UI
115 // threads.
116 static bool CapsLockIsEnabled();
117
71 // Turns on and off the auto-repeat of the keyboard. Returns true on success. 118 // Turns on and off the auto-repeat of the keyboard. Returns true on success.
72 // Do not call the function from non-UI threads. 119 // Do not call the function from non-UI threads.
73 static bool SetAutoRepeatEnabled(bool enabled); 120 static bool SetAutoRepeatEnabled(bool enabled);
74 121
75 // Sets the auto-repeat rate of the keyboard, initial delay in ms, and repeat 122 // Sets the auto-repeat rate of the keyboard, initial delay in ms, and repeat
76 // interval in ms. Returns true on success. Do not call the function from 123 // interval in ms. Returns true on success. Do not call the function from
77 // non-UI threads. 124 // non-UI threads.
78 static bool SetAutoRepeatRate(const AutoRepeatRate& rate); 125 static bool SetAutoRepeatRate(const AutoRepeatRate& rate);
79 126
80 // Returns true if caps lock is enabled. Do not call the function from non-UI 127 // Returns a mask (e.g. 1U<<4) for Num Lock. On error, returns 0.
81 // threads. 128 static unsigned int GetNumLockMask();
82 static bool CapsLockIsEnabled();
83
84 // Sets the caps lock status to |enable_caps_lock|. Do not call the function
85 // from non-UI threads.
86 static void SetCapsLockEnabled(bool enabled);
87 129
88 protected: 130 protected:
89 // Creates a full XKB layout name like 131 // Creates a full XKB layout name like
90 // "gb(extd)+chromeos(leftcontrol_disabled_leftalt),us" 132 // "gb(extd)+chromeos(leftcontrol_disabled_leftalt),us"
91 // from modifier key mapping and |layout_name|, such as "us", "us(dvorak)", 133 // from modifier key mapping and |layout_name|, such as "us", "us(dvorak)",
92 // and "gb(extd)". Returns an empty string on error. This function is 134 // and "gb(extd)". Returns an empty string on error. This function is
93 // protected: for testability. 135 // protected: for testability.
94 std::string CreateFullXkbLayoutName(const std::string& layout_name, 136 std::string CreateFullXkbLayoutName(const std::string& layout_name,
95 const ModifierMap& modifire_map); 137 const ModifierMap& modifire_map);
96 138
(...skipping 23 matching lines...) Expand all
120 // KeepCapsLock("us(colemak)") would return true. 162 // KeepCapsLock("us(colemak)") would return true.
121 bool KeepCapsLock(const std::string& xkb_layout_name) const; 163 bool KeepCapsLock(const std::string& xkb_layout_name) const;
122 164
123 // Converts |key| to a modifier key name which is used in 165 // Converts |key| to a modifier key name which is used in
124 // /usr/share/X11/xkb/symbols/chromeos. 166 // /usr/share/X11/xkb/symbols/chromeos.
125 static std::string ModifierKeyToString(ModifierKey key); 167 static std::string ModifierKeyToString(ModifierKey key);
126 168
127 // Called when execve'd setxkbmap process exits. 169 // Called when execve'd setxkbmap process exits.
128 static void OnSetLayoutFinish(pid_t pid, int status, XKeyboard* self); 170 static void OnSetLayoutFinish(pid_t pid, int status, XKeyboard* self);
129 171
172 const bool is_running_on_chrome_os_;
173 unsigned int num_lock_mask_;
174
175 // The current Num Lock and Caps Lock status. If true, enabled.
176 bool current_num_lock_status_;
177 bool current_caps_lock_status_;
130 // The XKB layout name which we set last time like "us" and "us(dvorak)". 178 // The XKB layout name which we set last time like "us" and "us(dvorak)".
131 std::string current_layout_name_; 179 std::string current_layout_name_;
132 // The mapping of modifier keys we set last time. 180 // The mapping of modifier keys we set last time.
133 ModifierMap current_modifier_map_; 181 ModifierMap current_modifier_map_;
182
134 // A queue for executing setxkbmap one by one. 183 // A queue for executing setxkbmap one by one.
135 std::queue<std::string> execute_queue_; 184 std::queue<std::string> execute_queue_;
136 185
137 std::set<std::string> keep_right_alt_xkb_layout_names_; 186 std::set<std::string> keep_right_alt_xkb_layout_names_;
138 std::set<std::string> caps_lock_remapped_xkb_layout_names_; 187 std::set<std::string> caps_lock_remapped_xkb_layout_names_;
139 188
140 const bool is_running_on_chrome_os_;
141
142 DISALLOW_COPY_AND_ASSIGN(XKeyboard); 189 DISALLOW_COPY_AND_ASSIGN(XKeyboard);
143 }; 190 };
144 191
145 } // namespace input_method 192 } // namespace input_method
146 } // namespace chromeos 193 } // namespace chromeos
147 194
148 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ 195 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/input_method_manager.h ('k') | chrome/browser/chromeos/input_method/xkeyboard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698