OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #include "remoting/host/linux/x11_character_injector.h" | 5 #include "remoting/host/linux/x11_character_injector.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "remoting/host/linux/x11_keyboard.h" | 10 #include "remoting/host/linux/x11_keyboard.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 X11CharacterInjector::X11CharacterInjector( | 37 X11CharacterInjector::X11CharacterInjector( |
38 std::unique_ptr<X11Keyboard> keyboard) | 38 std::unique_ptr<X11Keyboard> keyboard) |
39 : keyboard_(std::move(keyboard)) { | 39 : keyboard_(std::move(keyboard)) { |
40 std::vector<uint32_t> keycodes = keyboard_->GetUnusedKeycodes(); | 40 std::vector<uint32_t> keycodes = keyboard_->GetUnusedKeycodes(); |
41 for (int keycode : keycodes) { | 41 for (int keycode : keycodes) { |
42 available_keycodes_.push_back({keycode, base::TimeTicks()}); | 42 available_keycodes_.push_back({keycode, base::TimeTicks()}); |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 X11CharacterInjector::~X11CharacterInjector() { | 46 X11CharacterInjector::~X11CharacterInjector() { |
| 47 DCHECK(thread_checker_.CalledOnValidThread()); |
47 // Clear all used key mappings. | 48 // Clear all used key mappings. |
48 for (const KeyInfo& info : available_keycodes_) { | 49 for (const KeyInfo& info : available_keycodes_) { |
49 if (!info.expire_at.is_null()) { | 50 if (!info.expire_at.is_null()) { |
50 keyboard_->ChangeKeyMapping(info.keycode, 0); | 51 keyboard_->ChangeKeyMapping(info.keycode, 0); |
51 } | 52 } |
52 } | 53 } |
53 keyboard_->Sync(); | 54 keyboard_->Sync(); |
54 } | 55 } |
55 | 56 |
56 void X11CharacterInjector::Inject(uint32_t code_point) { | 57 void X11CharacterInjector::Inject(uint32_t code_point) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 void X11CharacterInjector::ResetKeyInfoExpirationTime( | 136 void X11CharacterInjector::ResetKeyInfoExpirationTime( |
136 base::TimeTicks now, | 137 base::TimeTicks now, |
137 std::vector<KeyInfo>::iterator position) { | 138 std::vector<KeyInfo>::iterator position) { |
138 KeyInfo info = *position; | 139 KeyInfo info = *position; |
139 info.expire_at = now + kMappingExpireDuration; | 140 info.expire_at = now + kMappingExpireDuration; |
140 available_keycodes_.erase(position); | 141 available_keycodes_.erase(position); |
141 available_keycodes_.push_back(info); | 142 available_keycodes_.push_back(info); |
142 } | 143 } |
143 | 144 |
144 } // namespace remoting | 145 } // namespace remoting |
OLD | NEW |