blob: 3549e2567db04560ef5696310e54633643378398 [file] [log] [blame]
Avi Drissmand6cdf9b2022-09-15 19:52:531// Copyright 2017 The Chromium Authors
yuweihd980e962017-05-09 03:53:052// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Lei Zhang8232b342021-04-21 20:15:365#ifndef REMOTING_CLIENT_INPUT_TOUCH_INPUT_STRATEGY_H_
6#define REMOTING_CLIENT_INPUT_TOUCH_INPUT_STRATEGY_H_
yuweihd980e962017-05-09 03:53:057
yuweih7fbc8052017-05-17 05:23:498#include "remoting/client/ui/view_matrix.h"
9
yuweihd980e962017-05-09 03:53:0510namespace remoting {
11
12class DesktopViewport;
13
14// This is an interface used by GestureInterpreter to customize the way gestures
15// are handled.
nicholssdf09b282017-05-26 20:08:1416class TouchInputStrategy {
yuweihd980e962017-05-09 03:53:0517 public:
nicholssdf09b282017-05-26 20:08:1418 enum TouchFeedbackType {
yuweih7fbc8052017-05-17 05:23:4919 TAP_FEEDBACK,
yuweihe1bd6ca2017-05-19 01:22:4520 DRAG_FEEDBACK,
21 };
22
23 enum Gesture {
24 NONE,
25 ZOOM,
26 DRAG,
yuweih7fbc8052017-05-17 05:23:4927 };
28
nicholssdf09b282017-05-26 20:08:1429 virtual ~TouchInputStrategy() {}
yuweihd980e962017-05-09 03:53:0530
yuweihe1bd6ca2017-05-19 01:22:4531 // Called when the GestureInterpreter receives a zoom gesture. The
yuweihd980e962017-05-09 03:53:0532 // implementation is responsible for modifying the viewport and observing the
33 // change.
yuweihe1bd6ca2017-05-19 01:22:4534 virtual void HandleZoom(const ViewMatrix::Point& pivot,
35 float scale,
36 DesktopViewport* viewport) = 0;
yuweihd980e962017-05-09 03:53:0537
38 // Called when the GestureInterpreter receives a pan gesture. The
39 // implementation is responsible for modifying the viewport and observing the
40 // change.
yuweihe1bd6ca2017-05-19 01:22:4541 // simultaneous_gesture: Gesture that is simultaneously in progress.
42 // Returns true if this changes the cursor position.
43 virtual bool HandlePan(const ViewMatrix::Vector2D& translation,
44 Gesture simultaneous_gesture,
yuweihd980e962017-05-09 03:53:0545 DesktopViewport* viewport) = 0;
46
yuweih7fbc8052017-05-17 05:23:4947 // Called when a touch input (which will end up injecting a mouse event at
48 // certain position in the host) is done at |touch_point|.
49 // The implementation should move the cursor to proper position.
yuweihb932f1d2017-05-23 21:18:5250 //
51 // Returns true if |touch_point| is a valid input, false otherwise. If the
52 // input is not valid, the implementation should not change its cursor
53 // position.
54 virtual bool TrackTouchInput(const ViewMatrix::Point& touch_point,
yuweih7fbc8052017-05-17 05:23:4955 const DesktopViewport& viewport) = 0;
56
57 // Returns the current cursor position.
58 virtual ViewMatrix::Point GetCursorPosition() const = 0;
59
Yuwei Huangdd311f72017-08-21 18:55:1660 // Focuses the viewport on the cursor position if necessary.
61 virtual void FocusViewportOnCursor(DesktopViewport* viewport) const = 0;
62
yuweihf6db64d12017-05-17 06:34:3363 // Maps a vector (or movement) in the surface coordinate to the vector to be
64 // used on the desktop. For example it can be used to map a scroll gesture
65 // on the screen to change in mouse wheel position.
66 virtual ViewMatrix::Vector2D MapScreenVectorToDesktop(
67 const ViewMatrix::Vector2D& delta,
68 const DesktopViewport& viewport) const = 0;
69
yuweih7fbc8052017-05-17 05:23:4970 // Returns the maximum radius of the feedback animation on the surface's
71 // coordinate for the given input type. The feedback will then be shown on the
72 // cursor positions returned by GetCursorPosition(). Return 0 if no feedback
73 // should be shown.
nicholssdf09b282017-05-26 20:08:1474 virtual float GetFeedbackRadius(TouchFeedbackType type) const = 0;
yuweihd980e962017-05-09 03:53:0575
76 // Returns true if the input strategy maintains a visible cursor on the
77 // desktop.
78 virtual bool IsCursorVisible() const = 0;
79};
80
81} // namespace remoting
Lei Zhang8232b342021-04-21 20:15:3682#endif // REMOTING_CLIENT_INPUT_TOUCH_INPUT_STRATEGY_H_