summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-10 03:30:19 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-10 03:30:19 +0000
commit4fe827a4470d67eb2e9c6b71f3f60580a33cc8a4 (patch)
treed3093653f373c963c026809c352d96f202df0724
parent7103f820b58e3f2a18a96b52c302444e1be35082 (diff)
downloadchromium_src-4fe827a4470d67eb2e9c6b71f3f60580a33cc8a4.zip
chromium_src-4fe827a4470d67eb2e9c6b71f3f60580a33cc8a4.tar.gz
chromium_src-4fe827a4470d67eb2e9c6b71f3f60580a33cc8a4.tar.bz2
Make floor-control more robust.
Check all injected mouse positions, not just the first one, to deal with possibility that mouse-injection API might fail. Also rename recent_remote_mouse_positions_ to injected_mouse_positions_ to emphasize these are the events that were (attempted to be) injected into the host. BUG=None TEST=Use buggy Mac client to send invalid mouse position to Linux host (move mouse off-screen. Review URL: http://codereview.chromium.org/7604007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96124 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/host/client_session.cc26
-rw-r--r--remoting/host/client_session.h7
2 files changed, 26 insertions, 7 deletions
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index 16048bf8..19c3d36 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -4,6 +4,8 @@
#include "remoting/host/client_session.h"
+#include <algorithm>
+
#include "base/task.h"
#include "remoting/host/user_authenticator.h"
#include "remoting/proto/auth.pb.h"
@@ -94,9 +96,10 @@ void ClientSession::InjectMouseEvent(const protocol::MouseEvent* event,
}
if (event->has_x() && event->has_y()) {
gfx::Point pos(event->x(), event->y());
- recent_remote_mouse_positions_.push_back(pos);
- if (recent_remote_mouse_positions_.size() > kNumRemoteMousePositions) {
- recent_remote_mouse_positions_.pop_front();
+ injected_mouse_positions_.push_back(pos);
+ if (injected_mouse_positions_.size() > kNumRemoteMousePositions) {
+ VLOG(1) << "Injected mouse positions queue full.";
+ injected_mouse_positions_.pop_front();
}
}
input_stub_->InjectMouseEvent(event, done_runner.Release());
@@ -113,9 +116,20 @@ void ClientSession::LocalMouseMoved(const gfx::Point& mouse_pos) {
// If this is a genuine local input event (rather than an echo of a remote
// input event that we've just injected), then ignore remote inputs for a
// short time.
- if (!recent_remote_mouse_positions_.empty() &&
- mouse_pos == *recent_remote_mouse_positions_.begin()) {
- recent_remote_mouse_positions_.pop_front();
+ std::list<gfx::Point>::iterator found_position =
+ std::find(injected_mouse_positions_.begin(),
+ injected_mouse_positions_.end(), mouse_pos);
+ if (found_position != injected_mouse_positions_.end()) {
+ // Remove it from the list, and any positions that were added before it,
+ // if any. This is because the local input monitor is assumed to receive
+ // injected mouse position events in the order in which they were injected
+ // (if at all). If the position is found somewhere other than the front of
+ // the queue, this would be because the earlier positions weren't
+ // successfully injected (or the local input monitor might have skipped over
+ // some positions), and not because the events were out-of-sequence. These
+ // spurious positions should therefore be discarded.
+ injected_mouse_positions_.erase(injected_mouse_positions_.begin(),
+ ++found_position);
} else {
latest_local_input_time_ = base::Time::Now();
}
diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h
index dded94a..b8339fb 100644
--- a/remoting/host/client_session.h
+++ b/remoting/host/client_session.h
@@ -113,7 +113,12 @@ class ClientSession : public protocol::HostStub,
// State to control remote input blocking while the local pointer is in use.
uint32 remote_mouse_button_state_;
- std::list<gfx::Point> recent_remote_mouse_positions_;
+
+ // Queue of recently-injected mouse positions. This is used to detect whether
+ // mouse events from the local input monitor are echoes of injected positions,
+ // or genuine mouse movements of a local input device.
+ std::list<gfx::Point> injected_mouse_positions_;
+
base::Time latest_local_input_time_;
std::set<int> pressed_keys_;