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 #ifndef REMOTING_HOST_REMOTE_INPUT_FILTER_H_ | 5 #ifndef REMOTING_HOST_REMOTE_INPUT_FILTER_H_ |
6 #define REMOTING_HOST_REMOTE_INPUT_FILTER_H_ | 6 #define REMOTING_HOST_REMOTE_INPUT_FILTER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "remoting/protocol/input_event_tracker.h" | 13 #include "remoting/protocol/input_event_tracker.h" |
14 #include "remoting/protocol/input_stub.h" | 14 #include "remoting/protocol/input_stub.h" |
15 #include "third_party/skia/include/core/SkPoint.h" | |
16 | 15 |
17 namespace remoting { | 16 namespace remoting { |
18 | 17 |
19 // Filtering InputStub that filters remotely-injected input if it has been | 18 // Filtering InputStub that filters remotely-injected input if it has been |
20 // notified of local input recently. | 19 // notified of local input recently. |
21 class RemoteInputFilter : public protocol::InputStub { | 20 class RemoteInputFilter : public protocol::InputStub { |
22 public: | 21 public: |
23 // Creates a filter forwarding events to the specified InputEventTracker. | 22 // Creates a filter forwarding events to the specified InputEventTracker. |
24 // The filter needs a tracker to release buttons & keys when blocking input. | 23 // The filter needs a tracker to release buttons & keys when blocking input. |
25 explicit RemoteInputFilter(protocol::InputEventTracker* event_tracker); | 24 explicit RemoteInputFilter(protocol::InputEventTracker* event_tracker); |
26 virtual ~RemoteInputFilter(); | 25 virtual ~RemoteInputFilter(); |
27 | 26 |
28 // Informs the filter that local mouse activity has been detected. If the | 27 // Informs the filter that local mouse activity has been detected. If the |
29 // activity does not match events we injected then we assume that it is local, | 28 // activity does not match events we injected then we assume that it is local, |
30 // and block remote input for a short while. | 29 // and block remote input for a short while. |
31 void LocalMouseMoved(const SkIPoint& mouse_pos); | 30 void LocalMouseMoved(const webrtc::DesktopVector& mouse_pos); |
32 | 31 |
33 // Informs the filter that injecting input causes an echo. | 32 // Informs the filter that injecting input causes an echo. |
34 void SetExpectLocalEcho(bool expect_local_echo); | 33 void SetExpectLocalEcho(bool expect_local_echo); |
35 | 34 |
36 // InputStub overrides. | 35 // InputStub overrides. |
37 virtual void InjectKeyEvent(const protocol::KeyEvent& event) OVERRIDE; | 36 virtual void InjectKeyEvent(const protocol::KeyEvent& event) OVERRIDE; |
38 virtual void InjectMouseEvent(const protocol::MouseEvent& event) OVERRIDE; | 37 virtual void InjectMouseEvent(const protocol::MouseEvent& event) OVERRIDE; |
39 | 38 |
40 private: | 39 private: |
41 bool ShouldIgnoreInput() const; | 40 bool ShouldIgnoreInput() const; |
42 | 41 |
43 protocol::InputEventTracker* event_tracker_; | 42 protocol::InputEventTracker* event_tracker_; |
44 | 43 |
45 // Queue of recently-injected mouse positions used to distinguish echoes of | 44 // Queue of recently-injected mouse positions used to distinguish echoes of |
46 // injected events from movements from a local input device. | 45 // injected events from movements from a local input device. |
47 std::list<SkIPoint> injected_mouse_positions_; | 46 std::list<webrtc::DesktopVector> injected_mouse_positions_; |
48 | 47 |
49 // Time at which local input events were most recently observed. | 48 // Time at which local input events were most recently observed. |
50 base::TimeTicks latest_local_input_time_; | 49 base::TimeTicks latest_local_input_time_; |
51 | 50 |
52 // If |true| than the filter assumes that injecting input causes an echo. | 51 // If |true| than the filter assumes that injecting input causes an echo. |
53 bool expect_local_echo_; | 52 bool expect_local_echo_; |
54 | 53 |
55 DISALLOW_COPY_AND_ASSIGN(RemoteInputFilter); | 54 DISALLOW_COPY_AND_ASSIGN(RemoteInputFilter); |
56 }; | 55 }; |
57 | 56 |
58 } // namespace remoting | 57 } // namespace remoting |
59 | 58 |
60 #endif // REMOTING_HOST_REMOTE_INPUT_FILTER_H_ | 59 #endif // REMOTING_HOST_REMOTE_INPUT_FILTER_H_ |
OLD | NEW |