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_SHARED_COMPOUND_EVENT_FILTER_H_ | 5 #ifndef UI_AURA_SHARED_COMPOUND_EVENT_FILTER_H_ |
6 #define UI_AURA_SHARED_COMPOUND_EVENT_FILTER_H_ | 6 #define UI_AURA_SHARED_COMPOUND_EVENT_FILTER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "ui/aura/aura_export.h" | 10 #include "ui/aura/aura_export.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // rest of the filter(s) and CompoundEventFilter will not see the consumed | 33 // rest of the filter(s) and CompoundEventFilter will not see the consumed |
34 // event. | 34 // event. |
35 class AURA_EXPORT CompoundEventFilter : public EventFilter { | 35 class AURA_EXPORT CompoundEventFilter : public EventFilter { |
36 public: | 36 public: |
37 CompoundEventFilter(); | 37 CompoundEventFilter(); |
38 virtual ~CompoundEventFilter(); | 38 virtual ~CompoundEventFilter(); |
39 | 39 |
40 // Returns the cursor for the specified component. | 40 // Returns the cursor for the specified component. |
41 static gfx::NativeCursor CursorForWindowComponent(int window_component); | 41 static gfx::NativeCursor CursorForWindowComponent(int window_component); |
42 | 42 |
43 void set_update_cursor_visibility(bool update) { | |
44 update_cursor_visibility_ = update; | |
45 } | |
46 | |
47 // Adds/removes additional event filters. This does not take ownership of | 43 // Adds/removes additional event filters. This does not take ownership of |
48 // the EventFilter. | 44 // the EventFilter. |
49 // NOTE: EventFilters are deprecated. Use env::AddPreTargetEventHandler etc. | 45 // NOTE: EventFilters are deprecated. Use env::AddPreTargetEventHandler etc. |
50 // instead. | 46 // instead. |
51 void AddFilter(EventFilter* filter); | 47 void AddFilter(EventFilter* filter); |
52 void RemoveFilter(EventFilter* filter); | 48 void RemoveFilter(EventFilter* filter); |
53 | 49 |
54 private: | 50 private: |
55 // Updates the cursor if the target provides a custom one, and provides | 51 // Updates the cursor if the target provides a custom one, and provides |
56 // default resize cursors for window edges. | 52 // default resize cursors for window edges. |
57 void UpdateCursor(Window* target, ui::MouseEvent* event); | 53 void UpdateCursor(Window* target, ui::MouseEvent* event); |
58 | 54 |
59 // Dispatches event to additional filters. | 55 // Dispatches event to additional filters. |
60 ui::EventResult FilterKeyEvent(ui::KeyEvent* event); | 56 ui::EventResult FilterKeyEvent(ui::KeyEvent* event); |
61 ui::EventResult FilterMouseEvent(ui::MouseEvent* event); | 57 ui::EventResult FilterMouseEvent(ui::MouseEvent* event); |
62 ui::TouchStatus FilterTouchEvent(Window* target, ui::TouchEvent* event); | 58 ui::TouchStatus FilterTouchEvent(Window* target, ui::TouchEvent* event); |
63 | 59 |
64 // Sets the visibility of the cursor if the event is not synthesized and | 60 // Sets the visibility of the cursor if the event is not synthesized and |
65 // |update_cursor_visibility_| is true. | 61 // 1) it's hiding (show=false) when the cursor is currently shown, or |
| 62 // 2) it's showing (show=true) if the cursor is previously hidden |
| 63 // by this event filter (see |cursor_hidden_by_filter_|), |
| 64 // so that it doesn't change the cursor visibility if the cursor was |
| 65 // intentionally hidden by other components. |
66 void SetCursorVisibilityOnEvent(aura::Window* target, | 66 void SetCursorVisibilityOnEvent(aura::Window* target, |
67 ui::Event* event, | 67 ui::Event* event, |
68 bool show); | 68 bool show); |
69 | 69 |
70 // Overridden from EventFilter: | 70 // Overridden from EventFilter: |
71 virtual ui::TouchStatus PreHandleTouchEvent(Window* target, | 71 virtual ui::TouchStatus PreHandleTouchEvent(Window* target, |
72 ui::TouchEvent* event) OVERRIDE; | 72 ui::TouchEvent* event) OVERRIDE; |
73 | 73 |
74 // Overridden from ui::EventHandler: | 74 // Overridden from ui::EventHandler: |
75 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 75 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
76 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 76 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
77 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 77 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
78 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 78 virtual ui::TouchStatus OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
79 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 79 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
80 // Additional event filters that pre-handles events. | 80 // Additional event filters that pre-handles events. |
81 ObserverList<EventFilter, true> filters_; | 81 ObserverList<EventFilter, true> filters_; |
82 | 82 |
83 // Should we show the mouse cursor when we see mouse movement and hide it when | 83 // True if the cursur was hidden by the filter. |
84 // we see a touch event? | 84 bool cursor_hidden_by_filter_; |
85 bool update_cursor_visibility_; | |
86 | 85 |
87 DISALLOW_COPY_AND_ASSIGN(CompoundEventFilter); | 86 DISALLOW_COPY_AND_ASSIGN(CompoundEventFilter); |
88 }; | 87 }; |
89 | 88 |
90 } // namespace shared | 89 } // namespace shared |
91 } // namespace aura | 90 } // namespace aura |
92 | 91 |
93 #endif // UI_AURA_COMPOUND_EVENT_FILTER_H_ | 92 #endif // UI_AURA_COMPOUND_EVENT_FILTER_H_ |
OLD | NEW |