OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/single_window_input_injector.h" | 5 #include "remoting/host/single_window_input_injector.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/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
11 #include "base/mac/scoped_cftyperef.h" | 11 #include "base/mac/scoped_cftyperef.h" |
12 #include "remoting/proto/event.pb.h" | 12 #include "remoting/proto/event.pb.h" |
13 #include "third_party/webrtc/modules/desktop_capture/mac/desktop_configuration.h
" | 13 #include "third_party/webrtc/modules/desktop_capture/mac/desktop_configuration.h
" |
14 | 14 |
15 namespace remoting { | 15 namespace remoting { |
16 | 16 |
17 using protocol::ClipboardEvent; | 17 using protocol::ClipboardEvent; |
18 using protocol::KeyEvent; | 18 using protocol::KeyEvent; |
19 using protocol::TextEvent; | 19 using protocol::TextEvent; |
20 using protocol::MouseEvent; | 20 using protocol::MouseEvent; |
| 21 using protocol::TouchEvent; |
21 | 22 |
22 class SingleWindowInputInjectorMac : public SingleWindowInputInjector { | 23 class SingleWindowInputInjectorMac : public SingleWindowInputInjector { |
23 public: | 24 public: |
24 SingleWindowInputInjectorMac( | 25 SingleWindowInputInjectorMac( |
25 webrtc::WindowId window_id, | 26 webrtc::WindowId window_id, |
26 scoped_ptr<InputInjector> input_injector); | 27 scoped_ptr<InputInjector> input_injector); |
27 ~SingleWindowInputInjectorMac() override; | 28 ~SingleWindowInputInjectorMac() override; |
28 | 29 |
29 // InputInjector interface. | 30 // InputInjector interface. |
30 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; | 31 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; |
31 void InjectKeyEvent(const KeyEvent& event) override; | 32 void InjectKeyEvent(const KeyEvent& event) override; |
32 void InjectTextEvent(const TextEvent& event) override; | 33 void InjectTextEvent(const TextEvent& event) override; |
33 void InjectMouseEvent(const MouseEvent& event) override; | 34 void InjectMouseEvent(const MouseEvent& event) override; |
| 35 void InjectTouchEvent(const TouchEvent& event) override; |
34 void InjectClipboardEvent(const ClipboardEvent& event) override; | 36 void InjectClipboardEvent(const ClipboardEvent& event) override; |
35 | 37 |
36 private: | 38 private: |
37 CGRect FindCGRectOfWindow(); | 39 CGRect FindCGRectOfWindow(); |
38 | 40 |
39 CGWindowID window_id_; | 41 CGWindowID window_id_; |
40 scoped_ptr<InputInjector> input_injector_; | 42 scoped_ptr<InputInjector> input_injector_; |
41 | 43 |
42 DISALLOW_COPY_AND_ASSIGN(SingleWindowInputInjectorMac); | 44 DISALLOW_COPY_AND_ASSIGN(SingleWindowInputInjectorMac); |
43 }; | 45 }; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Create a new event with coordinates that are in respect to the window. | 102 // Create a new event with coordinates that are in respect to the window. |
101 MouseEvent modified_event(event); | 103 MouseEvent modified_event(event); |
102 modified_event.set_x(event.x() + window_pos.x()); | 104 modified_event.set_x(event.x() + window_pos.x()); |
103 modified_event.set_y(event.y() + window_pos.y()); | 105 modified_event.set_y(event.y() + window_pos.y()); |
104 input_injector_->InjectMouseEvent(modified_event); | 106 input_injector_->InjectMouseEvent(modified_event); |
105 } else { | 107 } else { |
106 input_injector_->InjectMouseEvent(event); | 108 input_injector_->InjectMouseEvent(event); |
107 } | 109 } |
108 } | 110 } |
109 | 111 |
| 112 void SingleWindowInputInjectorMac::InjectTouchEvent(const TouchEvent& event) { |
| 113 NOTIMPLEMENTED(); |
| 114 } |
| 115 |
110 void SingleWindowInputInjectorMac::InjectClipboardEvent( | 116 void SingleWindowInputInjectorMac::InjectClipboardEvent( |
111 const ClipboardEvent& event) { | 117 const ClipboardEvent& event) { |
112 input_injector_->InjectClipboardEvent(event); | 118 input_injector_->InjectClipboardEvent(event); |
113 } | 119 } |
114 | 120 |
115 // This method finds the rectangle of the window we are streaming using | 121 // This method finds the rectangle of the window we are streaming using |
116 // |window_id_|. The InputInjector can then use this rectangle | 122 // |window_id_|. The InputInjector can then use this rectangle |
117 // to translate the input event to coordinates of the window rather | 123 // to translate the input event to coordinates of the window rather |
118 // than the screen. | 124 // than the screen. |
119 CGRect SingleWindowInputInjectorMac::FindCGRectOfWindow() { | 125 CGRect SingleWindowInputInjectorMac::FindCGRectOfWindow() { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 162 |
157 scoped_ptr<InputInjector> SingleWindowInputInjector::CreateForWindow( | 163 scoped_ptr<InputInjector> SingleWindowInputInjector::CreateForWindow( |
158 webrtc::WindowId window_id, | 164 webrtc::WindowId window_id, |
159 scoped_ptr<InputInjector> input_injector) { | 165 scoped_ptr<InputInjector> input_injector) { |
160 scoped_ptr<SingleWindowInputInjectorMac> injector( | 166 scoped_ptr<SingleWindowInputInjectorMac> injector( |
161 new SingleWindowInputInjectorMac(window_id, input_injector.Pass())); | 167 new SingleWindowInputInjectorMac(window_id, input_injector.Pass())); |
162 return injector.Pass(); | 168 return injector.Pass(); |
163 } | 169 } |
164 | 170 |
165 } // namespace remoting | 171 } // namespace remoting |
OLD | NEW |