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

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

Issue 9646013: Add the plumbing that will carry a clipboard item from a chromoting client to a host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix remoting_simple_host. Created 8 years, 9 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
« no previous file with comments | « remoting/host/event_executor.h ('k') | remoting/host/event_executor_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <set> 7 #include <set>
8 8
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/XF86keysym.h> 10 #include <X11/XF86keysym.h>
11 #include <X11/keysym.h> 11 #include <X11/keysym.h>
12 #include <X11/extensions/XTest.h> 12 #include <X11/extensions/XTest.h>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/message_loop.h" 18 #include "base/message_loop.h"
19 #include "remoting/proto/internal.pb.h" 19 #include "remoting/proto/internal.pb.h"
20 20
21 namespace remoting { 21 namespace remoting {
22 22
23 using protocol::ClipboardEvent;
24 using protocol::KeyEvent;
23 using protocol::MouseEvent; 25 using protocol::MouseEvent;
24 using protocol::KeyEvent;
25 26
26 namespace { 27 namespace {
27 28
28 // USB to XKB keycode map table. 29 // USB to XKB keycode map table.
29 #define USB_KEYMAP(usb, xkb, win, mac) {usb, xkb} 30 #define USB_KEYMAP(usb, xkb, win, mac) {usb, xkb}
30 #include "remoting/host/usb_keycode_map.h" 31 #include "remoting/host/usb_keycode_map.h"
31 32
32 // A class to generate events on Linux. 33 // A class to generate events on Linux.
33 class EventExecutorLinux : public EventExecutor { 34 class EventExecutorLinux : public EventExecutor {
34 public: 35 public:
35 EventExecutorLinux(MessageLoop* message_loop, Capturer* capturer); 36 EventExecutorLinux(MessageLoop* message_loop, Capturer* capturer);
36 virtual ~EventExecutorLinux(); 37 virtual ~EventExecutorLinux();
37 38
38 bool Init(); 39 bool Init();
39 40
41 // Clipboard stub interface.
42 virtual void InjectClipboardEvent(const ClipboardEvent& event)
43 OVERRIDE;
44
45 // InputStub interface.
40 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; 46 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE;
41 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; 47 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE;
42 48
43 private: 49 private:
44 // |mode| is one of the AutoRepeatModeOn, AutoRepeatModeOff, 50 // |mode| is one of the AutoRepeatModeOn, AutoRepeatModeOff,
45 // AutoRepeatModeDefault constants defined by the XChangeKeyboardControl() 51 // AutoRepeatModeDefault constants defined by the XChangeKeyboardControl()
46 // API. 52 // API.
47 void SetAutoRepeatForKey(int keycode, int mode); 53 void SetAutoRepeatForKey(int keycode, int mode);
48 void InjectScrollWheelClicks(int button, int count); 54 void InjectScrollWheelClicks(int button, int count);
49 55
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if (!XGetWindowAttributes(display_, root_window_, &root_attr)) { 313 if (!XGetWindowAttributes(display_, root_window_, &root_attr)) {
308 LOG(ERROR) << "Unable to get window attributes"; 314 LOG(ERROR) << "Unable to get window attributes";
309 return false; 315 return false;
310 } 316 }
311 317
312 width_ = root_attr.width; 318 width_ = root_attr.width;
313 height_ = root_attr.height; 319 height_ = root_attr.height;
314 return true; 320 return true;
315 } 321 }
316 322
323 void EventExecutorLinux::InjectClipboardEvent(const ClipboardEvent& event) {
324 // TODO(simonmorris): Implement clipboard injection.
325 }
326
317 void EventExecutorLinux::InjectKeyEvent(const KeyEvent& event) { 327 void EventExecutorLinux::InjectKeyEvent(const KeyEvent& event) {
318 if (MessageLoop::current() != message_loop_) { 328 if (MessageLoop::current() != message_loop_) {
319 message_loop_->PostTask( 329 message_loop_->PostTask(
320 FROM_HERE, 330 FROM_HERE,
321 base::Bind(&EventExecutorLinux::InjectKeyEvent, base::Unretained(this), 331 base::Bind(&EventExecutorLinux::InjectKeyEvent, base::Unretained(this),
322 event)); 332 event));
323 return; 333 return;
324 } 334 }
325 335
326 int keycode = 0; 336 int keycode = 0;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 456 }
447 if (event.has_wheel_offset_x() && event.wheel_offset_x() != 0) { 457 if (event.has_wheel_offset_x() && event.wheel_offset_x() != 0) {
448 int dx = event.wheel_offset_x(); 458 int dx = event.wheel_offset_x();
449 InjectScrollWheelClicks(HorizontalScrollWheelToX11ButtonNumber(dx), 459 InjectScrollWheelClicks(HorizontalScrollWheelToX11ButtonNumber(dx),
450 abs(dx)); 460 abs(dx));
451 } 461 }
452 } 462 }
453 463
454 } // namespace 464 } // namespace
455 465
456 scoped_ptr<protocol::InputStub> EventExecutor::Create(MessageLoop* message_loop, 466 scoped_ptr<protocol::HostEventStub> EventExecutor::Create(
457 Capturer* capturer) { 467 MessageLoop* message_loop, Capturer* capturer) {
458 scoped_ptr<EventExecutorLinux> executor( 468 scoped_ptr<EventExecutorLinux> executor(
459 new EventExecutorLinux(message_loop, capturer)); 469 new EventExecutorLinux(message_loop, capturer));
460 if (!executor->Init()) { 470 if (!executor->Init()) {
461 executor.reset(NULL); 471 executor.reset(NULL);
462 } 472 }
463 return executor.PassAs<protocol::InputStub>(); 473 return executor.PassAs<protocol::HostEventStub>();
464 } 474 }
465 475
466 } // namespace remoting 476 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/event_executor.h ('k') | remoting/host/event_executor_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698