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 30 matching lines...) Expand all Loading... |
41 class FocusManager; | 41 class FocusManager; |
42 class GestureEvent; | 42 class GestureEvent; |
43 class KeyEvent; | 43 class KeyEvent; |
44 class MouseEvent; | 44 class MouseEvent; |
45 class RootWindow; | 45 class RootWindow; |
46 class RootWindowHost; | 46 class RootWindowHost; |
47 class RootWindowObserver; | 47 class RootWindowObserver; |
48 class ScrollEvent; | 48 class ScrollEvent; |
49 class TouchEvent; | 49 class TouchEvent; |
50 | 50 |
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 | |
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 | |
55 // reference once it desires to release the lock. | |
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 | |
58 // "reasonable" state while the lock is held. | |
59 // Don't instantiate this class directly, use RootWindow::GetCompositorLock. | |
60 class AURA_EXPORT CompositorLock | |
61 : public base::RefCounted<CompositorLock>, | |
62 public base::SupportsWeakPtr<CompositorLock> { | |
63 private: | |
64 friend class base::RefCounted<CompositorLock>; | |
65 friend class RootWindow; | |
66 | |
67 explicit CompositorLock(RootWindow* root_window); | |
68 ~CompositorLock(); | |
69 | |
70 void CancelLock(); | |
71 | |
72 RootWindow* root_window_; | |
73 DISALLOW_COPY_AND_ASSIGN(CompositorLock); | |
74 }; | |
75 | |
76 // RootWindow is responsible for hosting a set of windows. | 51 // RootWindow is responsible for hosting a set of windows. |
77 class AURA_EXPORT RootWindow : public ui::CompositorDelegate, | 52 class AURA_EXPORT RootWindow : public ui::CompositorDelegate, |
78 public ui::CompositorObserver, | 53 public ui::CompositorObserver, |
79 public Window, | 54 public Window, |
80 public ui::GestureEventHelper, | 55 public ui::GestureEventHelper, |
81 public ui::LayerAnimationObserver, | 56 public ui::LayerAnimationObserver, |
82 public aura::client::CaptureDelegate, | 57 public aura::client::CaptureDelegate, |
83 public aura::RootWindowHostDelegate { | 58 public aura::RootWindowHostDelegate { |
84 public: | 59 public: |
85 explicit RootWindow(const gfx::Rect& initial_bounds); | 60 explicit RootWindow(const gfx::Rect& initial_bounds); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // These methods are used to defer the processing of mouse events related | 184 // These methods are used to defer the processing of mouse events related |
210 // to resize. A client (typically a RenderWidgetHostViewAura) can call | 185 // to resize. A client (typically a RenderWidgetHostViewAura) can call |
211 // HoldMouseMoves when an resize is initiated and then ReleaseMouseMoves | 186 // HoldMouseMoves when an resize is initiated and then ReleaseMouseMoves |
212 // once the resize is completed. | 187 // once the resize is completed. |
213 // | 188 // |
214 // More than one hold can be invoked and each hold must be cancelled by a | 189 // More than one hold can be invoked and each hold must be cancelled by a |
215 // release before we resume normal operation. | 190 // release before we resume normal operation. |
216 void HoldMouseMoves(); | 191 void HoldMouseMoves(); |
217 void ReleaseMouseMoves(); | 192 void ReleaseMouseMoves(); |
218 | 193 |
219 // Creates a compositor lock. | |
220 scoped_refptr<CompositorLock> GetCompositorLock(); | |
221 | |
222 // Sets if the window should be focused when shown. | 194 // Sets if the window should be focused when shown. |
223 void SetFocusWhenShown(bool focus_when_shown); | 195 void SetFocusWhenShown(bool focus_when_shown); |
224 | 196 |
225 // Grabs the snapshot of the root window by using the platform-dependent APIs. | 197 // Grabs the snapshot of the root window by using the platform-dependent APIs. |
226 bool GrabSnapshot(const gfx::Rect& snapshot_bounds, | 198 bool GrabSnapshot(const gfx::Rect& snapshot_bounds, |
227 std::vector<unsigned char>* png_representation); | 199 std::vector<unsigned char>* png_representation); |
228 | 200 |
229 // Gets the last location seen in a mouse event in this root window's | 201 // Gets the last location seen in a mouse event in this root window's |
230 // coordinates. This may return a point outside the root window's bounds. | 202 // coordinates. This may return a point outside the root window's bounds. |
231 gfx::Point GetLastMouseLocationInRoot() const; | 203 gfx::Point GetLastMouseLocationInRoot() const; |
(...skipping 24 matching lines...) Expand all Loading... |
256 // Overridden from aura::client::CaptureDelegate: | 228 // Overridden from aura::client::CaptureDelegate: |
257 virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE; | 229 virtual void UpdateCapture(Window* old_capture, Window* new_capture) OVERRIDE; |
258 virtual void SetNativeCapture() OVERRIDE; | 230 virtual void SetNativeCapture() OVERRIDE; |
259 virtual void ReleaseNativeCapture() OVERRIDE; | 231 virtual void ReleaseNativeCapture() OVERRIDE; |
260 | 232 |
261 // Exposes RootWindowHost::QueryMouseLocation() for test purposes. | 233 // Exposes RootWindowHost::QueryMouseLocation() for test purposes. |
262 gfx::Point QueryMouseLocationForTest() const; | 234 gfx::Point QueryMouseLocationForTest() const; |
263 | 235 |
264 private: | 236 private: |
265 friend class Window; | 237 friend class Window; |
266 friend class CompositorLock; | |
267 | 238 |
268 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|, | 239 // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|, |
269 // sending exited and entered events as its value changes. | 240 // sending exited and entered events as its value changes. |
270 void HandleMouseMoved(const MouseEvent& event, Window* target); | 241 void HandleMouseMoved(const MouseEvent& event, Window* target); |
271 | 242 |
272 bool ProcessMouseEvent(Window* target, MouseEvent* event); | 243 bool ProcessMouseEvent(Window* target, MouseEvent* event); |
273 bool ProcessKeyEvent(Window* target, KeyEvent* event); | 244 bool ProcessKeyEvent(Window* target, KeyEvent* event); |
274 ui::TouchStatus ProcessTouchEvent(Window* target, TouchEvent* event); | 245 ui::TouchStatus ProcessTouchEvent(Window* target, TouchEvent* event); |
275 ui::GestureStatus ProcessGestureEvent(Window* target, GestureEvent* event); | 246 ui::GestureStatus ProcessGestureEvent(Window* target, GestureEvent* event); |
276 bool ProcessGestures(ui::GestureRecognizer::Gestures* gestures); | 247 bool ProcessGestures(ui::GestureRecognizer::Gestures* gestures); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 gfx::Rect GetInitialHostWindowBounds() const; | 306 gfx::Rect GetInitialHostWindowBounds() const; |
336 | 307 |
337 // Posts a task to send synthesized mouse move event if there | 308 // Posts a task to send synthesized mouse move event if there |
338 // is no a pending task. | 309 // is no a pending task. |
339 void PostMouseMoveEventAfterWindowChange(); | 310 void PostMouseMoveEventAfterWindowChange(); |
340 | 311 |
341 // Creates and dispatches synthesized mouse move event using the | 312 // Creates and dispatches synthesized mouse move event using the |
342 // current mouse location. | 313 // current mouse location. |
343 void SynthesizeMouseMoveEvent(); | 314 void SynthesizeMouseMoveEvent(); |
344 | 315 |
345 // Called by CompositorLock. | |
346 void UnlockCompositor(); | |
347 | |
348 scoped_ptr<ui::Compositor> compositor_; | 316 scoped_ptr<ui::Compositor> compositor_; |
349 | 317 |
350 scoped_ptr<RootWindowHost> host_; | 318 scoped_ptr<RootWindowHost> host_; |
351 | 319 |
352 // If set before the RootWindow is created, the cursor will be drawn within | 320 // If set before the RootWindow is created, the cursor will be drawn within |
353 // the Aura root window but hidden outside of it, and it'll remain hidden | 321 // the Aura root window but hidden outside of it, and it'll remain hidden |
354 // after the Aura window is closed. | 322 // after the Aura window is closed. |
355 static bool hide_host_cursor_; | 323 static bool hide_host_cursor_; |
356 | 324 |
357 // Used to schedule painting. | 325 // Used to schedule painting. |
(...skipping 30 matching lines...) Expand all Loading... |
388 bool defer_draw_scheduling_; | 356 bool defer_draw_scheduling_; |
389 | 357 |
390 // How many holds are outstanding. We try to defer dispatching mouse moves | 358 // How many holds are outstanding. We try to defer dispatching mouse moves |
391 // while the count is > 0. | 359 // while the count is > 0. |
392 int mouse_move_hold_count_; | 360 int mouse_move_hold_count_; |
393 scoped_ptr<MouseEvent> held_mouse_move_; | 361 scoped_ptr<MouseEvent> held_mouse_move_; |
394 // Used to schedule DispatchHeldMouseMove() when |mouse_move_hold_count_| goes | 362 // Used to schedule DispatchHeldMouseMove() when |mouse_move_hold_count_| goes |
395 // to 0. | 363 // to 0. |
396 base::WeakPtrFactory<RootWindow> held_mouse_event_factory_; | 364 base::WeakPtrFactory<RootWindow> held_mouse_event_factory_; |
397 | 365 |
398 CompositorLock* compositor_lock_; | |
399 bool draw_on_compositor_unlock_; | |
400 | |
401 DISALLOW_COPY_AND_ASSIGN(RootWindow); | 366 DISALLOW_COPY_AND_ASSIGN(RootWindow); |
402 }; | 367 }; |
403 | 368 |
404 } // namespace aura | 369 } // namespace aura |
405 | 370 |
406 #endif // UI_AURA_ROOT_WINDOW_H_ | 371 #endif // UI_AURA_ROOT_WINDOW_H_ |
OLD | NEW |