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

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: Include SkTypes.h before SkSize.h to fix win build. 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
« no previous file with comments | « remoting/client/mouse_input_filter.h ('k') | remoting/client/plugin/chromoting_instance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..49e33a858ceba83b901808fbb73112e0cd562e30
--- /dev/null
+++ b/remoting/client/mouse_input_filter.cc
@@ -0,0 +1,49 @@
+// 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) {
+ 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()) {
+ int x = (out_event.x() * output_size_.width()) / input_size_.width();
+ out_event.set_x(std::max(0, std::min(output_size_.width() - 1, x)));
+ }
+ if (out_event.has_y()) {
+ int y = (out_event.y() * output_size_.height()) / input_size_.height();
+ out_event.set_y(std::max(0, std::min(output_size_.height() - 1, y)));
+ }
+
+ input_stub_->InjectMouseEvent(out_event);
+}
+
+void MouseInputFilter::set_input_size(const SkISize& size) {
+ input_size_ = size;
+}
+
+void MouseInputFilter::set_output_size(const SkISize& size) {
+ output_size_ = size;
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/client/mouse_input_filter.h ('k') | remoting/client/plugin/chromoting_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698