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

Side by Side Diff: remoting/host/linux/x_server_key_mapper.h

Issue 2346643003: [Remoting Host] Handle text event characters that are not presented on the keyboard (Closed)
Patch Set: Reviewer's Feedback Created 4 years, 3 months 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
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698