| 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 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 (mouse_button_state_ & LeftBit) != 0, | 244 (mouse_button_state_ & LeftBit) != 0, |
| 245 (mouse_button_state_ & RightBit) != 0, | 245 (mouse_button_state_ & RightBit) != 0, |
| 246 (mouse_button_state_ & MiddleBit) != 0); | 246 (mouse_button_state_ & MiddleBit) != 0); |
| 247 #pragma clang diagnostic pop | 247 #pragma clang diagnostic pop |
| 248 if (error != kCGErrorSuccess) | 248 if (error != kCGErrorSuccess) |
| 249 LOG(WARNING) << "CGPostMouseEvent error " << error; | 249 LOG(WARNING) << "CGPostMouseEvent error " << error; |
| 250 | 250 |
| 251 if (event.has_wheel_delta_x() && event.has_wheel_delta_y()) { | 251 if (event.has_wheel_delta_x() && event.has_wheel_delta_y()) { |
| 252 int delta_x = static_cast<int>(event.wheel_delta_x()); | 252 int delta_x = static_cast<int>(event.wheel_delta_x()); |
| 253 int delta_y = static_cast<int>(event.wheel_delta_y()); | 253 int delta_y = static_cast<int>(event.wheel_delta_y()); |
| 254 base::mac::ScopedCFTypeRef<CGEventRef> event( | 254 base::ScopedCFTypeRef<CGEventRef> event(CGEventCreateScrollWheelEvent( |
| 255 CGEventCreateScrollWheelEvent( | 255 NULL, kCGScrollEventUnitPixel, 2, delta_y, delta_x)); |
| 256 NULL, kCGScrollEventUnitPixel, 2, delta_y, delta_x)); | |
| 257 if (event) | 256 if (event) |
| 258 CGEventPost(kCGSessionEventTap, event); | 257 CGEventPost(kCGSessionEventTap, event); |
| 259 } | 258 } |
| 260 } | 259 } |
| 261 | 260 |
| 262 void InputInjectorMac::Core::Start( | 261 void InputInjectorMac::Core::Start( |
| 263 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 262 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
| 264 if (!task_runner_->BelongsToCurrentThread()) { | 263 if (!task_runner_->BelongsToCurrentThread()) { |
| 265 task_runner_->PostTask( | 264 task_runner_->PostTask( |
| 266 FROM_HERE, | 265 FROM_HERE, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 285 | 284 |
| 286 } // namespace | 285 } // namespace |
| 287 | 286 |
| 288 scoped_ptr<InputInjector> InputInjector::Create( | 287 scoped_ptr<InputInjector> InputInjector::Create( |
| 289 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 288 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 290 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 289 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 291 return scoped_ptr<InputInjector>(new InputInjectorMac(main_task_runner)); | 290 return scoped_ptr<InputInjector>(new InputInjectorMac(main_task_runner)); |
| 292 } | 291 } |
| 293 | 292 |
| 294 } // namespace remoting | 293 } // namespace remoting |
| OLD | NEW |