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_ROOT_WINDOW_H_ | 5 #ifndef UI_AURA_ROOT_WINDOW_H_ |
6 #define UI_AURA_ROOT_WINDOW_H_ | 6 #define UI_AURA_ROOT_WINDOW_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" | 18 #include "ui/aura/window_tree_host.h" |
19 #include "ui/aura/window_tree_host_delegate.h" | 19 #include "ui/aura/window_tree_host_delegate.h" |
20 #include "ui/base/cursor/cursor.h" | 20 #include "ui/base/cursor/cursor.h" |
21 #include "ui/compositor/compositor.h" | 21 #include "ui/compositor/compositor.h" |
22 #include "ui/compositor/layer_animation_observer.h" | 22 #include "ui/compositor/layer_animation_observer.h" |
23 #include "ui/events/event_constants.h" | 23 #include "ui/events/event_constants.h" |
24 #include "ui/events/event_processor.h" | 24 #include "ui/events/event_processor.h" |
25 #include "ui/events/event_targeter.h" | 25 #include "ui/events/event_targeter.h" |
| 26 #include "ui/events/gestures/gesture_event_queue.h" |
26 #include "ui/events/gestures/gesture_recognizer.h" | 27 #include "ui/events/gestures/gesture_recognizer.h" |
27 #include "ui/events/gestures/gesture_types.h" | 28 #include "ui/events/gestures/gesture_types.h" |
28 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
29 #include "ui/gfx/point.h" | 30 #include "ui/gfx/point.h" |
30 | 31 |
31 namespace gfx { | 32 namespace gfx { |
32 class Size; | 33 class Size; |
33 class Transform; | 34 class Transform; |
34 } | 35 } |
35 | 36 |
(...skipping 13 matching lines...) Expand all Loading... |
49 class RootWindowHost; | 50 class RootWindowHost; |
50 class RootWindowObserver; | 51 class RootWindowObserver; |
51 class TestScreen; | 52 class TestScreen; |
52 class WindowTargeter; | 53 class WindowTargeter; |
53 | 54 |
54 // RootWindow is responsible for hosting a set of windows. | 55 // RootWindow is responsible for hosting a set of windows. |
55 class AURA_EXPORT RootWindow : public ui::EventProcessor, | 56 class AURA_EXPORT RootWindow : public ui::EventProcessor, |
56 public ui::GestureEventHelper, | 57 public ui::GestureEventHelper, |
57 public ui::LayerAnimationObserver, | 58 public ui::LayerAnimationObserver, |
58 public aura::client::CaptureDelegate, | 59 public aura::client::CaptureDelegate, |
59 public aura::RootWindowHostDelegate { | 60 public aura::RootWindowHostDelegate, |
| 61 public ui::GestureEventQueueDelegate { |
60 public: | 62 public: |
61 struct AURA_EXPORT CreateParams { | 63 struct AURA_EXPORT CreateParams { |
62 // CreateParams with initial_bounds and default host in pixel. | 64 // CreateParams with initial_bounds and default host in pixel. |
63 explicit CreateParams(const gfx::Rect& initial_bounds); | 65 explicit CreateParams(const gfx::Rect& initial_bounds); |
64 ~CreateParams() {} | 66 ~CreateParams() {} |
65 | 67 |
66 gfx::Rect initial_bounds; | 68 gfx::Rect initial_bounds; |
67 | 69 |
68 // A host to use in place of the default one that RootWindow will create. | 70 // A host to use in place of the default one that RootWindow will create. |
69 // NULL by default. | 71 // NULL by default. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 128 |
127 // Moves the cursor to the |host_location| given in host coordinates. | 129 // Moves the cursor to the |host_location| given in host coordinates. |
128 void MoveCursorToHostLocation(const gfx::Point& host_location); | 130 void MoveCursorToHostLocation(const gfx::Point& host_location); |
129 | 131 |
130 // Returns a target window for the given gesture event. | 132 // Returns a target window for the given gesture event. |
131 Window* GetGestureTarget(ui::GestureEvent* event); | 133 Window* GetGestureTarget(ui::GestureEvent* event); |
132 | 134 |
133 // Handles a gesture event. Returns true if handled. Unlike the other | 135 // Handles a gesture event. Returns true if handled. Unlike the other |
134 // event-dispatching function (e.g. for touch/mouse/keyboard events), gesture | 136 // event-dispatching function (e.g. for touch/mouse/keyboard events), gesture |
135 // events are dispatched from GestureRecognizer instead of RootWindowHost. | 137 // events are dispatched from GestureRecognizer instead of RootWindowHost. |
136 void DispatchGestureEvent(ui::GestureEvent* event); | 138 virtual void DispatchGestureEvent(ui::GestureEvent* event) OVERRIDE; |
137 | 139 |
138 // Invoked when |window| is being destroyed. | 140 // Invoked when |window| is being destroyed. |
139 void OnWindowDestroying(Window* window); | 141 void OnWindowDestroying(Window* window); |
140 | 142 |
141 // Invoked when |window|'s bounds have changed. |contained_mouse| indicates if | 143 // Invoked when |window|'s bounds have changed. |contained_mouse| indicates if |
142 // the bounds before change contained the |last_moust_location()|. | 144 // the bounds before change contained the |last_moust_location()|. |
143 void OnWindowBoundsChanged(Window* window, bool contained_mouse); | 145 void OnWindowBoundsChanged(Window* window, bool contained_mouse); |
144 | 146 |
145 // Dispatches OnMouseExited to the |window| which is hiding if nessessary. | 147 // Dispatches OnMouseExited to the |window| which is hiding if nessessary. |
146 void DispatchMouseExitToHidingWindow(Window* window); | 148 void DispatchMouseExitToHidingWindow(Window* window); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // | 190 // |
189 // More than one hold can be invoked and each hold must be cancelled by a | 191 // More than one hold can be invoked and each hold must be cancelled by a |
190 // release before we resume normal operation. | 192 // release before we resume normal operation. |
191 void HoldPointerMoves(); | 193 void HoldPointerMoves(); |
192 void ReleasePointerMoves(); | 194 void ReleasePointerMoves(); |
193 | 195 |
194 // Gets the last location seen in a mouse event in this root window's | 196 // Gets the last location seen in a mouse event in this root window's |
195 // coordinates. This may return a point outside the root window's bounds. | 197 // coordinates. This may return a point outside the root window's bounds. |
196 gfx::Point GetLastMouseLocationInRoot() const; | 198 gfx::Point GetLastMouseLocationInRoot() const; |
197 | 199 |
| 200 void OnTouchEventForGestures( |
| 201 ui::TouchEvent* event, |
| 202 ui::TouchPointState::RequiresAck requires_ack); |
| 203 |
198 private: | 204 private: |
199 FRIEND_TEST_ALL_PREFIXES(RootWindowTest, KeepTranslatedEventInRoot); | 205 FRIEND_TEST_ALL_PREFIXES(RootWindowTest, KeepTranslatedEventInRoot); |
200 | 206 |
201 friend class Window; | 207 friend class Window; |
202 friend class TestScreen; | 208 friend class TestScreen; |
203 | 209 |
204 // The parameter for OnWindowHidden() to specify why window is hidden. | 210 // The parameter for OnWindowHidden() to specify why window is hidden. |
205 enum WindowHiddenReason { | 211 enum WindowHiddenReason { |
206 WINDOW_DESTROYED, // Window is destroyed. | 212 WINDOW_DESTROYED, // Window is destroyed. |
207 WINDOW_HIDDEN, // Window is hidden. | 213 WINDOW_HIDDEN, // Window is hidden. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 260 |
255 // Overridden from ui::EventDispatcherDelegate. | 261 // Overridden from ui::EventDispatcherDelegate. |
256 virtual bool CanDispatchToTarget(ui::EventTarget* target) OVERRIDE; | 262 virtual bool CanDispatchToTarget(ui::EventTarget* target) OVERRIDE; |
257 virtual ui::EventDispatchDetails PreDispatchEvent(ui::EventTarget* target, | 263 virtual ui::EventDispatchDetails PreDispatchEvent(ui::EventTarget* target, |
258 ui::Event* event) OVERRIDE; | 264 ui::Event* event) OVERRIDE; |
259 virtual ui::EventDispatchDetails PostDispatchEvent( | 265 virtual ui::EventDispatchDetails PostDispatchEvent( |
260 ui::EventTarget* target, const ui::Event& event) OVERRIDE; | 266 ui::EventTarget* target, const ui::Event& event) OVERRIDE; |
261 | 267 |
262 // Overridden from ui::GestureEventHelper. | 268 // Overridden from ui::GestureEventHelper. |
263 virtual bool CanDispatchToConsumer(ui::GestureConsumer* consumer) OVERRIDE; | 269 virtual bool CanDispatchToConsumer(ui::GestureConsumer* consumer) OVERRIDE; |
264 virtual void DispatchPostponedGestureEvent(ui::GestureEvent* event) OVERRIDE; | |
265 virtual void DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE; | 270 virtual void DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE; |
266 | 271 |
267 // Overridden from ui::LayerAnimationObserver: | 272 // Overridden from ui::LayerAnimationObserver: |
268 virtual void OnLayerAnimationEnded( | 273 virtual void OnLayerAnimationEnded( |
269 ui::LayerAnimationSequence* animation) OVERRIDE; | 274 ui::LayerAnimationSequence* animation) OVERRIDE; |
270 virtual void OnLayerAnimationScheduled( | 275 virtual void OnLayerAnimationScheduled( |
271 ui::LayerAnimationSequence* animation) OVERRIDE; | 276 ui::LayerAnimationSequence* animation) OVERRIDE; |
272 virtual void OnLayerAnimationAborted( | 277 virtual void OnLayerAnimationAborted( |
273 ui::LayerAnimationSequence* animation) OVERRIDE; | 278 ui::LayerAnimationSequence* animation) OVERRIDE; |
274 | 279 |
(...skipping 22 matching lines...) Expand all Loading... |
297 // ReleaseMouseMoves()/ReleaseTouchMoves() is called. NOTE: because these | 302 // ReleaseMouseMoves()/ReleaseTouchMoves() is called. NOTE: because these |
298 // methods dispatch events from RootWindowHost the coordinates are in terms of | 303 // methods dispatch events from RootWindowHost the coordinates are in terms of |
299 // the root. | 304 // the root. |
300 ui::EventDispatchDetails DispatchMouseEventImpl(ui::MouseEvent* event) | 305 ui::EventDispatchDetails DispatchMouseEventImpl(ui::MouseEvent* event) |
301 WARN_UNUSED_RESULT; | 306 WARN_UNUSED_RESULT; |
302 ui::EventDispatchDetails DispatchMouseEventRepost(ui::MouseEvent* event) | 307 ui::EventDispatchDetails DispatchMouseEventRepost(ui::MouseEvent* event) |
303 WARN_UNUSED_RESULT; | 308 WARN_UNUSED_RESULT; |
304 ui::EventDispatchDetails DispatchMouseEventToTarget(ui::MouseEvent* event, | 309 ui::EventDispatchDetails DispatchMouseEventToTarget(ui::MouseEvent* event, |
305 Window* target) | 310 Window* target) |
306 WARN_UNUSED_RESULT; | 311 WARN_UNUSED_RESULT; |
307 ui::EventDispatchDetails DispatchTouchEventImpl(ui::TouchEvent* event) | 312 ui::EventDispatchDetails DispatchTouchEventImpl(ui::TouchEvent* event, |
| 313 Window* target) |
308 WARN_UNUSED_RESULT; | 314 WARN_UNUSED_RESULT; |
309 ui::EventDispatchDetails DispatchHeldEvents() WARN_UNUSED_RESULT; | 315 ui::EventDispatchDetails DispatchHeldEvents() WARN_UNUSED_RESULT; |
310 // Creates and dispatches synthesized mouse move event using the | 316 // Creates and dispatches synthesized mouse move event using the |
311 // current mouse location. | 317 // current mouse location. |
312 ui::EventDispatchDetails SynthesizeMouseMoveEvent() WARN_UNUSED_RESULT; | 318 ui::EventDispatchDetails SynthesizeMouseMoveEvent() WARN_UNUSED_RESULT; |
313 | 319 |
314 void SynthesizeMouseMoveEventAsync(); | 320 void SynthesizeMouseMoveEventAsync(); |
315 | 321 |
316 // Posts a task to send synthesized mouse move event if there | 322 // Posts a task to send synthesized mouse move event if there |
317 // is no a pending task. | 323 // is no a pending task. |
318 void PostMouseMoveEventAfterWindowChange(); | 324 void PostMouseMoveEventAfterWindowChange(); |
319 | 325 |
320 void PreDispatchLocatedEvent(Window* target, ui::LocatedEvent* event); | 326 void PreDispatchLocatedEvent(Window* target, ui::LocatedEvent* event); |
321 | 327 |
| 328 Window* GetTouchEventTarget(ui::TouchEvent* event); |
| 329 |
322 // TODO(beng): evaluate the ideal ownership model. | 330 // TODO(beng): evaluate the ideal ownership model. |
323 scoped_ptr<Window> window_; | 331 scoped_ptr<Window> window_; |
324 | 332 |
325 scoped_ptr<RootWindowHost> host_; | 333 scoped_ptr<RootWindowHost> host_; |
326 | 334 |
327 // Touch ids that are currently down. | 335 // Touch ids that are currently down. |
328 uint32 touch_ids_down_; | 336 uint32 touch_ids_down_; |
329 | 337 |
330 // Last cursor set. Used for testing. | 338 // Last cursor set. Used for testing. |
331 gfx::NativeCursor last_cursor_; | 339 gfx::NativeCursor last_cursor_; |
(...skipping 19 matching lines...) Expand all Loading... |
351 bool dispatching_held_event_; | 359 bool dispatching_held_event_; |
352 | 360 |
353 scoped_ptr<ui::ViewProp> prop_; | 361 scoped_ptr<ui::ViewProp> prop_; |
354 | 362 |
355 // Used to schedule reposting an event. | 363 // Used to schedule reposting an event. |
356 base::WeakPtrFactory<RootWindow> repost_event_factory_; | 364 base::WeakPtrFactory<RootWindow> repost_event_factory_; |
357 | 365 |
358 // Used to schedule DispatchHeldEvents() when |move_hold_count_| goes to 0. | 366 // Used to schedule DispatchHeldEvents() when |move_hold_count_| goes to 0. |
359 base::WeakPtrFactory<RootWindow> held_event_factory_; | 367 base::WeakPtrFactory<RootWindow> held_event_factory_; |
360 | 368 |
| 369 std::map<Window*, ui::GestureEventQueue*> gesture_event_queues_; |
| 370 |
361 DISALLOW_COPY_AND_ASSIGN(RootWindow); | 371 DISALLOW_COPY_AND_ASSIGN(RootWindow); |
362 }; | 372 }; |
363 | 373 |
364 } // namespace aura | 374 } // namespace aura |
365 | 375 |
366 #endif // UI_AURA_ROOT_WINDOW_H_ | 376 #endif // UI_AURA_ROOT_WINDOW_H_ |
OLD | NEW |