1 // Copyright 2017 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.
4 
5 #ifndef REMOTING_CLIENT_INPUT_DIRECT_TOUCH_INPUT_STRATEGY_H_
6 #define REMOTING_CLIENT_INPUT_DIRECT_TOUCH_INPUT_STRATEGY_H_
7 
8 #include "remoting/client/input/touch_input_strategy.h"
9 
10 namespace remoting {
11 
12 // This strategy directly translates all operations on the OpenGL view into
13 // corresponding operations on the desktop. It doesn't maintain the cursor
14 // positions separately -- the positions come from the location of the touch.
15 class DirectTouchInputStrategy : public TouchInputStrategy {
16  public:
17   DirectTouchInputStrategy();
18   ~DirectTouchInputStrategy() override;
19 
20   // TouchInputStrategy overrides.
21 
22   void HandleZoom(const ViewMatrix::Point& pivot,
23                   float scale,
24                   DesktopViewport* viewport) override;
25 
26   bool HandlePan(const ViewMatrix::Vector2D& translation,
27                  Gesture simultaneous_gesture,
28                  DesktopViewport* viewport) override;
29 
30   bool TrackTouchInput(const ViewMatrix::Point& touch_point,
31                        const DesktopViewport& viewport) override;
32 
33   ViewMatrix::Point GetCursorPosition() const override;
34 
35   void FocusViewportOnCursor(DesktopViewport* viewport) const override;
36 
37   ViewMatrix::Vector2D MapScreenVectorToDesktop(
38       const ViewMatrix::Vector2D& delta,
39       const DesktopViewport& viewport) const override;
40 
41   float GetFeedbackRadius(TouchFeedbackType type) const override;
42 
43   bool IsCursorVisible() const override;
44 
45  private:
46   ViewMatrix::Point cursor_position_{0.f, 0.f};
47 
48   // TouchInputStrategy is neither copyable nor movable.
49   DirectTouchInputStrategy(const DirectTouchInputStrategy&) = delete;
50   DirectTouchInputStrategy& operator=(const DirectTouchInputStrategy&) = delete;
51 };
52 
53 }  // namespace remoting
54 #endif  // REMOTING_CLIENT_INPUT_DIRECT_TOUCH_INPUT_STRATEGY_H_
55