Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Unified Diff: remoting/client/mouse_input_filter.cc

Issue 8985007: Refactoring of the client-side input pipeline and scaling dimension management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/client/mouse_input_filter.cc
diff --git a/remoting/client/mouse_input_filter.cc b/remoting/client/mouse_input_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e12ea49ab24325bb36c3d25d39fc56d06573ab36
--- /dev/null
+++ b/remoting/client/mouse_input_filter.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/client/mouse_input_filter.h"
+
+#include "remoting/proto/event.pb.h"
+
+namespace remoting {
+
+MouseInputFilter::MouseInputFilter(protocol::InputStub* input_stub)
+ : input_stub_(input_stub)
+{
Sergey Ulanov 2011/12/20 00:05:35 Here and in all other methods: { should not be wra
Wez 2011/12/20 07:14:14 Done.
Wez 2011/12/20 07:14:14 Done.
+ input_size_.setEmpty();
+ output_size_.setEmpty();
+}
+
+MouseInputFilter::~MouseInputFilter()
+{
+}
+
+void MouseInputFilter::InjectKeyEvent(const protocol::KeyEvent& event)
+{
+ input_stub_->InjectKeyEvent(event);
+}
+
+void MouseInputFilter::InjectMouseEvent(const protocol::MouseEvent& event)
+{
+ if (input_size_.isZero() || output_size_.isZero())
+ return;
+
+ protocol::MouseEvent out_event(event);
+ if (out_event.has_x()) {
+ out_event.set_x((out_event.x() * output_size_.width()) /
Sergey Ulanov 2011/12/20 00:05:35 I think this code would be more readable if you de
Wez 2011/12/20 07:14:14 Performance shouldn't be affected, since x() and s
+ input_size_.width());
+ out_event.set_x(std::max(0, std::min(output_size_.width()-1,
Sergey Ulanov 2011/12/20 00:05:35 spaces around -
Wez 2011/12/20 07:14:14 Done.
+ out_event.x())));
+ }
+ if (out_event.has_y()) {
+ out_event.set_y((out_event.y() * output_size_.height()) /
+ input_size_.height());
+ out_event.set_y(std::max(0, std::min(output_size_.height()-1,
+ out_event.y())));
+ }
+
+ input_stub_->InjectMouseEvent(out_event);
+}
+
+void MouseInputFilter::SetInputDimensions(const SkISize& size)
+{
+ input_size_ = size;
+}
+
+void MouseInputFilter::SetOutputDimensions(const SkISize& size)
+{
+ output_size_ = size;
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698