Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: remoting/host/event_executor_mac.cc

Issue 10833060: Update for OS X 10.6 SDK. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 mouse_button_state_(0), 64 mouse_button_state_(0),
65 clipboard_(Clipboard::Create()) { 65 clipboard_(Clipboard::Create()) {
66 // Ensure that local hardware events are not suppressed after injecting 66 // Ensure that local hardware events are not suppressed after injecting
67 // input events. This allows LocalInputMonitor to detect if the local mouse 67 // input events. This allows LocalInputMonitor to detect if the local mouse
68 // is being moved whilst a remote user is connected. 68 // is being moved whilst a remote user is connected.
69 // This API is deprecated, but it is needed when using the deprecated 69 // This API is deprecated, but it is needed when using the deprecated
70 // injection APIs. 70 // injection APIs.
71 // If the non-deprecated injection APIs were used instead, the equivalent of 71 // If the non-deprecated injection APIs were used instead, the equivalent of
72 // this line would not be needed, as OS X defaults to _not_ suppressing local 72 // this line would not be needed, as OS X defaults to _not_ suppressing local
73 // inputs in that case. 73 // inputs in that case.
74 #pragma clang diagnostic push
75 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
74 CGSetLocalEventsSuppressionInterval(0.0); 76 CGSetLocalEventsSuppressionInterval(0.0);
77 #pragma clang diagnostic pop
75 } 78 }
76 79
77 // Hard-coded mapping from Virtual Key codes to Mac KeySyms. 80 // Hard-coded mapping from Virtual Key codes to Mac KeySyms.
78 // This mapping is only valid if both client and host are using a 81 // This mapping is only valid if both client and host are using a
79 // US English keyboard layout. 82 // US English keyboard layout.
80 // Because we're passing VK codes on the wire, with no Scancode, 83 // Because we're passing VK codes on the wire, with no Scancode,
81 // "extended" flag, etc, things like distinguishing left & right 84 // "extended" flag, etc, things like distinguishing left & right
82 // Shift keys doesn't work. 85 // Shift keys doesn't work.
83 // 86 //
84 // TODO(wez): Replace this with something more closely tied to what 87 // TODO(wez): Replace this with something more closely tied to what
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 VLOG(3) << "Converting VKEY: " << std::hex << event.keycode() 289 VLOG(3) << "Converting VKEY: " << std::hex << event.keycode()
287 << " to keycode: " << keycode << std::dec; 290 << " to keycode: " << keycode << std::dec;
288 } 291 }
289 292
290 // If we couldn't determine the Mac virtual key code then ignore the event. 293 // If we couldn't determine the Mac virtual key code then ignore the event.
291 if (keycode == kInvalidKeycode) 294 if (keycode == kInvalidKeycode)
292 return; 295 return;
293 296
294 // We use the deprecated event injection API because the new one doesn't 297 // We use the deprecated event injection API because the new one doesn't
295 // work with switched-out sessions (curtain mode). 298 // work with switched-out sessions (curtain mode).
299 #pragma clang diagnostic push
300 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
296 CGError error = CGPostKeyboardEvent(0, keycode, event.pressed()); 301 CGError error = CGPostKeyboardEvent(0, keycode, event.pressed());
302 #pragma clang diagnostic pop
297 if (error != kCGErrorSuccess) { 303 if (error != kCGErrorSuccess) {
298 LOG(WARNING) << "CGPostKeyboardEvent error " << error; 304 LOG(WARNING) << "CGPostKeyboardEvent error " << error;
299 } 305 }
300 } 306 }
301 307
302 void EventExecutorMac::InjectMouseEvent(const MouseEvent& event) { 308 void EventExecutorMac::InjectMouseEvent(const MouseEvent& event) {
303 if (event.has_x() && event.has_y()) { 309 if (event.has_x() && event.has_y()) {
304 // TODO(wez): This code assumes that MouseEvent(0,0) (top-left of client vie w) 310 // TODO(wez): This code assumes that MouseEvent(0,0) (top-left of client vie w)
305 // corresponds to local (0,0) (top-left of primary monitor). That won't in 311 // corresponds to local (0,0) (top-left of primary monitor). That won't in
306 // general be true on multi-monitor systems, though. 312 // general be true on multi-monitor systems, though.
(...skipping 18 matching lines...) Expand all
325 // events. For example, the deprecated APIs will detect double-clicks or drags 331 // events. For example, the deprecated APIs will detect double-clicks or drags
326 // in a way that is consistent with how they would be generated using a local 332 // in a way that is consistent with how they would be generated using a local
327 // mouse, whereas the new APIs expect us to inject these higher-level events 333 // mouse, whereas the new APIs expect us to inject these higher-level events
328 // directly. 334 // directly.
329 CGPoint position = CGPointMake(mouse_pos_.x(), mouse_pos_.y()); 335 CGPoint position = CGPointMake(mouse_pos_.x(), mouse_pos_.y());
330 enum { 336 enum {
331 LeftBit = 1 << (MouseEvent::BUTTON_LEFT - 1), 337 LeftBit = 1 << (MouseEvent::BUTTON_LEFT - 1),
332 MiddleBit = 1 << (MouseEvent::BUTTON_MIDDLE - 1), 338 MiddleBit = 1 << (MouseEvent::BUTTON_MIDDLE - 1),
333 RightBit = 1 << (MouseEvent::BUTTON_RIGHT - 1) 339 RightBit = 1 << (MouseEvent::BUTTON_RIGHT - 1)
334 }; 340 };
341 #pragma clang diagnostic push
342 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
335 CGError error = CGPostMouseEvent(position, true, 3, 343 CGError error = CGPostMouseEvent(position, true, 3,
336 (mouse_button_state_ & LeftBit) != 0, 344 (mouse_button_state_ & LeftBit) != 0,
337 (mouse_button_state_ & RightBit) != 0, 345 (mouse_button_state_ & RightBit) != 0,
338 (mouse_button_state_ & MiddleBit) != 0); 346 (mouse_button_state_ & MiddleBit) != 0);
347 #pragma clang diagnostic pop
339 if (error != kCGErrorSuccess) { 348 if (error != kCGErrorSuccess) {
340 LOG(WARNING) << "CGPostMouseEvent error " << error; 349 LOG(WARNING) << "CGPostMouseEvent error " << error;
341 } 350 }
342 351
343 if (event.has_wheel_offset_x() && event.has_wheel_offset_y()) { 352 if (event.has_wheel_offset_x() && event.has_wheel_offset_y()) {
344 int dx = event.wheel_offset_x(); 353 int dx = event.wheel_offset_x();
345 int dy = event.wheel_offset_y(); 354 int dy = event.wheel_offset_y();
346 // Note that |dy| (the vertical wheel) is the primary wheel. 355 // Note that |dy| (the vertical wheel) is the primary wheel.
356 #pragma clang diagnostic push
357 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
347 error = CGPostScrollWheelEvent(2, dy, dx); 358 error = CGPostScrollWheelEvent(2, dy, dx);
359 #pragma clang diagnostic pop
348 if (error != kCGErrorSuccess) { 360 if (error != kCGErrorSuccess) {
349 LOG(WARNING) << "CGPostScrollWheelEvent error " << error; 361 LOG(WARNING) << "CGPostScrollWheelEvent error " << error;
350 } 362 }
351 } 363 }
352 } 364 }
353 365
354 void EventExecutorMac::OnSessionStarted( 366 void EventExecutorMac::OnSessionStarted(
355 scoped_ptr<protocol::ClipboardStub> client_clipboard) { 367 scoped_ptr<protocol::ClipboardStub> client_clipboard) {
356 if (!task_runner_->BelongsToCurrentThread()) { 368 if (!task_runner_->BelongsToCurrentThread()) {
357 task_runner_->PostTask( 369 task_runner_->PostTask(
(...skipping 21 matching lines...) Expand all
379 391
380 } // namespace 392 } // namespace
381 393
382 scoped_ptr<EventExecutor> EventExecutor::Create( 394 scoped_ptr<EventExecutor> EventExecutor::Create(
383 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 395 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
384 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 396 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
385 return scoped_ptr<EventExecutor>(new EventExecutorMac(main_task_runner)); 397 return scoped_ptr<EventExecutor>(new EventExecutorMac(main_task_runner));
386 } 398 }
387 399
388 } // namespace remoting 400 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/video_frame_capturer_mac.mm » ('j') | remoting/host/video_frame_capturer_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698