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/local_input_monitor.h" | 5 #include "remoting/host/local_input_monitor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
11 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
12 #include "remoting/host/chromeos/pixel_rotator.h" | |
12 #include "remoting/host/client_session_control.h" | 13 #include "remoting/host/client_session_control.h" |
13 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 14 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
14 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
15 #include "ui/events/event_utils.h" | 16 #include "ui/events/event_utils.h" |
16 #include "ui/events/keycodes/keyboard_codes.h" | 17 #include "ui/events/keycodes/keyboard_codes.h" |
17 #include "ui/events/platform/platform_event_observer.h" | 18 #include "ui/events/platform/platform_event_observer.h" |
18 #include "ui/events/platform/platform_event_source.h" | 19 #include "ui/events/platform/platform_event_source.h" |
19 | 20 |
20 namespace remoting { | 21 namespace remoting { |
21 | 22 |
(...skipping 23 matching lines...) Expand all Loading... | |
45 private: | 46 private: |
46 void HandleMouseMove(const ui::PlatformEvent& event); | 47 void HandleMouseMove(const ui::PlatformEvent& event); |
47 void HandleKeyPressed(const ui::PlatformEvent& event); | 48 void HandleKeyPressed(const ui::PlatformEvent& event); |
48 | 49 |
49 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | 50 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
50 | 51 |
51 // Points to the object receiving mouse event notifications and session | 52 // Points to the object receiving mouse event notifications and session |
52 // disconnect requests. Must be called on the |caller_task_runner_|. | 53 // disconnect requests. Must be called on the |caller_task_runner_|. |
53 base::WeakPtr<ClientSessionControl> client_session_control_; | 54 base::WeakPtr<ClientSessionControl> client_session_control_; |
54 | 55 |
56 // Rotate the local mouse positions appropriately based on the current | |
Wez
2014/12/06 01:55:17
nit: Used to rotate...
Here and elsewhere, does i
kelvinp
2014/12/08 18:41:44
Done. No, it doesn't translate AFAIK.
| |
57 // display rotation settings. | |
58 scoped_ptr<PixelRotator> rotator_; | |
59 | |
55 DISALLOW_COPY_AND_ASSIGN(Core); | 60 DISALLOW_COPY_AND_ASSIGN(Core); |
56 }; | 61 }; |
57 | 62 |
58 // Task runner on which ui::events are received. | 63 // Task runner on which ui::events are received. |
59 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; | 64 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; |
60 scoped_ptr<Core> core_; | 65 scoped_ptr<Core> core_; |
61 | 66 |
62 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorChromeos); | 67 DISALLOW_COPY_AND_ASSIGN(LocalInputMonitorChromeos); |
63 }; | 68 }; |
64 | 69 |
(...skipping 14 matching lines...) Expand all Loading... | |
79 LocalInputMonitorChromeos::Core::Core( | 84 LocalInputMonitorChromeos::Core::Core( |
80 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 85 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
81 base::WeakPtr<ClientSessionControl> client_session_control) | 86 base::WeakPtr<ClientSessionControl> client_session_control) |
82 : caller_task_runner_(caller_task_runner), | 87 : caller_task_runner_(caller_task_runner), |
83 client_session_control_(client_session_control) { | 88 client_session_control_(client_session_control) { |
84 DCHECK(client_session_control_.get()); | 89 DCHECK(client_session_control_.get()); |
85 } | 90 } |
86 | 91 |
87 void LocalInputMonitorChromeos::Core::Start() { | 92 void LocalInputMonitorChromeos::Core::Start() { |
88 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); | 93 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); |
94 rotator_.reset(new PixelRotator()); | |
89 } | 95 } |
90 | 96 |
91 LocalInputMonitorChromeos::Core::~Core() { | 97 LocalInputMonitorChromeos::Core::~Core() { |
92 ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this); | 98 ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this); |
93 } | 99 } |
94 | 100 |
95 void LocalInputMonitorChromeos::Core::WillProcessEvent( | 101 void LocalInputMonitorChromeos::Core::WillProcessEvent( |
96 const ui::PlatformEvent& event) { | 102 const ui::PlatformEvent& event) { |
97 // No need to handle this callback. | 103 // No need to handle this callback. |
98 } | 104 } |
99 | 105 |
100 void LocalInputMonitorChromeos::Core::DidProcessEvent( | 106 void LocalInputMonitorChromeos::Core::DidProcessEvent( |
101 const ui::PlatformEvent& event) { | 107 const ui::PlatformEvent& event) { |
102 ui::EventType type = ui::EventTypeFromNative(event); | 108 ui::EventType type = ui::EventTypeFromNative(event); |
103 if (type == ui::ET_MOUSE_MOVED) { | 109 if (type == ui::ET_MOUSE_MOVED) { |
104 HandleMouseMove(event); | 110 HandleMouseMove(event); |
105 } else if (type == ui::ET_KEY_PRESSED) { | 111 } else if (type == ui::ET_KEY_PRESSED) { |
106 HandleKeyPressed(event); | 112 HandleKeyPressed(event); |
107 } | 113 } |
108 } | 114 } |
109 | 115 |
110 void LocalInputMonitorChromeos::Core::HandleMouseMove( | 116 void LocalInputMonitorChromeos::Core::HandleMouseMove( |
111 const ui::PlatformEvent& event) { | 117 const ui::PlatformEvent& event) { |
112 gfx::Point mouse_position = ui::EventLocationFromNative(event); | 118 gfx::PointF mouse_position = ui::EventLocationFromNative(event); |
119 mouse_position = rotator_->FromScreenPixel(mouse_position); | |
120 | |
113 caller_task_runner_->PostTask( | 121 caller_task_runner_->PostTask( |
114 FROM_HERE, | 122 FROM_HERE, |
115 base::Bind( | 123 base::Bind( |
116 &ClientSessionControl::OnLocalMouseMoved, client_session_control_, | 124 &ClientSessionControl::OnLocalMouseMoved, client_session_control_, |
117 webrtc::DesktopVector(mouse_position.x(), mouse_position.y()))); | 125 webrtc::DesktopVector(mouse_position.x(), mouse_position.y()))); |
118 } | 126 } |
119 | 127 |
120 void LocalInputMonitorChromeos::Core::HandleKeyPressed( | 128 void LocalInputMonitorChromeos::Core::HandleKeyPressed( |
121 const ui::PlatformEvent& event) { | 129 const ui::PlatformEvent& event) { |
122 ui::KeyEvent key_event(event); | 130 ui::KeyEvent key_event(event); |
(...skipping 11 matching lines...) Expand all Loading... | |
134 scoped_ptr<LocalInputMonitor> LocalInputMonitor::Create( | 142 scoped_ptr<LocalInputMonitor> LocalInputMonitor::Create( |
135 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | 143 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, |
136 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 144 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
137 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 145 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
138 base::WeakPtr<ClientSessionControl> client_session_control) { | 146 base::WeakPtr<ClientSessionControl> client_session_control) { |
139 return make_scoped_ptr(new LocalInputMonitorChromeos( | 147 return make_scoped_ptr(new LocalInputMonitorChromeos( |
140 caller_task_runner, input_task_runner, client_session_control)); | 148 caller_task_runner, input_task_runner, client_session_control)); |
141 } | 149 } |
142 | 150 |
143 } // namespace remoting | 151 } // namespace remoting |
OLD | NEW |