OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EVENT_FILTER_H_ | 5 #ifndef UI_AURA_EVENT_FILTER_H_ |
6 #define UI_AURA_EVENT_FILTER_H_ | 6 #define UI_AURA_EVENT_FILTER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "ui/aura/aura_export.h" | 10 #include "ui/aura/aura_export.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // the event, this is typically the visible window whose bounds most tightly | 25 // the event, this is typically the visible window whose bounds most tightly |
26 // enclose the event coordinates, in the case of mouse events, or the focused | 26 // enclose the event coordinates, in the case of mouse events, or the focused |
27 // window, in the case of key events. | 27 // window, in the case of key events. |
28 // | 28 // |
29 // The Desktop then walks up the hierarchy from the target to its own window, | 29 // The Desktop then walks up the hierarchy from the target to its own window, |
30 // collecting a list of EventFilters. This list is notified in reverse order | 30 // collecting a list of EventFilters. This list is notified in reverse order |
31 // (i.e. descending, from the Desktop's own event filter). Each filter gets a | 31 // (i.e. descending, from the Desktop's own event filter). Each filter gets a |
32 // chance to prevent further processing of the event and/or take other actions. | 32 // chance to prevent further processing of the event and/or take other actions. |
33 class AURA_EXPORT EventFilter { | 33 class AURA_EXPORT EventFilter { |
34 public: | 34 public: |
35 explicit EventFilter(Window* owner); | 35 virtual ~EventFilter() {} |
36 virtual ~EventFilter(); | |
37 | 36 |
38 // Parameters: a |target| Window and the |event|. The target window is the | 37 // Parameters: a |target| Window and the |event|. The target window is the |
39 // window the event was targeted at. If |event| is a LocatedEvent, its | 38 // window the event was targeted at. If |event| is a LocatedEvent, its |
40 // coordinates are relative to |target|. | 39 // coordinates are relative to |target|. |
41 | 40 |
42 // For all PreHandle*() functions that return a bool, return true if the | 41 // For all PreHandle*() functions that return a bool, return true if the |
43 // filter consumes the event and further processing (by the target, for | 42 // filter consumes the event and further processing (by the target, for |
44 // example) is not performed. Return false if the filter does not consume the | 43 // example) is not performed. Return false if the filter does not consume the |
45 // event and further processing is performed. Note that in this case the | 44 // event and further processing is performed. Note that in this case the |
46 // filter may still perform some action, the return value simply indicates | 45 // filter may still perform some action, the return value simply indicates |
47 // that further processing can occur. | 46 // that further processing can occur. |
48 | 47 |
49 virtual bool PreHandleKeyEvent(Window* target, KeyEvent* event) = 0; | 48 virtual bool PreHandleKeyEvent(Window* target, KeyEvent* event) = 0; |
50 virtual bool PreHandleMouseEvent(Window* target, MouseEvent* event) = 0; | 49 virtual bool PreHandleMouseEvent(Window* target, MouseEvent* event) = 0; |
51 | 50 |
52 // Returns a value other than ui::TOUCH_STATUS_UNKNOWN if the event is | 51 // Returns a value other than ui::TOUCH_STATUS_UNKNOWN if the event is |
53 // consumed. | 52 // consumed. |
54 virtual ui::TouchStatus PreHandleTouchEvent(Window* target, | 53 virtual ui::TouchStatus PreHandleTouchEvent(Window* target, |
55 TouchEvent* event) = 0; | 54 TouchEvent* event) = 0; |
56 | 55 |
57 // Returns a value other than ui::GESTURE_STATUS_UNKNOWN if the gesture is | 56 // Returns a value other than ui::GESTURE_STATUS_UNKNOWN if the gesture is |
58 // consumed. | 57 // consumed. |
59 virtual ui::GestureStatus PreHandleGestureEvent(Window* target, | 58 virtual ui::GestureStatus PreHandleGestureEvent(Window* target, |
60 GestureEvent* event) = 0; | 59 GestureEvent* event) = 0; |
61 | |
62 protected: | |
63 Window* owner() { return owner_; } | |
64 | |
65 private: | |
66 Window* owner_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(EventFilter); | |
69 }; | 60 }; |
70 | 61 |
71 } // namespace aura | 62 } // namespace aura |
72 | 63 |
73 #endif // UI_AURA_EVENT_FILTER_H_ | 64 #endif // UI_AURA_EVENT_FILTER_H_ |
OLD | NEW |