OLD | NEW |
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/client_session.h" | 5 #include "remoting/host/client_session.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "remoting/host/capturer.h" | 10 #include "remoting/host/capturer.h" |
11 #include "remoting/proto/event.pb.h" | 11 #include "remoting/proto/event.pb.h" |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 | 14 |
15 using protocol::KeyEvent; | |
16 using protocol::MouseEvent; | |
17 | |
18 ClientSession::ClientSession( | 15 ClientSession::ClientSession( |
19 EventHandler* event_handler, | 16 EventHandler* event_handler, |
20 scoped_ptr<protocol::ConnectionToClient> connection, | 17 scoped_ptr<protocol::ConnectionToClient> connection, |
21 protocol::HostEventStub* host_event_stub, | 18 protocol::HostEventStub* host_event_stub, |
22 Capturer* capturer) | 19 Capturer* capturer) |
23 : event_handler_(event_handler), | 20 : event_handler_(event_handler), |
24 connection_(connection.Pass()), | 21 connection_(connection.Pass()), |
25 client_jid_(connection_->session()->jid()), | 22 client_jid_(connection_->session()->jid()), |
26 host_event_stub_(host_event_stub), | 23 host_event_stub_(host_event_stub), |
27 input_tracker_(host_event_stub), | 24 input_tracker_(host_event_stub), |
(...skipping 19 matching lines...) Expand all Loading... |
47 // TODO(wez): Disable clipboard in both directions on local activity, and | 44 // TODO(wez): Disable clipboard in both directions on local activity, and |
48 // replace these tests with a HostInputFilter (or ClipboardFilter). | 45 // replace these tests with a HostInputFilter (or ClipboardFilter). |
49 if (auth_input_filter_.input_stub() == NULL) | 46 if (auth_input_filter_.input_stub() == NULL) |
50 return; | 47 return; |
51 if (disable_input_filter_.input_stub() == NULL) | 48 if (disable_input_filter_.input_stub() == NULL) |
52 return; | 49 return; |
53 | 50 |
54 host_event_stub_->InjectClipboardEvent(event); | 51 host_event_stub_->InjectClipboardEvent(event); |
55 } | 52 } |
56 | 53 |
57 void ClientSession::InjectKeyEvent(const KeyEvent& event) { | 54 void ClientSession::InjectKeyEvent(const protocol::KeyEvent& event) { |
58 DCHECK(CalledOnValidThread()); | 55 DCHECK(CalledOnValidThread()); |
59 auth_input_filter_.InjectKeyEvent(event); | 56 auth_input_filter_.InjectKeyEvent(event); |
60 } | 57 } |
61 | 58 |
62 void ClientSession::InjectMouseEvent(const MouseEvent& event) { | 59 void ClientSession::InjectMouseEvent(const protocol::MouseEvent& event) { |
63 DCHECK(CalledOnValidThread()); | 60 DCHECK(CalledOnValidThread()); |
64 | 61 |
65 MouseEvent event_to_inject = event; | 62 protocol::MouseEvent event_to_inject = event; |
66 if (event.has_x() && event.has_y()) { | 63 if (event.has_x() && event.has_y()) { |
67 // In case the client sends events with off-screen coordinates, modify | 64 // In case the client sends events with off-screen coordinates, modify |
68 // the event to lie within the current screen area. This is better than | 65 // the event to lie within the current screen area. This is better than |
69 // simply discarding the event, which might lose a button-up event at the | 66 // simply discarding the event, which might lose a button-up event at the |
70 // end of a drag'n'drop (or cause other related problems). | 67 // end of a drag'n'drop (or cause other related problems). |
71 SkIPoint pos(SkIPoint::Make(event.x(), event.y())); | 68 SkIPoint pos(SkIPoint::Make(event.x(), event.y())); |
72 const SkISize& screen = capturer_->size_most_recent(); | 69 const SkISize& screen = capturer_->size_most_recent(); |
73 pos.setX(std::max(0, std::min(screen.width() - 1, pos.x()))); | 70 pos.setX(std::max(0, std::min(screen.width() - 1, pos.x()))); |
74 pos.setY(std::max(0, std::min(screen.height() - 1, pos.y()))); | 71 pos.setY(std::max(0, std::min(screen.height() - 1, pos.y()))); |
75 event_to_inject.set_x(pos.x()); | 72 event_to_inject.set_x(pos.x()); |
76 event_to_inject.set_y(pos.y()); | 73 event_to_inject.set_y(pos.y()); |
77 } | 74 } |
78 auth_input_filter_.InjectMouseEvent(event_to_inject); | 75 auth_input_filter_.InjectMouseEvent(event_to_inject); |
79 } | 76 } |
80 | 77 |
| 78 void ClientSession::NotifyClientDimensions( |
| 79 const protocol::ClientDimensions& dimensions) { |
| 80 // TODO(wez): Use the dimensions, e.g. to resize the host desktop to match. |
| 81 } |
| 82 |
81 void ClientSession::OnConnectionAuthenticated( | 83 void ClientSession::OnConnectionAuthenticated( |
82 protocol::ConnectionToClient* connection) { | 84 protocol::ConnectionToClient* connection) { |
83 DCHECK(CalledOnValidThread()); | 85 DCHECK(CalledOnValidThread()); |
84 DCHECK_EQ(connection_.get(), connection); | 86 DCHECK_EQ(connection_.get(), connection); |
85 auth_input_filter_.set_input_stub(&disable_input_filter_); | 87 auth_input_filter_.set_input_stub(&disable_input_filter_); |
86 event_handler_->OnSessionAuthenticated(this); | 88 event_handler_->OnSessionAuthenticated(this); |
87 } | 89 } |
88 | 90 |
89 void ClientSession::OnConnectionChannelsConnected( | 91 void ClientSession::OnConnectionChannelsConnected( |
90 protocol::ConnectionToClient* connection) { | 92 protocol::ConnectionToClient* connection) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 147 |
146 if (disable_inputs) { | 148 if (disable_inputs) { |
147 disable_input_filter_.set_input_stub(NULL); | 149 disable_input_filter_.set_input_stub(NULL); |
148 input_tracker_.ReleaseAll(); | 150 input_tracker_.ReleaseAll(); |
149 } else { | 151 } else { |
150 disable_input_filter_.set_input_stub(&remote_input_filter_); | 152 disable_input_filter_.set_input_stub(&remote_input_filter_); |
151 } | 153 } |
152 } | 154 } |
153 | 155 |
154 } // namespace remoting | 156 } // namespace remoting |
OLD | NEW |