Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 REMOTING_HOST_LINUX_X_SERVER_KEY_MAPPER_H_ | |
| 6 #define REMOTING_HOST_LINUX_X_SERVER_KEY_MAPPER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 #include <X11/Xlib.h> | |
| 10 | |
| 11 #include <queue> | |
| 12 #include <unordered_set> | |
| 13 | |
| 14 #include "base/macros.h" | |
| 15 | |
| 16 namespace remoting { | |
| 17 | |
| 18 /** | |
| 19 * This is a helper class for assigning unused keycodes to characters. When all | |
| 20 * keycodes are used, newly added character will take the keycode of the oldest | |
| 21 * character. | |
| 22 * When the key mapper is destructed, all keycodes used by the mapper will be | |
| 23 * reset to map NoSymbol. | |
| 24 * The key mapper must be used on single thread thread. | |
| 25 */ | |
| 26 class XServerKeyMapper { | |
| 27 public: | |
| 28 explicit XServerKeyMapper(Display* display); | |
| 29 ~XServerKeyMapper(); | |
| 30 | |
| 31 // |code_point|: The Unicode code point for the character. | |
| 32 // Returns the keycode for the new character. Returns -1 when failed to map | |
| 33 // the character. | |
| 34 int AddNewCharacter(uint32_t code_point); | |
| 35 | |
| 36 private: | |
| 37 // X11 graphics context. | |
| 38 Display* display_; | |
| 39 | |
| 40 // TODO(yuweih): Consider better data structure, e.g. LRU. | |
|
Sergey Ulanov
2016/09/19 21:39:00
To implement the current solution you can just hav
Yuwei
2016/09/21 03:47:40
For LRU I think we should count use of KeySym rath
| |
| 41 std::queue<uint32_t> available_keycodes_; | |
| 42 | |
| 43 std::unordered_set<uint32_t> used_keycodes_; | |
|
Sergey Ulanov
2016/09/19 21:39:00
keycodes are always in range [8..255] so this can
Yuwei
2016/09/21 03:47:40
Obsolete. The |last_used| field of KeyInfo is enou
| |
| 44 | |
| 45 DISALLOW_COPY_AND_ASSIGN(XServerKeyMapper); | |
| 46 }; | |
| 47 | |
| 48 } // namespace remoting | |
| 49 | |
| 50 #endif // REMOTING_HOST_LINUX_X_SERVER_KEY_MAPPER_H_ | |
| OLD | NEW |