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

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

Issue 799233004: Add touch events to the protocol, the stub layer, and to the client plugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mac builds Created 5 years, 11 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
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/input_injector.h" 5 #include "remoting/host/input_injector.h"
6 6
7 #include <X11/extensions/XInput.h> 7 #include <X11/extensions/XInput.h>
8 #include <X11/extensions/XTest.h> 8 #include <X11/extensions/XTest.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/XKBlib.h> 10 #include <X11/XKBlib.h>
(...skipping 17 matching lines...) Expand all
28 #include "ui/events/keycodes/dom4/keycode_converter.h" 28 #include "ui/events/keycodes/dom4/keycode_converter.h"
29 29
30 namespace remoting { 30 namespace remoting {
31 31
32 namespace { 32 namespace {
33 33
34 using protocol::ClipboardEvent; 34 using protocol::ClipboardEvent;
35 using protocol::KeyEvent; 35 using protocol::KeyEvent;
36 using protocol::TextEvent; 36 using protocol::TextEvent;
37 using protocol::MouseEvent; 37 using protocol::MouseEvent;
38 using protocol::TouchEvent;
38 39
39 bool FindKeycodeForKeySym(Display* display, 40 bool FindKeycodeForKeySym(Display* display,
40 KeySym key_sym, 41 KeySym key_sym,
41 uint32_t* keycode, 42 uint32_t* keycode,
42 uint32_t* modifiers) { 43 uint32_t* modifiers) {
43 *keycode = XKeysymToKeycode(display, key_sym); 44 *keycode = XKeysymToKeycode(display, key_sym);
44 45
45 const uint32_t kModifiersToTry[] = { 46 const uint32_t kModifiersToTry[] = {
46 0, 47 0,
47 ShiftMask, 48 ShiftMask,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 100
100 bool Init(); 101 bool Init();
101 102
102 // Clipboard stub interface. 103 // Clipboard stub interface.
103 void InjectClipboardEvent(const ClipboardEvent& event) override; 104 void InjectClipboardEvent(const ClipboardEvent& event) override;
104 105
105 // InputStub interface. 106 // InputStub interface.
106 void InjectKeyEvent(const KeyEvent& event) override; 107 void InjectKeyEvent(const KeyEvent& event) override;
107 void InjectTextEvent(const TextEvent& event) override; 108 void InjectTextEvent(const TextEvent& event) override;
108 void InjectMouseEvent(const MouseEvent& event) override; 109 void InjectMouseEvent(const MouseEvent& event) override;
110 void InjectTouchEvent(const TouchEvent& event) override;
109 111
110 // InputInjector interface. 112 // InputInjector interface.
111 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; 113 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override;
112 114
113 private: 115 private:
114 // The actual implementation resides in InputInjectorX11::Core class. 116 // The actual implementation resides in InputInjectorX11::Core class.
115 class Core : public base::RefCountedThreadSafe<Core> { 117 class Core : public base::RefCountedThreadSafe<Core> {
116 public: 118 public:
117 explicit Core(scoped_refptr<base::SingleThreadTaskRunner> task_runner); 119 explicit Core(scoped_refptr<base::SingleThreadTaskRunner> task_runner);
118 120
119 bool Init(); 121 bool Init();
120 122
121 // Mirrors the ClipboardStub interface. 123 // Mirrors the ClipboardStub interface.
122 void InjectClipboardEvent(const ClipboardEvent& event); 124 void InjectClipboardEvent(const ClipboardEvent& event);
123 125
124 // Mirrors the InputStub interface. 126 // Mirrors the InputStub interface.
125 void InjectKeyEvent(const KeyEvent& event); 127 void InjectKeyEvent(const KeyEvent& event);
126 void InjectTextEvent(const TextEvent& event); 128 void InjectTextEvent(const TextEvent& event);
127 void InjectMouseEvent(const MouseEvent& event); 129 void InjectMouseEvent(const MouseEvent& event);
130 void InjectTouchEvent(const TouchEvent& event);
128 131
129 // Mirrors the InputInjector interface. 132 // Mirrors the InputInjector interface.
130 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard); 133 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard);
131 134
132 void Stop(); 135 void Stop();
133 136
134 private: 137 private:
135 friend class base::RefCountedThreadSafe<Core>; 138 friend class base::RefCountedThreadSafe<Core>;
136 virtual ~Core(); 139 virtual ~Core();
137 140
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 215 }
213 216
214 void InputInjectorX11::InjectTextEvent(const TextEvent& event) { 217 void InputInjectorX11::InjectTextEvent(const TextEvent& event) {
215 core_->InjectTextEvent(event); 218 core_->InjectTextEvent(event);
216 } 219 }
217 220
218 void InputInjectorX11::InjectMouseEvent(const MouseEvent& event) { 221 void InputInjectorX11::InjectMouseEvent(const MouseEvent& event) {
219 core_->InjectMouseEvent(event); 222 core_->InjectMouseEvent(event);
220 } 223 }
221 224
225 void InputInjectorX11::InjectTouchEvent(const TouchEvent& event) {
226 core_->InjectTouchEvent(event);
227 }
228
222 void InputInjectorX11::Start( 229 void InputInjectorX11::Start(
223 scoped_ptr<protocol::ClipboardStub> client_clipboard) { 230 scoped_ptr<protocol::ClipboardStub> client_clipboard) {
224 core_->Start(client_clipboard.Pass()); 231 core_->Start(client_clipboard.Pass());
225 } 232 }
226 233
227 InputInjectorX11::Core::Core( 234 InputInjectorX11::Core::Core(
228 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 235 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
229 : task_runner_(task_runner), 236 : task_runner_(task_runner),
230 latest_mouse_position_(-1, -1), 237 latest_mouse_position_(-1, -1),
231 wheel_ticks_x_(0.0f), 238 wheel_ticks_x_(0.0f),
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 359
353 XTestFakeKeyEvent(display_, keycode, True, CurrentTime); 360 XTestFakeKeyEvent(display_, keycode, True, CurrentTime);
354 XTestFakeKeyEvent(display_, keycode, False, CurrentTime); 361 XTestFakeKeyEvent(display_, keycode, False, CurrentTime);
355 362
356 XkbLockModifiers(display_, XkbUseCoreKbd, modifiers, 0); 363 XkbLockModifiers(display_, XkbUseCoreKbd, modifiers, 0);
357 } 364 }
358 365
359 XFlush(display_); 366 XFlush(display_);
360 } 367 }
361 368
369 void InputInjectorX11::Core::InjectTouchEvent(const TouchEvent& event) {
370 NOTIMPLEMENTED() << "Raw touch event injection not implemented.";
Wez 2015/01/21 03:08:37 nit: Why does this one get a message and the other
Rintaro Kuroiwa 2015/01/28 01:12:29 Oh I wanted to get Win, Mac, and CroS building and
371 return;
Wez 2015/01/21 03:08:37 ?
Rintaro Kuroiwa 2015/01/28 01:12:29 Not sure why I did this :P
372 }
373
362 InputInjectorX11::Core::~Core() { 374 InputInjectorX11::Core::~Core() {
363 CHECK(pressed_keys_.empty()); 375 CHECK(pressed_keys_.empty());
364 } 376 }
365 377
366 void InputInjectorX11::Core::InitClipboard() { 378 void InputInjectorX11::Core::InitClipboard() {
367 DCHECK(task_runner_->BelongsToCurrentThread()); 379 DCHECK(task_runner_->BelongsToCurrentThread());
368 clipboard_ = Clipboard::Create(); 380 clipboard_ = Clipboard::Create();
369 } 381 }
370 382
371 bool InputInjectorX11::Core::IsAutoRepeatEnabled() { 383 bool InputInjectorX11::Core::IsAutoRepeatEnabled() {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 639 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
628 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 640 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
629 scoped_ptr<InputInjectorX11> injector( 641 scoped_ptr<InputInjectorX11> injector(
630 new InputInjectorX11(main_task_runner)); 642 new InputInjectorX11(main_task_runner));
631 if (!injector->Init()) 643 if (!injector->Init())
632 return nullptr; 644 return nullptr;
633 return injector.Pass(); 645 return injector.Pass();
634 } 646 }
635 647
636 } // namespace remoting 648 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698