OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_AURA_WINDOW_TARGETER_H_ | 5 #ifndef UI_AURA_WINDOW_TARGETER_H_ |
6 #define UI_AURA_WINDOW_TARGETER_H_ | 6 #define UI_AURA_WINDOW_TARGETER_H_ |
7 | 7 |
| 8 #include "base/macros.h" |
8 #include "ui/aura/aura_export.h" | 9 #include "ui/aura/aura_export.h" |
9 #include "ui/events/event_targeter.h" | 10 #include "ui/events/event_targeter.h" |
10 | 11 |
| 12 namespace ui { |
| 13 class KeyEvent; |
| 14 class LocatedEvent; |
| 15 } // namespace ui |
| 16 |
11 namespace aura { | 17 namespace aura { |
12 | 18 |
13 class Window; | 19 class Window; |
14 | 20 |
15 class AURA_EXPORT WindowTargeter : public ui::EventTargeter { | 21 class AURA_EXPORT WindowTargeter : public ui::EventTargeter { |
16 public: | 22 public: |
17 WindowTargeter(); | 23 WindowTargeter(); |
18 ~WindowTargeter() override; | 24 ~WindowTargeter() override; |
19 | 25 |
| 26 // Returns true if |window| or one of its descendants can be a target of |
| 27 // |event|. This requires that |window| and its descendants are not |
| 28 // prohibited from accepting the event, and that the event is within an |
| 29 // actionable region of the target's bounds. Note that the location etc. of |
| 30 // |event| is in |window|'s parent's coordinate system. |
| 31 virtual bool SubtreeShouldBeExploredForEvent(Window* window, |
| 32 const ui::LocatedEvent& event); |
| 33 |
20 protected: | 34 protected: |
| 35 // Same as FindTargetForEvent(), but used for positional events. The location |
| 36 // etc. of |event| are in |root|'s coordinate system. When finding the target |
| 37 // for the event, the targeter can mutate the |event| (e.g. change the |
| 38 // coordinate to be in the returned target's coordinate system) so that it can |
| 39 // be dispatched to the target without any further modification. |
| 40 virtual Window* FindTargetForLocatedEvent(Window* window, |
| 41 ui::LocatedEvent* event); |
| 42 |
| 43 // Returns false if neither |window| nor any of its descendants are allowed |
| 44 // to accept |event| for reasons unrelated to the event's location or the |
| 45 // target's bounds. For example, overrides of this function may consider |
| 46 // attributes such as the visibility or enabledness of |window|. Note that |
| 47 // the location etc. of |event| is in |window|'s parent's coordinate system. |
| 48 virtual bool SubtreeCanAcceptEvent(Window* window, |
| 49 const ui::LocatedEvent& event) const; |
| 50 |
| 51 // Returns whether the location of the event is in an actionable region of the |
| 52 // target. Note that the location etc. of |event| is in the |window|'s |
| 53 // parent's coordinate system. |
| 54 virtual bool EventLocationInsideBounds(Window* target, |
| 55 const ui::LocatedEvent& event) const; |
| 56 |
21 // ui::EventTargeter: | 57 // ui::EventTargeter: |
22 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, | 58 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, |
23 ui::Event* event) override; | 59 ui::Event* event) override; |
24 ui::EventTarget* FindTargetForLocatedEvent(ui::EventTarget* root, | 60 ui::EventTarget* FindNextBestTarget(ui::EventTarget* previous_target, |
25 ui::LocatedEvent* event) override; | 61 ui::Event* event) override; |
26 bool SubtreeCanAcceptEvent(ui::EventTarget* target, | |
27 const ui::LocatedEvent& event) const override; | |
28 bool EventLocationInsideBounds(ui::EventTarget* target, | |
29 const ui::LocatedEvent& event) const override; | |
30 | 62 |
31 private: | 63 private: |
32 Window* FindTargetForKeyEvent(Window* root_window, | 64 Window* FindTargetForKeyEvent(Window* root_window, const ui::KeyEvent& event); |
33 const ui::KeyEvent& event); | 65 Window* FindTargetForNonKeyEvent(Window* root_window, ui::Event* event); |
34 Window* FindTargetInRootWindow(Window* root_window, | 66 Window* FindTargetInRootWindow(Window* root_window, |
35 const ui::LocatedEvent& event); | 67 const ui::LocatedEvent& event); |
| 68 Window* FindTargetForLocatedEventRecursively(Window* root_window, |
| 69 ui::LocatedEvent* event); |
36 | 70 |
37 DISALLOW_COPY_AND_ASSIGN(WindowTargeter); | 71 DISALLOW_COPY_AND_ASSIGN(WindowTargeter); |
38 }; | 72 }; |
39 | 73 |
40 } // namespace aura | 74 } // namespace aura |
41 | 75 |
42 #endif // UI_AURA_WINDOW_TARGETER_H_ | 76 #endif // UI_AURA_WINDOW_TARGETER_H_ |
OLD | NEW |