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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "ui/compositor/compositor_observer.h" | 24 #include "ui/compositor/compositor_observer.h" |
25 #include "ui/compositor/layer_animation_observer.h" | 25 #include "ui/compositor/layer_animation_observer.h" |
26 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
27 #include "ui/gfx/point.h" | 27 #include "ui/gfx/point.h" |
28 | 28 |
29 namespace gfx { | 29 namespace gfx { |
30 class Size; | 30 class Size; |
31 } | 31 } |
32 | 32 |
33 namespace ui { | 33 namespace ui { |
| 34 class GestureEventImpl; |
34 class GestureRecognizer; | 35 class GestureRecognizer; |
| 36 class KeyEvent; |
35 class LayerAnimationSequence; | 37 class LayerAnimationSequence; |
| 38 class MouseEvent; |
| 39 class ScrollEvent; |
| 40 class TouchEventImpl; |
36 class Transform; | 41 class Transform; |
37 } | 42 } |
38 | 43 |
39 namespace aura { | 44 namespace aura { |
40 | 45 |
41 class FocusManager; | 46 class FocusManager; |
42 class GestureEvent; | |
43 class KeyEvent; | |
44 class MouseEvent; | |
45 class RootWindow; | 47 class RootWindow; |
46 class RootWindowHost; | 48 class RootWindowHost; |
47 class RootWindowObserver; | 49 class RootWindowObserver; |
48 class ScrollEvent; | |
49 class TouchEvent; | |
50 | 50 |
51 // This class represents a lock on the compositor, that can be used to prevent a | 51 // This class represents a lock on the compositor, that can be used to prevent a |
52 // compositing pass from happening while we're waiting for an asynchronous | 52 // compositing pass from happening while we're waiting for an asynchronous |
53 // event. The typical use case is when waiting for a renderer to produce a frame | 53 // event. The typical use case is when waiting for a renderer to produce a frame |
54 // at the right size. The caller keeps a reference on this object, and drops the | 54 // at the right size. The caller keeps a reference on this object, and drops the |
55 // reference once it desires to release the lock. | 55 // reference once it desires to release the lock. |
56 // Note however that the lock is canceled after a short timeout to ensure | 56 // Note however that the lock is canceled after a short timeout to ensure |
57 // responsiveness of the UI, so the compositor tree should be kept in a | 57 // responsiveness of the UI, so the compositor tree should be kept in a |
58 // "reasonable" state while the lock is held. | 58 // "reasonable" state while the lock is held. |
59 // Don't instantiate this class directly, use RootWindow::GetCompositorLock. | 59 // Don't instantiate this class directly, use RootWindow::GetCompositorLock. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 // Draws the necessary set of windows. | 139 // Draws the necessary set of windows. |
140 void Draw(); | 140 void Draw(); |
141 | 141 |
142 // Draw the whole screen. | 142 // Draw the whole screen. |
143 void ScheduleFullDraw(); | 143 void ScheduleFullDraw(); |
144 | 144 |
145 // Handles a gesture event. Returns true if handled. Unlike the other | 145 // Handles a gesture event. Returns true if handled. Unlike the other |
146 // event-dispatching function (e.g. for touch/mouse/keyboard events), gesture | 146 // event-dispatching function (e.g. for touch/mouse/keyboard events), gesture |
147 // events are dispatched from GestureRecognizer instead of RootWindowHost. | 147 // events are dispatched from GestureRecognizer instead of RootWindowHost. |
148 bool DispatchGestureEvent(GestureEvent* event); | 148 bool DispatchGestureEvent(ui::GestureEventImpl* event); |
149 | 149 |
150 // Invoked when |window| is being destroyed. | 150 // Invoked when |window| is being destroyed. |
151 void OnWindowDestroying(Window* window); | 151 void OnWindowDestroying(Window* window); |
152 | 152 |
153 // Invoked when |window|'s bounds have changed. |contained_mouse| indicates if | 153 // Invoked when |window|'s bounds have changed. |contained_mouse| indicates if |
154 // the bounds before change contained the |last_moust_location()|. | 154 // the bounds before change contained the |last_moust_location()|. |
155 void OnWindowBoundsChanged(Window* window, bool contained_mouse); | 155 void OnWindowBoundsChanged(Window* window, bool contained_mouse); |
156 | 156 |
157 // Invoked when |window|'s visibility is changed. | 157 // Invoked when |window|'s visibility is changed. |
158 void OnWindowVisibilityChanged(Window* window, bool is_visible); | 158 void OnWindowVisibilityChanged(Window* window, bool is_visible); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 260 |
261 // Exposes RootWindowHost::QueryMouseLocation() for test purposes. | 261 // Exposes RootWindowHost::QueryMouseLocation() for test purposes. |
262 gfx::Point QueryMouseLocationForTest() const; | 262 gfx::Point QueryMouseLocationForTest() const; |
263 | 263 |
264 private: | 264 private: |
265 friend class Window; | 265 friend class Window; |
266 friend class CompositorLock; | 266 friend class CompositorLock; |
267 | 267 |
268 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|, | 268 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|, |
269 // sending exited and entered events as its value changes. | 269 // sending exited and entered events as its value changes. |
270 void HandleMouseMoved(const MouseEvent& event, Window* target); | 270 void HandleMouseMoved(const ui::MouseEvent& event, Window* target); |
271 | 271 |
272 bool ProcessMouseEvent(Window* target, MouseEvent* event); | 272 bool ProcessMouseEvent(Window* target, ui::MouseEvent* event); |
273 bool ProcessKeyEvent(Window* target, KeyEvent* event); | 273 bool ProcessKeyEvent(Window* target, ui::KeyEvent* event); |
274 ui::TouchStatus ProcessTouchEvent(Window* target, TouchEvent* event); | 274 ui::TouchStatus ProcessTouchEvent(Window* target, ui::TouchEventImpl* event); |
275 ui::GestureStatus ProcessGestureEvent(Window* target, GestureEvent* event); | 275 ui::GestureStatus ProcessGestureEvent(Window* target, |
| 276 ui::GestureEventImpl* event); |
276 bool ProcessGestures(ui::GestureRecognizer::Gestures* gestures); | 277 bool ProcessGestures(ui::GestureRecognizer::Gestures* gestures); |
277 | 278 |
278 // Called when a Window is attached or detached from the RootWindow. | 279 // Called when a Window is attached or detached from the RootWindow. |
279 void OnWindowAddedToRootWindow(Window* window); | 280 void OnWindowAddedToRootWindow(Window* window); |
280 void OnWindowRemovedFromRootWindow(Window* window); | 281 void OnWindowRemovedFromRootWindow(Window* window); |
281 | 282 |
282 // Called when a window becomes invisible, either by being removed | 283 // Called when a window becomes invisible, either by being removed |
283 // from root window hierachy, via SetVisible(false) or being destroyed. | 284 // from root window hierachy, via SetVisible(false) or being destroyed. |
284 // |destroyed| is set to true when the window is being destroyed. | 285 // |destroyed| is set to true when the window is being destroyed. |
285 void OnWindowHidden(Window* invisible, bool destroyed); | 286 void OnWindowHidden(Window* invisible, bool destroyed); |
(...skipping 17 matching lines...) Expand all Loading... |
303 | 304 |
304 // Overridden from ui::LayerAnimationObserver: | 305 // Overridden from ui::LayerAnimationObserver: |
305 virtual void OnLayerAnimationEnded( | 306 virtual void OnLayerAnimationEnded( |
306 ui::LayerAnimationSequence* animation) OVERRIDE; | 307 ui::LayerAnimationSequence* animation) OVERRIDE; |
307 virtual void OnLayerAnimationScheduled( | 308 virtual void OnLayerAnimationScheduled( |
308 ui::LayerAnimationSequence* animation) OVERRIDE; | 309 ui::LayerAnimationSequence* animation) OVERRIDE; |
309 virtual void OnLayerAnimationAborted( | 310 virtual void OnLayerAnimationAborted( |
310 ui::LayerAnimationSequence* animation) OVERRIDE; | 311 ui::LayerAnimationSequence* animation) OVERRIDE; |
311 | 312 |
312 // Overridden from aura::RootWindowHostDelegate: | 313 // Overridden from aura::RootWindowHostDelegate: |
313 virtual bool OnHostKeyEvent(KeyEvent* event) OVERRIDE; | 314 virtual bool OnHostKeyEvent(ui::KeyEvent* event) OVERRIDE; |
314 virtual bool OnHostMouseEvent(MouseEvent* event) OVERRIDE; | 315 virtual bool OnHostMouseEvent(ui::MouseEvent* event) OVERRIDE; |
315 virtual bool OnHostScrollEvent(ScrollEvent* event) OVERRIDE; | 316 virtual bool OnHostScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
316 virtual bool OnHostTouchEvent(TouchEvent* event) OVERRIDE; | 317 virtual bool OnHostTouchEvent(ui::TouchEventImpl* event) OVERRIDE; |
317 virtual void OnHostLostCapture() OVERRIDE; | 318 virtual void OnHostLostCapture() OVERRIDE; |
318 virtual void OnHostPaint() OVERRIDE; | 319 virtual void OnHostPaint() OVERRIDE; |
319 virtual void OnHostResized(const gfx::Size& size) OVERRIDE; | 320 virtual void OnHostResized(const gfx::Size& size) OVERRIDE; |
320 virtual float GetDeviceScaleFactor() OVERRIDE; | 321 virtual float GetDeviceScaleFactor() OVERRIDE; |
321 virtual RootWindow* AsRootWindow() OVERRIDE; | 322 virtual RootWindow* AsRootWindow() OVERRIDE; |
322 | 323 |
323 // We hold and aggregate mouse drags as a way of throttling resizes when | 324 // We hold and aggregate mouse drags as a way of throttling resizes when |
324 // HoldMouseMoves() is called. The following methods are used to dispatch held | 325 // HoldMouseMoves() is called. The following methods are used to dispatch held |
325 // and newly incoming mouse events, typically when an event other than a mouse | 326 // and newly incoming mouse events, typically when an event other than a mouse |
326 // drag needs dispatching or a matching ReleaseMouseMoves() is called. | 327 // drag needs dispatching or a matching ReleaseMouseMoves() is called. |
327 // NOTE: because these methods dispatch events from RootWindowHost the | 328 // NOTE: because these methods dispatch events from RootWindowHost the |
328 // coordinates are in terms of the root. | 329 // coordinates are in terms of the root. |
329 bool DispatchMouseEventImpl(MouseEvent* event); | 330 bool DispatchMouseEventImpl(ui::MouseEvent* event); |
330 bool DispatchMouseEventToTarget(MouseEvent* event, Window* target); | 331 bool DispatchMouseEventToTarget(ui::MouseEvent* event, Window* target); |
331 void DispatchHeldMouseMove(); | 332 void DispatchHeldMouseMove(); |
332 | 333 |
333 // Parses the switch describing the initial size for the host window and | 334 // Parses the switch describing the initial size for the host window and |
334 // returns bounds for the window. | 335 // returns bounds for the window. |
335 gfx::Rect GetInitialHostWindowBounds() const; | 336 gfx::Rect GetInitialHostWindowBounds() const; |
336 | 337 |
337 // Posts a task to send synthesized mouse move event if there | 338 // Posts a task to send synthesized mouse move event if there |
338 // is no a pending task. | 339 // is no a pending task. |
339 void PostMouseMoveEventAfterWindowChange(); | 340 void PostMouseMoveEventAfterWindowChange(); |
340 | 341 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 384 |
384 bool synthesize_mouse_move_; | 385 bool synthesize_mouse_move_; |
385 bool waiting_on_compositing_end_; | 386 bool waiting_on_compositing_end_; |
386 bool draw_on_compositing_end_; | 387 bool draw_on_compositing_end_; |
387 | 388 |
388 bool defer_draw_scheduling_; | 389 bool defer_draw_scheduling_; |
389 | 390 |
390 // How many holds are outstanding. We try to defer dispatching mouse moves | 391 // How many holds are outstanding. We try to defer dispatching mouse moves |
391 // while the count is > 0. | 392 // while the count is > 0. |
392 int mouse_move_hold_count_; | 393 int mouse_move_hold_count_; |
393 scoped_ptr<MouseEvent> held_mouse_move_; | 394 scoped_ptr<ui::MouseEvent> held_mouse_move_; |
394 // Used to schedule DispatchHeldMouseMove() when |mouse_move_hold_count_| goes | 395 // Used to schedule DispatchHeldMouseMove() when |mouse_move_hold_count_| goes |
395 // to 0. | 396 // to 0. |
396 base::WeakPtrFactory<RootWindow> held_mouse_event_factory_; | 397 base::WeakPtrFactory<RootWindow> held_mouse_event_factory_; |
397 | 398 |
398 CompositorLock* compositor_lock_; | 399 CompositorLock* compositor_lock_; |
399 bool draw_on_compositor_unlock_; | 400 bool draw_on_compositor_unlock_; |
400 | 401 |
401 DISALLOW_COPY_AND_ASSIGN(RootWindow); | 402 DISALLOW_COPY_AND_ASSIGN(RootWindow); |
402 }; | 403 }; |
403 | 404 |
404 } // namespace aura | 405 } // namespace aura |
405 | 406 |
406 #endif // UI_AURA_ROOT_WINDOW_H_ | 407 #endif // UI_AURA_ROOT_WINDOW_H_ |
OLD | NEW |