OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_EVENT_DISPATCHER_H_ | 5 #ifndef UI_AURA_WINDOW_EVENT_DISPATCHER_H_ |
6 #define UI_AURA_WINDOW_EVENT_DISPATCHER_H_ | 6 #define UI_AURA_WINDOW_EVENT_DISPATCHER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "ui/aura/aura_export.h" | 16 #include "ui/aura/aura_export.h" |
17 #include "ui/aura/client/capture_delegate.h" | 17 #include "ui/aura/client/capture_delegate.h" |
18 #include "ui/aura/window_tree_host.h" | |
19 #include "ui/base/cursor/cursor.h" | 18 #include "ui/base/cursor/cursor.h" |
20 #include "ui/events/event_constants.h" | 19 #include "ui/events/event_constants.h" |
21 #include "ui/events/event_processor.h" | 20 #include "ui/events/event_processor.h" |
22 #include "ui/events/event_targeter.h" | 21 #include "ui/events/event_targeter.h" |
23 #include "ui/events/gestures/gesture_recognizer.h" | 22 #include "ui/events/gestures/gesture_recognizer.h" |
24 #include "ui/events/gestures/gesture_types.h" | 23 #include "ui/events/gestures/gesture_types.h" |
25 #include "ui/gfx/native_widget_types.h" | 24 #include "ui/gfx/native_widget_types.h" |
26 #include "ui/gfx/point.h" | 25 #include "ui/gfx/point.h" |
27 | 26 |
28 namespace gfx { | 27 namespace gfx { |
29 class Size; | 28 class Size; |
30 class Transform; | 29 class Transform; |
31 } | 30 } |
32 | 31 |
33 namespace ui { | 32 namespace ui { |
34 class GestureEvent; | 33 class GestureEvent; |
35 class GestureRecognizer; | 34 class GestureRecognizer; |
36 class KeyEvent; | 35 class KeyEvent; |
37 class MouseEvent; | 36 class MouseEvent; |
38 class ScrollEvent; | 37 class ScrollEvent; |
39 class TouchEvent; | 38 class TouchEvent; |
40 } | 39 } |
41 | 40 |
42 namespace aura { | 41 namespace aura { |
43 class RootWindowObserver; | 42 class RootWindowObserver; |
44 class TestScreen; | 43 class TestScreen; |
45 class WindowTargeter; | 44 class WindowTargeter; |
| 45 class WindowTreeHost; |
46 | 46 |
47 // WindowEventDispatcher orchestrates event dispatch within a window tree | 47 // WindowEventDispatcher orchestrates event dispatch within a window tree |
48 // owned by WindowTreeHost. WTH also owns the WED. | 48 // owned by WindowTreeHost. WTH also owns the WED. |
49 // TODO(beng): In progress, remove functionality not directly related to | 49 // TODO(beng): In progress, remove functionality not directly related to |
50 // event dispatch. | 50 // event dispatch. |
51 class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, | 51 class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, |
52 public ui::GestureEventHelper, | 52 public ui::GestureEventHelper, |
53 public client::CaptureDelegate { | 53 public client::CaptureDelegate { |
54 public: | 54 public: |
55 explicit WindowEventDispatcher(WindowTreeHost* host); | 55 explicit WindowEventDispatcher(WindowTreeHost* host); |
56 virtual ~WindowEventDispatcher(); | 56 virtual ~WindowEventDispatcher(); |
57 | 57 |
58 Window* window() { return host()->window(); } | |
59 const Window* window() const { return host()->window(); } | |
60 WindowTreeHost* host() { | |
61 return const_cast<WindowTreeHost*>( | |
62 const_cast<const WindowEventDispatcher*>(this)->host()); | |
63 } | |
64 const WindowTreeHost* host() const { return host_; } | |
65 Window* mouse_pressed_handler() { return mouse_pressed_handler_; } | 58 Window* mouse_pressed_handler() { return mouse_pressed_handler_; } |
66 Window* mouse_moved_handler() { return mouse_moved_handler_; } | 59 Window* mouse_moved_handler() { return mouse_moved_handler_; } |
67 | 60 |
68 // Repost event for re-processing. Used when exiting context menus. | 61 // Repost event for re-processing. Used when exiting context menus. |
69 // We only support the ET_MOUSE_PRESSED and ET_GESTURE_TAP_DOWN event | 62 // We only support the ET_MOUSE_PRESSED and ET_GESTURE_TAP_DOWN event |
70 // types (although the latter is currently a no-op). | 63 // types (although the latter is currently a no-op). |
71 void RepostEvent(const ui::LocatedEvent& event); | 64 void RepostEvent(const ui::LocatedEvent& event); |
72 | 65 |
73 // Invoked when the mouse events get enabled or disabled. | 66 // Invoked when the mouse events get enabled or disabled. |
74 void OnMouseEventsEnableStateChanged(bool enabled); | 67 void OnMouseEventsEnableStateChanged(bool enabled); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 friend class TestScreen; | 136 friend class TestScreen; |
144 | 137 |
145 // The parameter for OnWindowHidden() to specify why window is hidden. | 138 // The parameter for OnWindowHidden() to specify why window is hidden. |
146 enum WindowHiddenReason { | 139 enum WindowHiddenReason { |
147 WINDOW_DESTROYED, // Window is destroyed. | 140 WINDOW_DESTROYED, // Window is destroyed. |
148 WINDOW_HIDDEN, // Window is hidden. | 141 WINDOW_HIDDEN, // Window is hidden. |
149 WINDOW_MOVING, // Window is temporarily marked as hidden due to move | 142 WINDOW_MOVING, // Window is temporarily marked as hidden due to move |
150 // across root windows. | 143 // across root windows. |
151 }; | 144 }; |
152 | 145 |
| 146 Window* window(); |
| 147 const Window* window() const; |
| 148 |
153 // Updates the event with the appropriate transform for the device scale | 149 // Updates the event with the appropriate transform for the device scale |
154 // factor. The WindowEventDispatcher dispatches events in the physical pixel | 150 // factor. The WindowEventDispatcher dispatches events in the physical pixel |
155 // coordinate. But the event processing from WindowEventDispatcher onwards | 151 // coordinate. But the event processing from WindowEventDispatcher onwards |
156 // happen in device-independent pixel coordinate. So it is necessary to update | 152 // happen in device-independent pixel coordinate. So it is necessary to update |
157 // the event received from the host. | 153 // the event received from the host. |
158 void TransformEventForDeviceScaleFactor(ui::LocatedEvent* event); | 154 void TransformEventForDeviceScaleFactor(ui::LocatedEvent* event); |
159 | 155 |
160 // Dispatches the specified event type (intended for enter/exit) to the | 156 // Dispatches the specified event type (intended for enter/exit) to the |
161 // |mouse_moved_handler_|. | 157 // |mouse_moved_handler_|. |
162 ui::EventDispatchDetails DispatchMouseEnterOrExit( | 158 ui::EventDispatchDetails DispatchMouseEnterOrExit( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 251 |
256 // Used to schedule DispatchHeldEvents() when |move_hold_count_| goes to 0. | 252 // Used to schedule DispatchHeldEvents() when |move_hold_count_| goes to 0. |
257 base::WeakPtrFactory<WindowEventDispatcher> held_event_factory_; | 253 base::WeakPtrFactory<WindowEventDispatcher> held_event_factory_; |
258 | 254 |
259 DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcher); | 255 DISALLOW_COPY_AND_ASSIGN(WindowEventDispatcher); |
260 }; | 256 }; |
261 | 257 |
262 } // namespace aura | 258 } // namespace aura |
263 | 259 |
264 #endif // UI_AURA_WINDOW_EVENT_DISPATCHER_H_ | 260 #endif // UI_AURA_WINDOW_EVENT_DISPATCHER_H_ |
OLD | NEW |