OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_VIEWS_POINTER_WATCHER_H_ | 5 #ifndef UI_VIEWS_POINTER_WATCHER_H_ |
6 #define UI_VIEWS_POINTER_WATCHER_H_ | 6 #define UI_VIEWS_POINTER_WATCHER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "ui/views/views_export.h" | 9 #include "ui/views/views_export.h" |
10 | 10 |
11 namespace gfx { | 11 namespace gfx { |
12 class Point; | 12 class Point; |
13 } | 13 } |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 class PointerEvent; | 16 class PointerEvent; |
17 } | 17 } |
18 | 18 |
19 namespace views { | 19 namespace views { |
20 class Widget; | 20 class Widget; |
21 | 21 |
| 22 // When a PointerWatcher is added the types of events desired is specified by |
| 23 // way of PointerWatcherEventTypes. |
| 24 enum class PointerWatcherEventTypes { |
| 25 // The PointerWatcher is interested in press, release, capture and mouse |
| 26 // wheel. |
| 27 BASIC, |
| 28 // The PointerWatcher is interested in BASIC events, as well as move |
| 29 // events. |
| 30 MOVES, |
| 31 // The PointerWatcher is interested in MOVE events, as well as drag |
| 32 // events. |
| 33 DRAGS |
| 34 }; |
| 35 |
22 // An interface for read-only observation of pointer events (in particular, the | 36 // An interface for read-only observation of pointer events (in particular, the |
23 // events cannot be marked as handled). Only certain event types are supported. | 37 // events cannot be marked as handled). Only certain event types are supported. |
24 // The |target| is the top-level widget that will receive the event, if any. | 38 // The |target| is the top-level widget that will receive the event, if any. |
25 // To reduce IPC traffic from the window server, move events are not provided | 39 // To reduce IPC traffic from the window server, move events are not provided |
26 // unless the app specifically requests them. | 40 // unless the app specifically requests them. |
27 // NOTE: On mus this allows observation of events outside of windows owned | 41 // NOTE: On mus this allows observation of events outside of windows owned |
28 // by the current process, in which case the |target| will be null. On mus | 42 // by the current process, in which case the |target| will be null. On mus |
29 // event.target() is always null. | 43 // event.target() is always null. |
30 // NOTE: Mouse capture change events are sent through OnPointerEventObserved and | 44 // NOTE: Mouse capture change events are sent through OnPointerEventObserved and |
31 // its |target| is always null. | 45 // its |target| is always null. |
32 class VIEWS_EXPORT PointerWatcher { | 46 class VIEWS_EXPORT PointerWatcher { |
33 public: | 47 public: |
34 PointerWatcher() {} | 48 PointerWatcher() {} |
35 | 49 |
36 virtual void OnPointerEventObserved(const ui::PointerEvent& event, | 50 virtual void OnPointerEventObserved(const ui::PointerEvent& event, |
37 const gfx::Point& location_in_screen, | 51 const gfx::Point& location_in_screen, |
38 Widget* target) = 0; | 52 Widget* target) = 0; |
39 | 53 |
40 protected: | 54 protected: |
41 virtual ~PointerWatcher() {} | 55 virtual ~PointerWatcher() {} |
42 | 56 |
43 private: | 57 private: |
44 DISALLOW_COPY_AND_ASSIGN(PointerWatcher); | 58 DISALLOW_COPY_AND_ASSIGN(PointerWatcher); |
45 }; | 59 }; |
46 | 60 |
47 } // namespace views | 61 } // namespace views |
48 | 62 |
49 #endif // UI_VIEWS_POINTER_WATCHER_H_ | 63 #endif // UI_VIEWS_POINTER_WATCHER_H_ |
OLD | NEW |