Chromium Code Reviews| 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 |