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 "base/task.h" | 14 #include "base/task.h" |
15 #include "media/base/callback.h" | |
16 #include "remoting/host/capturer.h" | 15 #include "remoting/host/capturer.h" |
17 #include "remoting/proto/internal.pb.h" | 16 #include "remoting/proto/internal.pb.h" |
18 #include "remoting/protocol/message_decoder.h" | 17 #include "remoting/protocol/message_decoder.h" |
19 | 18 |
20 namespace remoting { | 19 namespace remoting { |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 using protocol::MouseEvent; | 23 using protocol::MouseEvent; |
25 using protocol::KeyEvent; | 24 using protocol::KeyEvent; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 // 0xF4 - 0xF7 | 207 // 0xF4 - 0xF7 |
209 -1, -1, /* VKEY_ATTN */ -1, /* VKEY_CRSEL */ -1, | 208 -1, -1, /* VKEY_ATTN */ -1, /* VKEY_CRSEL */ -1, |
210 // 0xF8 - 0xFB | 209 // 0xF8 - 0xFB |
211 /* VKEY_EXSEL */ -1, /* VKEY_EREOF */ -1, /* VKEY_PLAY */ -1, | 210 /* VKEY_EXSEL */ -1, /* VKEY_EREOF */ -1, /* VKEY_PLAY */ -1, |
212 /* VKEY_ZOOM */ -1, | 211 /* VKEY_ZOOM */ -1, |
213 // 0xFC - 0xFF | 212 // 0xFC - 0xFF |
214 /* VKEY_NONAME */ -1, /* VKEY_PA1 */ -1, /* VKEY_OEM_CLEAR */ -1, -1 | 213 /* VKEY_NONAME */ -1, /* VKEY_PA1 */ -1, /* VKEY_OEM_CLEAR */ -1, -1 |
215 }; | 214 }; |
216 | 215 |
217 void EventExecutorMac::InjectKeyEvent(const KeyEvent* event, Task* done) { | 216 void EventExecutorMac::InjectKeyEvent(const KeyEvent* event, Task* done) { |
218 media::AutoTaskRunner done_runner(done); | 217 base::ScopedTaskRunner done_runner(done); |
219 | 218 |
220 int key_code = event->keycode(); | 219 int key_code = event->keycode(); |
221 if (key_code >= 0 && key_code < 256) { | 220 if (key_code >= 0 && key_code < 256) { |
222 int key_sym = kUsVkeyToKeysym[key_code]; | 221 int key_sym = kUsVkeyToKeysym[key_code]; |
223 if (key_sym != -1) { | 222 if (key_sym != -1) { |
224 base::mac::ScopedCFTypeRef<CGEventRef> kbd_event( | 223 base::mac::ScopedCFTypeRef<CGEventRef> kbd_event( |
225 CGEventCreateKeyboardEvent(0, kUsVkeyToKeysym[key_code], | 224 CGEventCreateKeyboardEvent(0, kUsVkeyToKeysym[key_code], |
226 event->pressed())); | 225 event->pressed())); |
227 int this_modifier = 0; | 226 int this_modifier = 0; |
228 switch (key_sym) { | 227 switch (key_sym) { |
(...skipping 15 matching lines...) Expand all Loading... |
244 } else if (this_modifier && !event->pressed()) { | 243 } else if (this_modifier && !event->pressed()) { |
245 modifiers_ &= ~this_modifier; | 244 modifiers_ &= ~this_modifier; |
246 } | 245 } |
247 CGEventSetFlags(kbd_event, modifiers_); | 246 CGEventSetFlags(kbd_event, modifiers_); |
248 CGEventPost(kCGSessionEventTap, kbd_event); | 247 CGEventPost(kCGSessionEventTap, kbd_event); |
249 } | 248 } |
250 } | 249 } |
251 } | 250 } |
252 | 251 |
253 void EventExecutorMac::InjectMouseEvent(const MouseEvent* event, Task* done) { | 252 void EventExecutorMac::InjectMouseEvent(const MouseEvent* event, Task* done) { |
254 media::AutoTaskRunner done_runner(done); | 253 base::ScopedTaskRunner done_runner(done); |
255 | 254 |
256 if (event->has_x() && event->has_y()) { | 255 if (event->has_x() && event->has_y()) { |
257 // TODO(wez): Checking the validity of the MouseEvent should be done in core | 256 // TODO(wez): Checking the validity of the MouseEvent should be done in core |
258 // cross-platform code, not here! | 257 // cross-platform code, not here! |
259 // TODO(wez): This code assumes that MouseEvent(0,0) (top-left of client vie
w) | 258 // TODO(wez): This code assumes that MouseEvent(0,0) (top-left of client vie
w) |
260 // corresponds to local (0,0) (top-left of primary monitor). That won't in | 259 // corresponds to local (0,0) (top-left of primary monitor). That won't in |
261 // general be true on multi-monitor systems, though. | 260 // general be true on multi-monitor systems, though. |
262 gfx::Size size = capturer_->size_most_recent(); | 261 gfx::Size size = capturer_->size_most_recent(); |
263 if (event->x() >= 0 || event->y() >= 0 || | 262 if (event->x() >= 0 || event->y() >= 0 || |
264 event->x() < size.width() || event->y() < size.height()) { | 263 event->x() < size.width() || event->y() < size.height()) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 306 } |
308 | 307 |
309 } // namespace | 308 } // namespace |
310 | 309 |
311 EventExecutor* EventExecutor::Create(MessageLoop* message_loop, | 310 EventExecutor* EventExecutor::Create(MessageLoop* message_loop, |
312 Capturer* capturer) { | 311 Capturer* capturer) { |
313 return new EventExecutorMac(message_loop, capturer); | 312 return new EventExecutorMac(message_loop, capturer); |
314 } | 313 } |
315 | 314 |
316 } // namespace remoting | 315 } // namespace remoting |
OLD | NEW |