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

Side by Side Diff: remoting/host/linux/x11_character_injector.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, 2 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_X11_CHARACTER_INJECTOR_H_
6 #define REMOTING_HOST_LINUX_X11_CHARACTER_INJECTOR_H_
7
8 #include <stdint.h>
9
10 #include <queue>
11
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h"
15 #include "base/timer/timer.h"
16
17 namespace remoting {
18
19 class X11Keyboard;
20
21 // This is a helper class for injecting unicode characters to XWindow server.
22 // Characters will be queued up and sent when there is available resource.
23 class X11CharacterInjector {
24 public:
25 explicit X11CharacterInjector(std::unique_ptr<X11Keyboard> keyboard);
26 ~X11CharacterInjector();
27
28 void Inject(uint32_t code_point);
29
30 private:
31 struct KeyInfo;
32 struct MapResult;
33
34 // Schedules a task to call DoInject after |delay| if no such task has been
35 // scheduled.
36 void Schedule(base::TimeDelta delay);
37 void DoInject();
38
39 // |code_point|: The Unicode code point for the character.
40 // If the returned result indicates success, caller can use the returned
41 // keycode and modifiers to simulate a key press that can generate the
42 // character.
43 //
44 // Note that the returned result will expire after some amount of time so do
45 // not store the result for later use.
46 MapResult MapCharacter(uint32_t code_point);
47
48 // Resets the expiration time of the KeyInfo in available_keycodes_[index]
49 // to now + the expire duration constant.
50 void ResetKeyInfoExpirationTime(base::TimeTicks now,
51 std::vector<KeyInfo>::iterator position);
52
53 std::unique_ptr<X11Keyboard> keyboard_;
54 std::queue<uint32_t> characters_queue_;
55 base::OneShotTimer injection_timer_;
56
57 // Sorted by ascending expiration time.
58 std::vector<KeyInfo> available_keycodes_;
59
60 base::ThreadChecker thread_checker_;
61 DISALLOW_COPY_AND_ASSIGN(X11CharacterInjector);
62 };
63
64 } // namespace remoting
65
66 #endif // REMOTING_HOST_LINUX_X11_CHARACTER_INJECTOR_H_
OLDNEW
« no previous file with comments | « remoting/host/linux/unicode_to_keysym_unittest.cc ('k') | remoting/host/linux/x11_character_injector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698