reveman | 90b85ed | 2015-12-10 02:39:33 | [diff] [blame] | 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. |
| 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" |
denniskempin | 31a496e | 2016-12-17 00:20:57 | [diff] [blame] | 13 | #include "ui/gfx/geometry/point_f.h" |
reveman | 90b85ed | 2015-12-10 02:39:33 | [diff] [blame] | 14 | |
| 15 | namespace ui { |
| 16 | class TouchEvent; |
| 17 | } |
| 18 | |
| 19 | namespace exo { |
| 20 | class TouchDelegate; |
denniskempin | 31a496e | 2016-12-17 00:20:57 | [diff] [blame] | 21 | class TouchStylusDelegate; |
reveman | 90b85ed | 2015-12-10 02:39:33 | [diff] [blame] | 22 | |
| 23 | // This class implements a client touch device that represents one or more |
| 24 | // touch devices. |
| 25 | class Touch : public ui::EventHandler, public SurfaceObserver { |
| 26 | public: |
| 27 | explicit Touch(TouchDelegate* delegate); |
| 28 | ~Touch() override; |
| 29 | |
Alexandros Frantzis | aed3360b | 2018-01-24 18:40:04 | [diff] [blame^] | 30 | TouchDelegate* delegate() const { return delegate_; } |
| 31 | |
denniskempin | 31a496e | 2016-12-17 00:20:57 | [diff] [blame] | 32 | // Set delegate for stylus events. |
| 33 | void SetStylusDelegate(TouchStylusDelegate* delegate); |
| 34 | bool HasStylusDelegate() const; |
| 35 | |
reveman | 90b85ed | 2015-12-10 02:39:33 | [diff] [blame] | 36 | // 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. |
reveman | 2d3815d | 2016-06-26 20:13:25 | [diff] [blame] | 47 | TouchDelegate* const delegate_; |
reveman | 90b85ed | 2015-12-10 02:39:33 | [diff] [blame] | 48 | |
denniskempin | 31a496e | 2016-12-17 00:20:57 | [diff] [blame] | 49 | // The delegate instance that all stylus related events are dispatched to. |
| 50 | TouchStylusDelegate* stylus_delegate_ = nullptr; |
| 51 | |
reveman | 90b85ed | 2015-12-10 02:39:33 | [diff] [blame] | 52 | // The current focus surface for the touch device. |
reveman | 2d3815d | 2016-06-26 20:13:25 | [diff] [blame] | 53 | Surface* focus_ = nullptr; |
reveman | 90b85ed | 2015-12-10 02:39:33 | [diff] [blame] | 54 | |
| 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_ |