OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/local_input_monitor.h" | 5 #include "remoting/host/local_input_monitor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 void LocalInputMonitorWin::Core::StopOnUiThread() { | 142 void LocalInputMonitorWin::Core::StopOnUiThread() { |
143 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 143 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
144 | 144 |
145 // Stop receiving raw mouse input. | 145 // Stop receiving raw mouse input. |
146 if (window_) { | 146 if (window_) { |
147 RAWINPUTDEVICE device = {0}; | 147 RAWINPUTDEVICE device = {0}; |
148 device.dwFlags = RIDEV_REMOVE; | 148 device.dwFlags = RIDEV_REMOVE; |
149 device.usUsagePage = kGenericDesktopPage; | 149 device.usUsagePage = kGenericDesktopPage; |
150 device.usUsage = kMouseUsage; | 150 device.usUsage = kMouseUsage; |
151 device.hwndTarget = NULL; | 151 device.hwndTarget = nullptr; |
152 | 152 |
153 // The error is harmless, ignore it. | 153 // The error is harmless, ignore it. |
154 RegisterRawInputDevices(&device, 1, sizeof(device)); | 154 RegisterRawInputDevices(&device, 1, sizeof(device)); |
155 } | 155 } |
156 | 156 |
157 window_.reset(); | 157 window_.reset(); |
158 } | 158 } |
159 | 159 |
160 LRESULT LocalInputMonitorWin::Core::OnInput(HRAWINPUT input_handle) { | 160 LRESULT LocalInputMonitorWin::Core::OnInput(HRAWINPUT input_handle) { |
161 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 161 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
162 | 162 |
163 // Get the size of the input record. | 163 // Get the size of the input record. |
164 UINT size = 0; | 164 UINT size = 0; |
165 UINT result = GetRawInputData(input_handle, | 165 UINT result = GetRawInputData(input_handle, |
166 RID_INPUT, | 166 RID_INPUT, |
167 NULL, | 167 nullptr, |
168 &size, | 168 &size, |
169 sizeof(RAWINPUTHEADER)); | 169 sizeof(RAWINPUTHEADER)); |
170 if (result == -1) { | 170 if (result == -1) { |
171 PLOG(ERROR) << "GetRawInputData() failed"; | 171 PLOG(ERROR) << "GetRawInputData() failed"; |
172 return 0; | 172 return 0; |
173 } | 173 } |
174 | 174 |
175 // Retrieve the input record itself. | 175 // Retrieve the input record itself. |
176 scoped_ptr<uint8[]> buffer(new uint8[size]); | 176 scoped_ptr<uint8[]> buffer(new uint8[size]); |
177 RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get()); | 177 RAWINPUT* input = reinterpret_cast<RAWINPUT*>(buffer.get()); |
178 result = GetRawInputData(input_handle, | 178 result = GetRawInputData(input_handle, |
179 RID_INPUT, | 179 RID_INPUT, |
180 buffer.get(), | 180 buffer.get(), |
181 &size, | 181 &size, |
182 sizeof(RAWINPUTHEADER)); | 182 sizeof(RAWINPUTHEADER)); |
183 if (result == -1) { | 183 if (result == -1) { |
184 PLOG(ERROR) << "GetRawInputData() failed"; | 184 PLOG(ERROR) << "GetRawInputData() failed"; |
185 return 0; | 185 return 0; |
186 } | 186 } |
187 | 187 |
188 // Notify the observer about mouse events generated locally. Remote (injected) | 188 // Notify the observer about mouse events generated locally. Remote (injected) |
189 // mouse events do not specify a device handle (based on observed behavior). | 189 // mouse events do not specify a device handle (based on observed behavior). |
190 if (input->header.dwType == RIM_TYPEMOUSE && | 190 if (input->header.dwType == RIM_TYPEMOUSE && |
191 input->header.hDevice != NULL) { | 191 input->header.hDevice != nullptr) { |
192 POINT position; | 192 POINT position; |
193 if (!GetCursorPos(&position)) { | 193 if (!GetCursorPos(&position)) { |
194 position.x = 0; | 194 position.x = 0; |
195 position.y = 0; | 195 position.y = 0; |
196 } | 196 } |
197 | 197 |
198 caller_task_runner_->PostTask( | 198 caller_task_runner_->PostTask( |
199 FROM_HERE, base::Bind(&ClientSessionControl::OnLocalMouseMoved, | 199 FROM_HERE, base::Bind(&ClientSessionControl::OnLocalMouseMoved, |
200 client_session_control_, | 200 client_session_control_, |
201 webrtc::DesktopVector(position.x, position.y))); | 201 webrtc::DesktopVector(position.x, position.y))); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 scoped_ptr<LocalInputMonitor> LocalInputMonitor::Create( | 237 scoped_ptr<LocalInputMonitor> LocalInputMonitor::Create( |
238 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 238 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
239 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 239 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
240 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 240 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
241 base::WeakPtr<ClientSessionControl> client_session_control) { | 241 base::WeakPtr<ClientSessionControl> client_session_control) { |
242 return make_scoped_ptr(new LocalInputMonitorWin( | 242 return make_scoped_ptr(new LocalInputMonitorWin( |
243 caller_task_runner, ui_task_runner, client_session_control)); | 243 caller_task_runner, ui_task_runner, client_session_control)); |
244 } | 244 } |
245 | 245 |
246 } // namespace remoting | 246 } // namespace remoting |
OLD | NEW |