blob: 88d1048ca2d853e0c8c198a79bf3172238658766 [file] [log] [blame]
reveman90b85ed2015-12-10 02:39:331// 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.
4
5#ifndef COMPONENTS_EXO_TOUCH_H_
6#define COMPONENTS_EXO_TOUCH_H_
7
8#include <vector>
9
10#include "base/macros.h"
11#include "components/exo/surface_observer.h"
12#include "ui/events/event_handler.h"
denniskempin31a496e2016-12-17 00:20:5713#include "ui/gfx/geometry/point_f.h"
reveman90b85ed2015-12-10 02:39:3314
15namespace ui {
16class TouchEvent;
17}
18
19namespace exo {
20class TouchDelegate;
denniskempin31a496e2016-12-17 00:20:5721class TouchStylusDelegate;
reveman90b85ed2015-12-10 02:39:3322
23// This class implements a client touch device that represents one or more
24// touch devices.
25class Touch : public ui::EventHandler, public SurfaceObserver {
26 public:
27 explicit Touch(TouchDelegate* delegate);
28 ~Touch() override;
29
Alexandros Frantzisaed3360b2018-01-24 18:40:0430 TouchDelegate* delegate() const { return delegate_; }
31
denniskempin31a496e2016-12-17 00:20:5732 // Set delegate for stylus events.
33 void SetStylusDelegate(TouchStylusDelegate* delegate);
34 bool HasStylusDelegate() const;
35
reveman90b85ed2015-12-10 02:39:3336 // Overridden from ui::EventHandler:
37 void OnTouchEvent(ui::TouchEvent* event) override;
38
39 // Overridden from SurfaceObserver:
40 void OnSurfaceDestroying(Surface* surface) override;
41
42 private:
43 // Returns the effective target for |event|.
44 Surface* GetEffectiveTargetForEvent(ui::Event* event) const;
45
46 // The delegate instance that all events are dispatched to.
reveman2d3815d2016-06-26 20:13:2547 TouchDelegate* const delegate_;
reveman90b85ed2015-12-10 02:39:3348
denniskempin31a496e2016-12-17 00:20:5749 // The delegate instance that all stylus related events are dispatched to.
50 TouchStylusDelegate* stylus_delegate_ = nullptr;
51
reveman90b85ed2015-12-10 02:39:3352 // The current focus surface for the touch device.
reveman2d3815d2016-06-26 20:13:2553 Surface* focus_ = nullptr;
reveman90b85ed2015-12-10 02:39:3354
55 // Vector of touch points in focus surface.
56 std::vector<int> touch_points_;
57
58 DISALLOW_COPY_AND_ASSIGN(Touch);
59};
60
61} // namespace exo
62
63#endif // COMPONENTS_EXO_TOUCH_H_