Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / remoting / client / touch_input_scaler.h
blobb9c93e8f12eea1b53ae8d37fea852e2d66376695
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef REMOTING_CLIENT_TOUCH_INPUT_SCALER_H_
6 #define REMOTING_CLIENT_TOUCH_INPUT_SCALER_H_
8 #include "remoting/protocol/input_filter.h"
9 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
11 namespace remoting {
13 namespace protocol {
14 class TouchEvent;
15 } // namespace protocol
17 // Scales the touch input coordinates to host coordinates and clamps so
18 // that the values do not go outside the remote desktop.
19 // Also resizes the touch size.
20 class TouchInputScaler : public protocol::InputFilter {
21 public:
22 TouchInputScaler() = default;
23 explicit TouchInputScaler(InputStub* input_stub);
24 ~TouchInputScaler() override;
26 // Set input and output desktop sizes.
27 void set_input_size(const webrtc::DesktopSize& size) {
28 input_size_.set(size.width() - 1, size.height() - 1);
30 void set_output_size(const webrtc::DesktopSize& size) {
31 output_size_.set(size.width() - 1, size.height() - 1);
34 // protocol::InputStub interface.
35 void InjectTouchEvent(const protocol::TouchEvent& event) override;
37 private:
38 // Sizes for scaling and clamping coordinates and sizes.
39 // These hold the max-X,Y coordinates and not the actual width and height.
40 webrtc::DesktopSize input_size_;
41 webrtc::DesktopSize output_size_;
43 DISALLOW_COPY_AND_ASSIGN(TouchInputScaler);
46 } // namespace remoting
48 #endif // REMOTING_CLIENT_TOUCH_INPUT_SCALER_H_