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/input_injector.h" | 5 #include "remoting/host/input_injector.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <ApplicationServices/ApplicationServices.h> | 8 #include <ApplicationServices/ApplicationServices.h> |
9 #include <Carbon/Carbon.h> | 9 #include <Carbon/Carbon.h> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/mac/scoped_cftyperef.h" | 15 #include "base/mac/scoped_cftyperef.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "media/video/capture/screen/mac/desktop_configuration.h" | |
19 #include "remoting/host/clipboard.h" | 18 #include "remoting/host/clipboard.h" |
20 #include "remoting/proto/internal.pb.h" | 19 #include "remoting/proto/internal.pb.h" |
21 #include "remoting/protocol/message_decoder.h" | 20 #include "remoting/protocol/message_decoder.h" |
22 #include "skia/ext/skia_utils_mac.h" | 21 #include "skia/ext/skia_utils_mac.h" |
23 #include "third_party/skia/include/core/SkPoint.h" | 22 #include "third_party/skia/include/core/SkPoint.h" |
24 #include "third_party/skia/include/core/SkRect.h" | 23 #include "third_party/skia/include/core/SkRect.h" |
| 24 #include "third_party/webrtc/modules/desktop_capture/mac/desktop_configuration.h
" |
25 | 25 |
26 namespace remoting { | 26 namespace remoting { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 using protocol::ClipboardEvent; | 30 using protocol::ClipboardEvent; |
31 using protocol::KeyEvent; | 31 using protocol::KeyEvent; |
32 using protocol::MouseEvent; | 32 using protocol::MouseEvent; |
33 | 33 |
34 // USB to Mac keycode mapping table. | 34 // USB to Mac keycode mapping table. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // accordingly. | 184 // accordingly. |
185 | 185 |
186 // Set the mouse position assuming single-monitor. | 186 // Set the mouse position assuming single-monitor. |
187 mouse_pos_ = SkIPoint::Make(event.x(), event.y()); | 187 mouse_pos_ = SkIPoint::Make(event.x(), event.y()); |
188 | 188 |
189 // Fetch the desktop configuration. | 189 // Fetch the desktop configuration. |
190 // TODO(wez): Optimize this out, or at least only enumerate displays in | 190 // TODO(wez): Optimize this out, or at least only enumerate displays in |
191 // response to display-changed events. VideoFrameCapturer's VideoFrames | 191 // response to display-changed events. VideoFrameCapturer's VideoFrames |
192 // could be augmented to include native cursor coordinates for use by | 192 // could be augmented to include native cursor coordinates for use by |
193 // MouseClampingFilter, removing the need for translation here. | 193 // MouseClampingFilter, removing the need for translation here. |
194 media::MacDesktopConfiguration desktop_config = | 194 webrtc::MacDesktopConfiguration desktop_config = |
195 media::MacDesktopConfiguration::GetCurrent( | 195 webrtc::MacDesktopConfiguration::GetCurrent( |
196 media::MacDesktopConfiguration::TopLeftOrigin); | 196 webrtc::MacDesktopConfiguration::TopLeftOrigin); |
197 | 197 |
198 // Translate the mouse position into desktop coordinates. | 198 // Translate the mouse position into desktop coordinates. |
199 mouse_pos_ += SkIPoint::Make(desktop_config.pixel_bounds.left(), | 199 mouse_pos_ += SkIPoint::Make(desktop_config.pixel_bounds.left(), |
200 desktop_config.pixel_bounds.top()); | 200 desktop_config.pixel_bounds.top()); |
201 | 201 |
202 // Constrain the mouse position to the desktop coordinates. | 202 // Constrain the mouse position to the desktop coordinates. |
203 mouse_pos_ = SkIPoint::Make( | 203 mouse_pos_ = SkIPoint::Make( |
204 std::max(desktop_config.pixel_bounds.left(), | 204 std::max(desktop_config.pixel_bounds.left(), |
205 std::min(desktop_config.pixel_bounds.right(), mouse_pos_.x())), | 205 std::min(desktop_config.pixel_bounds.right(), mouse_pos_.x())), |
206 std::max(desktop_config.pixel_bounds.top(), | 206 std::max(desktop_config.pixel_bounds.top(), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 285 |
286 } // namespace | 286 } // namespace |
287 | 287 |
288 scoped_ptr<InputInjector> InputInjector::Create( | 288 scoped_ptr<InputInjector> InputInjector::Create( |
289 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 289 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
290 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 290 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
291 return scoped_ptr<InputInjector>(new InputInjectorMac(main_task_runner)); | 291 return scoped_ptr<InputInjector>(new InputInjectorMac(main_task_runner)); |
292 } | 292 } |
293 | 293 |
294 } // namespace remoting | 294 } // namespace remoting |
OLD | NEW |