Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/event_executor_mac.h" | 5 #include "remoting/host/event_executor.h" |
| 6 | 6 |
| 7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
| 8 #include <Carbon/Carbon.h> | 8 #include <Carbon/Carbon.h> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | |
| 10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 11 #include "base/task.h" | 12 #include "base/task.h" |
| 12 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
|
Lambros
2011/04/01 15:54:00
Nit: alphabetize
dmac
2011/04/01 21:15:07
Done.
| |
| 13 #include "remoting/host/capturer.h" | 14 #include "remoting/host/capturer.h" |
| 14 #include "remoting/protocol/message_decoder.h" | 15 #include "remoting/protocol/message_decoder.h" |
| 15 #include "remoting/proto/internal.pb.h" | 16 #include "remoting/proto/internal.pb.h" |
|
Lambros
2011/04/01 15:54:00
Nit: proto before protocol?
dmac
2011/04/01 21:15:07
Done.
| |
| 16 | 17 |
| 17 namespace remoting { | 18 namespace remoting { |
| 18 | 19 |
| 20 namespace { | |
| 21 | |
| 19 using protocol::MouseEvent; | 22 using protocol::MouseEvent; |
| 20 using protocol::KeyEvent; | 23 using protocol::KeyEvent; |
| 21 | 24 |
| 25 // A class to generate events on Mac. | |
| 26 class EventExecutorMac : public EventExecutor { | |
| 27 public: | |
| 28 EventExecutorMac(MessageLoopForUI* message_loop, Capturer* capturer); | |
| 29 virtual ~EventExecutorMac() {} | |
| 30 | |
| 31 virtual void InjectKeyEvent(const KeyEvent* event, Task* done) OVERRIDE; | |
| 32 virtual void InjectMouseEvent(const MouseEvent* event, Task* done) OVERRIDE; | |
| 33 | |
| 34 private: | |
| 35 MessageLoopForUI* message_loop_; | |
| 36 Capturer* capturer_; | |
| 37 int last_x_, last_y_; | |
| 38 int modifiers_, mouse_buttons_; | |
| 39 | |
| 40 DISALLOW_COPY_AND_ASSIGN(EventExecutorMac); | |
| 41 }; | |
| 42 | |
| 22 EventExecutorMac::EventExecutorMac( | 43 EventExecutorMac::EventExecutorMac( |
| 23 MessageLoopForUI* message_loop, Capturer* capturer) | 44 MessageLoopForUI* message_loop, Capturer* capturer) |
| 24 : message_loop_(message_loop), | 45 : message_loop_(message_loop), |
| 25 capturer_(capturer), last_x_(0), last_y_(0), modifiers_(0), | 46 capturer_(capturer), last_x_(0), last_y_(0), modifiers_(0), |
| 26 mouse_buttons_(0) { | 47 mouse_buttons_(0) { |
| 27 } | 48 } |
| 28 | 49 |
| 29 EventExecutorMac::~EventExecutorMac() { | |
| 30 } | |
| 31 | |
| 32 // Hard-coded mapping from Virtual Key codes to Mac KeySyms. | 50 // Hard-coded mapping from Virtual Key codes to Mac KeySyms. |
| 33 // This mapping is only valid if both client and host are using a | 51 // This mapping is only valid if both client and host are using a |
| 34 // US English keyboard layout. | 52 // US English keyboard layout. |
| 35 // Because we're passing VK codes on the wire, with no Scancode, | 53 // Because we're passing VK codes on the wire, with no Scancode, |
| 36 // "extended" flag, etc, things like distinguishing left & right | 54 // "extended" flag, etc, things like distinguishing left & right |
| 37 // Shift keys doesn't work. | 55 // Shift keys doesn't work. |
| 38 // | 56 // |
| 39 // TODO(wez): Replace this with something more closely tied to what | 57 // TODO(wez): Replace this with something more closely tied to what |
| 40 // WebInputEventFactory does on Linux/GTK, and which respects the | 58 // WebInputEventFactory does on Linux/GTK, and which respects the |
| 41 // host's keyboard layout. | 59 // host's keyboard layout. |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 if (event->has_wheel_offset_x() && event->has_wheel_offset_y()) { | 298 if (event->has_wheel_offset_x() && event->has_wheel_offset_y()) { |
| 281 // TODO(jamiewalch): Use either CGPostScrollWheelEvent() or | 299 // TODO(jamiewalch): Use either CGPostScrollWheelEvent() or |
| 282 // CGEventCreateScrollWheelEvent() to inject scroll events. | 300 // CGEventCreateScrollWheelEvent() to inject scroll events. |
| 283 NOTIMPLEMENTED() << "No scroll wheel support yet."; | 301 NOTIMPLEMENTED() << "No scroll wheel support yet."; |
| 284 } | 302 } |
| 285 | 303 |
| 286 done->Run(); | 304 done->Run(); |
| 287 delete done; | 305 delete done; |
| 288 } | 306 } |
| 289 | 307 |
| 290 protocol::InputStub* CreateEventExecutor(MessageLoopForUI* message_loop, | 308 } // namespace |
| 291 Capturer* capturer) { | 309 |
| 310 EventExecutor* EventExecutor::Create(MessageLoopForUI* message_loop, | |
| 311 Capturer* capturer) { | |
| 292 return new EventExecutorMac(message_loop, capturer); | 312 return new EventExecutorMac(message_loop, capturer); |
| 293 } | 313 } |
| 294 | 314 |
| 295 } // namespace remoting | 315 } // namespace remoting |
| OLD | NEW |