OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.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/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "remoting/host/capturer.h" | 14 #include "remoting/host/capturer.h" |
15 #include "remoting/proto/internal.pb.h" | 15 #include "remoting/proto/internal.pb.h" |
16 #include "remoting/protocol/message_decoder.h" | 16 #include "remoting/protocol/message_decoder.h" |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 using protocol::ClipboardEvent; | |
Sergey Ulanov
2012/03/14 20:27:07
nit: Don't need this.
simonmorris
2012/03/14 21:20:21
Done.
| |
23 using protocol::KeyEvent; | |
22 using protocol::MouseEvent; | 24 using protocol::MouseEvent; |
23 using protocol::KeyEvent; | |
24 | 25 |
25 // A class to generate events on Mac. | 26 // A class to generate events on Mac. |
26 class EventExecutorMac : public EventExecutor { | 27 class EventExecutorMac : public EventExecutor { |
27 public: | 28 public: |
28 EventExecutorMac(MessageLoop* message_loop, Capturer* capturer); | 29 EventExecutorMac(MessageLoop* message_loop, Capturer* capturer); |
29 virtual ~EventExecutorMac() {} | 30 virtual ~EventExecutorMac() {} |
30 | 31 |
32 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; | |
31 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; | 33 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; |
32 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; | 34 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; |
33 | 35 |
34 private: | 36 private: |
35 MessageLoop* message_loop_; | 37 MessageLoop* message_loop_; |
36 Capturer* capturer_; | 38 Capturer* capturer_; |
37 int last_x_, last_y_; | 39 int last_x_, last_y_; |
38 int mouse_buttons_; | 40 int mouse_buttons_; |
39 | 41 |
40 DISALLOW_COPY_AND_ASSIGN(EventExecutorMac); | 42 DISALLOW_COPY_AND_ASSIGN(EventExecutorMac); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 -1, -1, -1, -1, | 206 -1, -1, -1, -1, |
205 // 0xF4 - 0xF7 | 207 // 0xF4 - 0xF7 |
206 -1, -1, /* VKEY_ATTN */ -1, /* VKEY_CRSEL */ -1, | 208 -1, -1, /* VKEY_ATTN */ -1, /* VKEY_CRSEL */ -1, |
207 // 0xF8 - 0xFB | 209 // 0xF8 - 0xFB |
208 /* VKEY_EXSEL */ -1, /* VKEY_EREOF */ -1, /* VKEY_PLAY */ -1, | 210 /* VKEY_EXSEL */ -1, /* VKEY_EREOF */ -1, /* VKEY_PLAY */ -1, |
209 /* VKEY_ZOOM */ -1, | 211 /* VKEY_ZOOM */ -1, |
210 // 0xFC - 0xFF | 212 // 0xFC - 0xFF |
211 /* VKEY_NONAME */ -1, /* VKEY_PA1 */ -1, /* VKEY_OEM_CLEAR */ -1, -1 | 213 /* VKEY_NONAME */ -1, /* VKEY_PA1 */ -1, /* VKEY_OEM_CLEAR */ -1, -1 |
212 }; | 214 }; |
213 | 215 |
216 void EventExecutorMac::InjectClipboardEvent(const ClipboardEvent& event) { | |
217 // TODO(simonmorris): Implement clipboard injection. | |
218 } | |
219 | |
214 void EventExecutorMac::InjectKeyEvent(const KeyEvent& event) { | 220 void EventExecutorMac::InjectKeyEvent(const KeyEvent& event) { |
215 int key_code = event.keycode(); | 221 int key_code = event.keycode(); |
216 if (key_code >= 0 && key_code < 256) { | 222 if (key_code >= 0 && key_code < 256) { |
217 int key_sym = kUsVkeyToKeysym[key_code]; | 223 int key_sym = kUsVkeyToKeysym[key_code]; |
218 if (key_sym != -1) { | 224 if (key_sym != -1) { |
219 // We use the deprecated event injection API because the new one doesn't | 225 // We use the deprecated event injection API because the new one doesn't |
220 // work with switched-out sessions (curtain mode). | 226 // work with switched-out sessions (curtain mode). |
221 CGError error = CGPostKeyboardEvent(0, key_sym, event.pressed()); | 227 CGError error = CGPostKeyboardEvent(0, key_sym, event.pressed()); |
222 if (error != kCGErrorSuccess) { | 228 if (error != kCGErrorSuccess) { |
223 LOG(WARNING) << "CGPostKeyboardEvent error " << error; | 229 LOG(WARNING) << "CGPostKeyboardEvent error " << error; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 } | 294 } |
289 | 295 |
290 } // namespace | 296 } // namespace |
291 | 297 |
292 EventExecutor* EventExecutor::Create(MessageLoop* message_loop, | 298 EventExecutor* EventExecutor::Create(MessageLoop* message_loop, |
293 Capturer* capturer) { | 299 Capturer* capturer) { |
294 return new EventExecutorMac(message_loop, capturer); | 300 return new EventExecutorMac(message_loop, capturer); |
295 } | 301 } |
296 | 302 |
297 } // namespace remoting | 303 } // namespace remoting |
OLD | NEW |