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_X11_CHARACTER_INJECTOR_H_ |
| 6 #define REMOTING_HOST_LINUX_X11_CHARACTER_INJECTOR_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include <X11/Xlib.h> |
| 10 |
| 11 #include <queue> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/threading/thread_checker.h" |
| 16 #include "base/timer/timer.h" |
| 17 #include "remoting/host/linux/x11_key_mapper.h" |
| 18 |
| 19 namespace remoting { |
| 20 |
| 21 class X11Keyboard; |
| 22 |
| 23 // This is a helper class for injecting unicode characters to XWindow server. |
| 24 // Characters will be queued up and sent when there is available resource. |
| 25 class X11CharacterInjector { |
| 26 public: |
| 27 explicit X11CharacterInjector(Display* display); |
| 28 ~X11CharacterInjector(); |
| 29 |
| 30 void Inject(uint32_t code_point); |
| 31 |
| 32 private: |
| 33 // Ensures that Consume() will be called once at some point in the future not |
| 34 // earlier than now + |delay|. It's a no-op when calling this function with a |
| 35 // smaller |delay| after calling this with a larger delay while the scheduled |
| 36 // Consume() has not been called yet. |
| 37 void Schedule(base::TimeDelta delay); |
| 38 void Consume(); |
| 39 |
| 40 std::unique_ptr<X11Keyboard> keyboard_; |
| 41 X11KeyMapper key_mapper_; |
| 42 std::queue<uint32_t> characters_queue_; |
| 43 base::OneShotTimer consume_timer_; |
| 44 base::TimeTicks scheduled_consume_time_; |
| 45 |
| 46 base::ThreadChecker thread_checker_; |
| 47 |
| 48 base::WeakPtrFactory<X11CharacterInjector> weak_factory_; |
| 49 DISALLOW_COPY_AND_ASSIGN(X11CharacterInjector); |
| 50 }; |
| 51 |
| 52 } // namespace remoting |
| 53 |
| 54 #endif // REMOTING_HOST_LINUX_X11_CHARACTER_INJECTOR_H_ |
OLD | NEW |