[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 81585f3 | 2011-07-29 19:32:06 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 5 | #ifndef UI_AURA_ROOT_WINDOW_H_ |
| 6 | #define UI_AURA_ROOT_WINDOW_H_ |
[email protected] | 81585f3 | 2011-07-29 19:32:06 | [diff] [blame] | 7 | #pragma once |
| 8 | |
[email protected] | 81585f3 | 2011-07-29 19:32:06 | [diff] [blame] | 9 | #include "base/basictypes.h" |
[email protected] | 8d8953c | 2012-03-23 23:19:10 | [diff] [blame] | 10 | #include "base/memory/ref_counted.h" |
[email protected] | 82a4e909 | 2012-02-12 18:09:37 | [diff] [blame] | 11 | #include "base/memory/scoped_ptr.h" |
[email protected] | f296be7 | 2011-10-11 15:40:00 | [diff] [blame] | 12 | #include "base/memory/weak_ptr.h" |
[email protected] | 35e9b66a | 2011-10-06 18:19:21 | [diff] [blame] | 13 | #include "base/message_loop.h" |
[email protected] | f94f0f1 | 2011-09-14 21:14:01 | [diff] [blame] | 14 | #include "ui/aura/aura_export.h" |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 15 | #include "ui/aura/focus_manager.h" |
[email protected] | 4aeda579 | 2012-01-26 20:38:42 | [diff] [blame] | 16 | #include "ui/aura/gestures/gesture_recognizer.h" |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 17 | #include "ui/aura/window.h" |
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame^] | 18 | #include "ui/base/cursor/cursor.h" |
[email protected] | 7a05bdc | 2011-10-04 23:38:39 | [diff] [blame] | 19 | #include "ui/base/events.h" |
[email protected] | 905e19a | 2011-09-07 02:17:53 | [diff] [blame] | 20 | #include "ui/gfx/compositor/compositor.h" |
[email protected] | 894e8fc | 2012-02-24 13:29:50 | [diff] [blame] | 21 | #include "ui/gfx/compositor/compositor_observer.h" |
[email protected] | e876c27 | 2011-11-02 16:42:45 | [diff] [blame] | 22 | #include "ui/gfx/compositor/layer_animation_observer.h" |
[email protected] | 81585f3 | 2011-07-29 19:32:06 | [diff] [blame] | 23 | #include "ui/gfx/native_widget_types.h" |
[email protected] | 896728e | 2011-10-14 00:41:26 | [diff] [blame] | 24 | #include "ui/gfx/point.h" |
[email protected] | 81585f3 | 2011-07-29 19:32:06 | [diff] [blame] | 25 | |
| 26 | namespace gfx { |
| 27 | class Size; |
| 28 | } |
| 29 | |
[email protected] | 593ddfa | 2011-10-20 21:51:43 | [diff] [blame] | 30 | namespace ui { |
[email protected] | fe7074c6 | 2011-10-28 15:22:54 | [diff] [blame] | 31 | class LayerAnimationSequence; |
[email protected] | 593ddfa | 2011-10-20 21:51:43 | [diff] [blame] | 32 | class Transform; |
| 33 | } |
| 34 | |
[email protected] | 81585f3 | 2011-07-29 19:32:06 | [diff] [blame] | 35 | namespace aura { |
| 36 | |
[email protected] | 8d8953c | 2012-03-23 23:19:10 | [diff] [blame] | 37 | class RootWindow; |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 38 | class RootWindowHost; |
| 39 | class RootWindowObserver; |
[email protected] | 5951806f | 2011-10-17 16:06:35 | [diff] [blame] | 40 | class KeyEvent; |
[email protected] | a83f0f2 | 2011-08-23 15:39:15 | [diff] [blame] | 41 | class MouseEvent; |
[email protected] | aca200e | 2011-12-15 17:52:02 | [diff] [blame] | 42 | class StackingClient; |
| 43 | class ScrollEvent; |
[email protected] | 5951806f | 2011-10-17 16:06:35 | [diff] [blame] | 44 | class TouchEvent; |
[email protected] | 538f956 | 2012-01-17 17:46:04 | [diff] [blame] | 45 | class GestureEvent; |
[email protected] | b1b15551 | 2011-08-18 22:47:50 | [diff] [blame] | 46 | |
[email protected] | 8d8953c | 2012-03-23 23:19:10 | [diff] [blame] | 47 | // This class represents a lock on the compositor, that can be used to prevent a |
| 48 | // compositing pass from happening while we're waiting for an asynchronous |
| 49 | // event. The typical use case is when waiting for a renderer to produce a frame |
| 50 | // at the right size. The caller keeps a reference on this object, and drops the |
| 51 | // reference once it desires to release the lock. |
| 52 | // Note however that the lock is canceled after a short timeout to ensure |
| 53 | // responsiveness of the UI, so the compositor tree should be kept in a |
| 54 | // "reasonable" state while the lock is held. |
| 55 | // Don't instantiate this class directly, use RootWindow::GetCompositorLock. |
| 56 | class AURA_EXPORT CompositorLock : |
| 57 | public base::RefCounted<CompositorLock>, |
| 58 | public base::SupportsWeakPtr<CompositorLock> { |
| 59 | public: |
| 60 | ~CompositorLock(); |
| 61 | |
| 62 | private: |
| 63 | friend class RootWindow; |
| 64 | |
| 65 | CompositorLock(RootWindow* root_window); |
| 66 | void CancelLock(); |
| 67 | |
| 68 | RootWindow* root_window_; |
| 69 | DISALLOW_COPY_AND_ASSIGN(CompositorLock); |
| 70 | }; |
| 71 | |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 72 | // RootWindow is responsible for hosting a set of windows. |
| 73 | class AURA_EXPORT RootWindow : public ui::CompositorDelegate, |
[email protected] | 894e8fc | 2012-02-24 13:29:50 | [diff] [blame] | 74 | public ui::CompositorObserver, |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 75 | public Window, |
| 76 | public internal::FocusManager, |
| 77 | public ui::LayerAnimationObserver { |
[email protected] | 81585f3 | 2011-07-29 19:32:06 | [diff] [blame] | 78 | public: |
[email protected] | e050ef14 | 2012-03-21 01:04:24 | [diff] [blame] | 79 | explicit RootWindow(const gfx::Rect& initial_bounds); |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 80 | virtual ~RootWindow(); |
[email protected] | 9ed496e | 2011-10-18 23:47:39 | [diff] [blame] | 81 | |
[email protected] | 627a62f | 2012-02-14 22:59:14 | [diff] [blame] | 82 | static void set_hide_host_cursor(bool hide) { |
| 83 | hide_host_cursor_ = hide; |
| 84 | } |
| 85 | static bool hide_host_cursor() { |
| 86 | return hide_host_cursor_; |
| 87 | } |
| 88 | |
[email protected] | 9ed496e | 2011-10-18 23:47:39 | [diff] [blame] | 89 | ui::Compositor* compositor() { return compositor_.get(); } |
[email protected] | 896728e | 2011-10-14 00:41:26 | [diff] [blame] | 90 | gfx::Point last_mouse_location() const { return last_mouse_location_; } |
[email protected] | 912be0e | 2011-11-09 19:05:24 | [diff] [blame] | 91 | gfx::NativeCursor last_cursor() const { return last_cursor_; } |
[email protected] | 627a62f | 2012-02-14 22:59:14 | [diff] [blame] | 92 | bool cursor_shown() const { return cursor_shown_; } |
[email protected] | 9ed496e | 2011-10-18 23:47:39 | [diff] [blame] | 93 | Window* mouse_pressed_handler() { return mouse_pressed_handler_; } |
| 94 | Window* capture_window() { return capture_window_; } |
[email protected] | 09c6943 | 2012-03-16 16:23:28 | [diff] [blame] | 95 | Window* focused_window() { return focused_window_; } |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 96 | |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 97 | // Shows the root window host. |
| 98 | void ShowRootWindow(); |
[email protected] | 970aa36 | 2011-08-30 20:03:34 | [diff] [blame] | 99 | |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 100 | // Sets the size of the root window. |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 101 | void SetHostSize(const gfx::Size& size); |
| 102 | gfx::Size GetHostSize() const; |
[email protected] | 970aa36 | 2011-08-30 20:03:34 | [diff] [blame] | 103 | |
[email protected] | e050ef14 | 2012-03-21 01:04:24 | [diff] [blame] | 104 | // Sets the bounds of the host window. |
| 105 | void SetHostBounds(const gfx::Rect& size); |
| 106 | |
[email protected] | 627a62f | 2012-02-14 22:59:14 | [diff] [blame] | 107 | // Sets the currently-displayed cursor. If the cursor was previously hidden |
| 108 | // via ShowCursor(false), it will remain hidden until ShowCursor(true) is |
| 109 | // called, at which point the cursor that was last set via SetCursor() will be |
| 110 | // used. |
[email protected] | 0207c92d | 2011-10-04 14:45:07 | [diff] [blame] | 111 | void SetCursor(gfx::NativeCursor cursor); |
[email protected] | 70ccf70 | 2011-09-22 18:15:58 | [diff] [blame] | 112 | |
[email protected] | 627a62f | 2012-02-14 22:59:14 | [diff] [blame] | 113 | // Shows or hides the cursor. |
[email protected] | 09a02fff | 2011-12-20 22:01:43 | [diff] [blame] | 114 | void ShowCursor(bool show); |
| 115 | |
[email protected] | 5922cb2 | 2012-01-17 21:53:12 | [diff] [blame] | 116 | // Moves the cursor to the specified location relative to the root window. |
| 117 | void MoveCursorTo(const gfx::Point& location); |
| 118 | |
[email protected] | e424326 | 2012-01-19 18:59:25 | [diff] [blame] | 119 | // Clips the cursor movement to |capture_window_|. Should be invoked only |
| 120 | // after SetCapture(). ReleaseCapture() implicitly removes any confines set |
| 121 | // using this function. Returns true if successful. |
| 122 | bool ConfineCursorToWindow(); |
| 123 | |
[email protected] | 81585f3 | 2011-07-29 19:32:06 | [diff] [blame] | 124 | // Draws the necessary set of windows. |
| 125 | void Draw(); |
| 126 | |
[email protected] | 7df588fbd | 2012-02-10 14:15:56 | [diff] [blame] | 127 | // Draw the whole screen. |
| 128 | void ScheduleFullDraw(); |
| 129 | |
[email protected] | a83f0f2 | 2011-08-23 15:39:15 | [diff] [blame] | 130 | // Handles a mouse event. Returns true if handled. |
[email protected] | 593ddfa | 2011-10-20 21:51:43 | [diff] [blame] | 131 | bool DispatchMouseEvent(MouseEvent* event); |
[email protected] | a83f0f2 | 2011-08-23 15:39:15 | [diff] [blame] | 132 | |
[email protected] | c94f859 | 2011-09-02 20:12:13 | [diff] [blame] | 133 | // Handles a key event. Returns true if handled. |
[email protected] | 593ddfa | 2011-10-20 21:51:43 | [diff] [blame] | 134 | bool DispatchKeyEvent(KeyEvent* event); |
[email protected] | c94f859 | 2011-09-02 20:12:13 | [diff] [blame] | 135 | |
[email protected] | aca200e | 2011-12-15 17:52:02 | [diff] [blame] | 136 | // Handles a scroll event. Returns true if handled. |
| 137 | bool DispatchScrollEvent(ScrollEvent* event); |
| 138 | |
[email protected] | 5951806f | 2011-10-17 16:06:35 | [diff] [blame] | 139 | // Handles a touch event. Returns true if handled. |
[email protected] | 593ddfa | 2011-10-20 21:51:43 | [diff] [blame] | 140 | bool DispatchTouchEvent(TouchEvent* event); |
[email protected] | 5951806f | 2011-10-17 16:06:35 | [diff] [blame] | 141 | |
[email protected] | 538f956 | 2012-01-17 17:46:04 | [diff] [blame] | 142 | // Handles a gesture event. Returns true if handled. Unlike the other |
| 143 | // event-dispatching function (e.g. for touch/mouse/keyboard events), gesture |
| 144 | // events are dispatched from GestureRecognizer instead of RootWindowHost. |
| 145 | bool DispatchGestureEvent(GestureEvent* event); |
| 146 | |
[email protected] | 7a9f891 | 2011-09-12 21:31:31 | [diff] [blame] | 147 | // Called when the host changes size. |
| 148 | void OnHostResized(const gfx::Size& size); |
| 149 | |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 150 | // Invoked when |window| is being destroyed. |
[email protected] | 539a8af | 2012-01-27 20:12:14 | [diff] [blame] | 151 | void OnWindowDestroying(Window* window); |
| 152 | |
[email protected] | c486611 | 2012-03-31 00:36:29 | [diff] [blame] | 153 | // Invoked when |window|'s bounds have changed. |contained_mouse| indicates if |
[email protected] | 539a8af | 2012-01-27 20:12:14 | [diff] [blame] | 154 | // the bounds before change contained the |last_moust_location()|. |
| 155 | void OnWindowBoundsChanged(Window* window, bool contained_mouse); |
| 156 | |
[email protected] | c486611 | 2012-03-31 00:36:29 | [diff] [blame] | 157 | // Invoked when |window|'s visibility is changed. |
[email protected] | 539a8af | 2012-01-27 20:12:14 | [diff] [blame] | 158 | void OnWindowVisibilityChanged(Window* window, bool is_visible); |
| 159 | |
[email protected] | c486611 | 2012-03-31 00:36:29 | [diff] [blame] | 160 | // Invoked when |window|'s tranfrom has changed. |contained_mouse| |
[email protected] | 539a8af | 2012-01-27 20:12:14 | [diff] [blame] | 161 | // indicates if the bounds before change contained the |
| 162 | // |last_moust_location()|. |
| 163 | void OnWindowTransformed(Window* window, bool contained_mouse); |
[email protected] | b8b456ce | 2011-09-27 00:19:13 | [diff] [blame] | 164 | |
[email protected] | c486611 | 2012-03-31 00:36:29 | [diff] [blame] | 165 | // Invoked when the keyboard mapping (in X11 terms: the mapping between |
| 166 | // keycodes and keysyms) has changed. |
| 167 | void OnKeyboardMappingChanged(); |
| 168 | |
[email protected] | 6eb1082 | 2012-03-27 03:34:10 | [diff] [blame] | 169 | // Add/remove observer. There is no need to remove the observer if |
| 170 | // the root window is being deleted. In particular, you SHOULD NOT remove |
| 171 | // in |WindowObserver::OnWindowDestroying| of the observer observing |
| 172 | // the root window because it is too late to remove it. |
[email protected] | 9fc206d | 2011-12-13 00:05:33 | [diff] [blame] | 173 | void AddRootWindowObserver(RootWindowObserver* observer); |
| 174 | void RemoveRootWindowObserver(RootWindowObserver* observer); |
[email protected] | e717ffd | 2011-10-13 17:15:19 | [diff] [blame] | 175 | |
[email protected] | b5a1864 | 2011-11-18 22:45:36 | [diff] [blame] | 176 | // Posts |native_event| to the platform's event queue. |
| 177 | void PostNativeEvent(const base::NativeEvent& native_event); |
| 178 | |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 179 | // Converts |point| from the root window's coordinate system to native |
| 180 | // screen's. |
[email protected] | ace7ca0 | 2011-11-22 21:34:17 | [diff] [blame] | 181 | void ConvertPointToNativeScreen(gfx::Point* point) const; |
| 182 | |
[email protected] | 4def0e69 | 2011-10-19 14:11:09 | [diff] [blame] | 183 | // Capture ------------------------------------------------------------------- |
| 184 | |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 185 | // Sets capture to the specified window. |
| 186 | void SetCapture(Window* window); |
| 187 | |
| 188 | // If |window| has mouse capture, the current capture window is set to NULL. |
| 189 | void ReleaseCapture(Window* window); |
| 190 | |
[email protected] | 4aeda579 | 2012-01-26 20:38:42 | [diff] [blame] | 191 | // Gesture Recognition ------------------------------------------------------- |
| 192 | |
| 193 | // When a touch event is dispatched to a Window, it can notify the RootWindow |
| 194 | // to queue the touch event for asynchronous gesture recognition. These are |
| 195 | // the entry points for the asynchronous processing of the queued touch |
| 196 | // events. |
| 197 | // Process the next touch event for gesture recognition. |processed| indicates |
| 198 | // whether the queued event was processed by the window or not. |
| 199 | void AdvanceQueuedTouchEvent(Window* window, bool processed); |
| 200 | |
| 201 | GestureRecognizer* gesture_recognizer() const { |
| 202 | return gesture_recognizer_.get(); |
| 203 | } |
| 204 | |
| 205 | // Provided only for testing: |
| 206 | void SetGestureRecognizerForTesting(GestureRecognizer* gr); |
| 207 | |
[email protected] | 3ae258d0 | 2012-03-05 23:50:13 | [diff] [blame] | 208 | // Returns the accelerated widget from the RootWindowHost. |
| 209 | gfx::AcceleratedWidget GetAcceleratedWidget(); |
| 210 | |
[email protected] | 745816be | 2011-11-22 05:08:30 | [diff] [blame] | 211 | #if !defined(NDEBUG) |
| 212 | // Toggles the host's full screen state. |
| 213 | void ToggleFullScreen(); |
| 214 | #endif |
| 215 | |
[email protected] | 308aaa3 | 2012-03-12 13:14:50 | [diff] [blame] | 216 | // These methods are used to defer the processing of mouse events related |
| 217 | // to resize. A client (typically a RenderWidgetHostViewAura) can call |
| 218 | // HoldMouseMoves when an resize is initiated and then ReleaseMouseMoves |
| 219 | // once the resize is completed. |
| 220 | // |
| 221 | // More than one hold can be invoked and each hold must be cancelled by a |
| 222 | // release before we resume normal operation. |
| 223 | void HoldMouseMoves(); |
| 224 | void ReleaseMouseMoves(); |
| 225 | |
[email protected] | 8d8953c | 2012-03-23 23:19:10 | [diff] [blame] | 226 | // Creates a compositor lock. |
| 227 | scoped_refptr<CompositorLock> GetCompositorLock(); |
| 228 | |
[email protected] | b635b72 | 2012-03-23 17:15:00 | [diff] [blame] | 229 | // Sets if the window should be focused when shown. |
| 230 | void SetFocusWhenShown(bool focus_when_shown); |
| 231 | |
[email protected] | 54231f7 | 2012-01-31 21:07:26 | [diff] [blame] | 232 | // Overridden from Window: |
| 233 | virtual RootWindow* GetRootWindow() OVERRIDE; |
[email protected] | e050ef14 | 2012-03-21 01:04:24 | [diff] [blame] | 234 | virtual const RootWindow* GetRootWindow() const OVERRIDE; |
[email protected] | 54231f7 | 2012-01-31 21:07:26 | [diff] [blame] | 235 | virtual void SetTransform(const ui::Transform& transform) OVERRIDE; |
| 236 | |
[email protected] | 6e45688 | 2011-12-06 07:42:51 | [diff] [blame] | 237 | // Overridden from ui::CompositorDelegate: |
[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 238 | virtual void ScheduleDraw() OVERRIDE; |
[email protected] | 6e45688 | 2011-12-06 07:42:51 | [diff] [blame] | 239 | |
[email protected] | 894e8fc | 2012-02-24 13:29:50 | [diff] [blame] | 240 | // Overridden from ui::CompositorObserver: |
[email protected] | a8f677c | 2012-03-23 01:36:06 | [diff] [blame] | 241 | virtual void OnCompositingStarted(ui::Compositor*) OVERRIDE; |
[email protected] | 894e8fc | 2012-02-24 13:29:50 | [diff] [blame] | 242 | virtual void OnCompositingEnded(ui::Compositor*) OVERRIDE; |
| 243 | |
[email protected] | 72eb1cf | 2012-01-31 23:31:11 | [diff] [blame] | 244 | private: |
[email protected] | 16690b0 | 2012-02-01 04:06:35 | [diff] [blame] | 245 | friend class Window; |
[email protected] | 8d8953c | 2012-03-23 23:19:10 | [diff] [blame] | 246 | friend class CompositorLock; |
[email protected] | 16690b0 | 2012-02-01 04:06:35 | [diff] [blame] | 247 | |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 248 | // Called whenever the mouse moves, tracks the current |mouse_moved_handler_|, |
| 249 | // sending exited and entered events as its value changes. |
| 250 | void HandleMouseMoved(const MouseEvent& event, Window* target); |
| 251 | |
[email protected] | 759017e0 | 2012-02-11 20:46:11 | [diff] [blame] | 252 | // Called whenever the |capture_window_| changes. |
| 253 | // Sends capture changed events to event filters for old capture window. |
| 254 | void HandleMouseCaptureChanged(Window* old_capture_window); |
| 255 | |
[email protected] | ea2a867a | 2011-10-26 17:41:33 | [diff] [blame] | 256 | bool ProcessMouseEvent(Window* target, MouseEvent* event); |
| 257 | bool ProcessKeyEvent(Window* target, KeyEvent* event); |
| 258 | ui::TouchStatus ProcessTouchEvent(Window* target, TouchEvent* event); |
[email protected] | 538f956 | 2012-01-17 17:46:04 | [diff] [blame] | 259 | ui::GestureStatus ProcessGestureEvent(Window* target, GestureEvent* event); |
[email protected] | 4aeda579 | 2012-01-26 20:38:42 | [diff] [blame] | 260 | bool ProcessGestures(GestureRecognizer::Gestures* gestures); |
[email protected] | ea2a867a | 2011-10-26 17:41:33 | [diff] [blame] | 261 | |
[email protected] | 16690b0 | 2012-02-01 04:06:35 | [diff] [blame] | 262 | // Called when a Window is attached or detached from the RootWindow. |
| 263 | void OnWindowAddedToRootWindow(Window* window); |
| 264 | void OnWindowRemovedFromRootWindow(Window* window); |
| 265 | |
[email protected] | a278e260 | 2012-02-16 16:46:35 | [diff] [blame] | 266 | // Called when a window becomes invisible, either by being removed |
| 267 | // from root window hierachy, via SetVisible(false) or being destroyed. |
| 268 | // |destroyed| is set to true when the window is being destroyed. |
| 269 | void OnWindowHidden(Window* invisible, bool destroyed); |
| 270 | |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 271 | // Overridden from Window: |
| 272 | virtual bool CanFocus() const OVERRIDE; |
[email protected] | 1128681f | 2012-01-13 03:15:40 | [diff] [blame] | 273 | virtual bool CanReceiveEvents() const OVERRIDE; |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 274 | virtual internal::FocusManager* GetFocusManager() OVERRIDE; |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 275 | |
[email protected] | e876c27 | 2011-11-02 16:42:45 | [diff] [blame] | 276 | // Overridden from ui::LayerAnimationObserver: |
[email protected] | fe7074c6 | 2011-10-28 15:22:54 | [diff] [blame] | 277 | virtual void OnLayerAnimationEnded( |
[email protected] | 30676816 | 2012-02-02 02:04:41 | [diff] [blame] | 278 | ui::LayerAnimationSequence* animation) OVERRIDE; |
[email protected] | e876c27 | 2011-11-02 16:42:45 | [diff] [blame] | 279 | virtual void OnLayerAnimationScheduled( |
[email protected] | 30676816 | 2012-02-02 02:04:41 | [diff] [blame] | 280 | ui::LayerAnimationSequence* animation) OVERRIDE; |
[email protected] | e876c27 | 2011-11-02 16:42:45 | [diff] [blame] | 281 | virtual void OnLayerAnimationAborted( |
[email protected] | 30676816 | 2012-02-02 02:04:41 | [diff] [blame] | 282 | ui::LayerAnimationSequence* animation) OVERRIDE; |
[email protected] | 326828b | 2011-10-21 02:01:10 | [diff] [blame] | 283 | |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 284 | // Overridden from FocusManager: |
[email protected] | 09c6943 | 2012-03-16 16:23:28 | [diff] [blame] | 285 | virtual void SetFocusedWindow(Window* window, |
| 286 | const aura::Event* event) OVERRIDE; |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 287 | virtual Window* GetFocusedWindow() OVERRIDE; |
| 288 | virtual bool IsFocusedWindow(const Window* window) const OVERRIDE; |
| 289 | |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 290 | // Initializes the root window. |
[email protected] | 9ed496e | 2011-10-18 23:47:39 | [diff] [blame] | 291 | void Init(); |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 292 | |
[email protected] | 8bbbb40d | 2012-03-23 01:49:23 | [diff] [blame] | 293 | // We hold and aggregate mouse drags as a way of throttling resizes when |
| 294 | // HoldMouseMoves() is called. The following methods are used to dispatch held |
| 295 | // and newly incoming mouse events, typically when an event other than a mouse |
| 296 | // drag needs dispatching or a matching ReleaseMouseMoves() is called. |
[email protected] | 308aaa3 | 2012-03-12 13:14:50 | [diff] [blame] | 297 | bool DispatchMouseEventImpl(MouseEvent* event); |
| 298 | void DispatchHeldMouseMove(); |
| 299 | |
[email protected] | 4a14bca9 | 2011-10-21 00:09:22 | [diff] [blame] | 300 | // Parses the switch describing the initial size for the host window and |
| 301 | // returns bounds for the window. |
| 302 | gfx::Rect GetInitialHostWindowBounds() const; |
| 303 | |
[email protected] | 539a8af | 2012-01-27 20:12:14 | [diff] [blame] | 304 | // Posts a task to send synthesized mouse move event if there |
| 305 | // is no a pending task. |
| 306 | void PostMouseMoveEventAfterWindowChange(); |
| 307 | |
| 308 | // Creates and dispatches synthesized mouse move event using the |
| 309 | // current mouse location. |
| 310 | void SynthesizeMouseMoveEvent(); |
| 311 | |
[email protected] | 8d8953c | 2012-03-23 23:19:10 | [diff] [blame] | 312 | // Called by CompositorLock. |
| 313 | void UnlockCompositor(); |
| 314 | |
[email protected] | 82a4e909 | 2012-02-12 18:09:37 | [diff] [blame] | 315 | scoped_ptr<ui::Compositor> compositor_; |
[email protected] | 81585f3 | 2011-07-29 19:32:06 | [diff] [blame] | 316 | |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 317 | scoped_ptr<RootWindowHost> host_; |
[email protected] | 8d8c773 | 2011-08-25 22:35:13 | [diff] [blame] | 318 | |
[email protected] | 627a62f | 2012-02-14 22:59:14 | [diff] [blame] | 319 | // If set before the RootWindow is created, the cursor will be drawn within |
| 320 | // the Aura root window but hidden outside of it, and it'll remain hidden |
| 321 | // after the Aura window is closed. |
| 322 | static bool hide_host_cursor_; |
| 323 | |
[email protected] | 5978af5e | 2011-10-24 22:17:18 | [diff] [blame] | 324 | // Used to schedule painting. |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 325 | base::WeakPtrFactory<RootWindow> schedule_paint_factory_; |
[email protected] | 5978af5e | 2011-10-24 22:17:18 | [diff] [blame] | 326 | |
[email protected] | 539a8af | 2012-01-27 20:12:14 | [diff] [blame] | 327 | // Use to post mouse move event. |
| 328 | base::WeakPtrFactory<RootWindow> event_factory_; |
| 329 | |
[email protected] | 896728e | 2011-10-14 00:41:26 | [diff] [blame] | 330 | // Last location seen in a mouse event. |
| 331 | gfx::Point last_mouse_location_; |
| 332 | |
[email protected] | bf74dd8 | 2011-11-11 21:36:41 | [diff] [blame] | 333 | // ui::EventFlags containing the current state of the mouse buttons. |
| 334 | int mouse_button_flags_; |
| 335 | |
[email protected] | 912be0e | 2011-11-09 19:05:24 | [diff] [blame] | 336 | // Last cursor set. Used for testing. |
| 337 | gfx::NativeCursor last_cursor_; |
| 338 | |
[email protected] | 627a62f | 2012-02-14 22:59:14 | [diff] [blame] | 339 | // Is the cursor currently shown? Used for testing. |
| 340 | bool cursor_shown_; |
| 341 | |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 342 | ObserverList<RootWindowObserver> observers_; |
[email protected] | e717ffd | 2011-10-13 17:15:19 | [diff] [blame] | 343 | |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 344 | // The capture window. When not-null, this window receives all the mouse and |
| 345 | // touch events. |
| 346 | Window* capture_window_; |
| 347 | |
| 348 | Window* mouse_pressed_handler_; |
| 349 | Window* mouse_moved_handler_; |
| 350 | Window* focused_window_; |
[email protected] | 912b6f3 | 2012-01-19 00:48:01 | [diff] [blame] | 351 | |
| 352 | // The gesture_recognizer_ for this. |
[email protected] | b945735 | 2012-01-19 16:31:06 | [diff] [blame] | 353 | scoped_ptr<GestureRecognizer> gesture_recognizer_; |
[email protected] | 114bfbd | 2011-10-18 21:20:24 | [diff] [blame] | 354 | |
[email protected] | 539a8af | 2012-01-27 20:12:14 | [diff] [blame] | 355 | bool synthesize_mouse_move_; |
[email protected] | 894e8fc | 2012-02-24 13:29:50 | [diff] [blame] | 356 | bool waiting_on_compositing_end_; |
| 357 | bool draw_on_compositing_end_; |
[email protected] | 539a8af | 2012-01-27 20:12:14 | [diff] [blame] | 358 | |
[email protected] | 308aaa3 | 2012-03-12 13:14:50 | [diff] [blame] | 359 | bool defer_draw_scheduling_; |
| 360 | |
| 361 | // How many holds are outstanding. We try to defer dispatching mouse moves |
| 362 | // while the count is > 0. |
| 363 | int mouse_move_hold_count_; |
| 364 | bool should_hold_mouse_moves_; |
[email protected] | 308aaa3 | 2012-03-12 13:14:50 | [diff] [blame] | 365 | scoped_ptr<MouseEvent> held_mouse_move_; |
| 366 | |
[email protected] | 8d8953c | 2012-03-23 23:19:10 | [diff] [blame] | 367 | CompositorLock* compositor_lock_; |
| 368 | bool draw_on_compositor_unlock_; |
| 369 | |
[email protected] | d679488 | 2012-03-29 03:19:58 | [diff] [blame] | 370 | int draw_trace_count_; |
| 371 | |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 372 | DISALLOW_COPY_AND_ASSIGN(RootWindow); |
[email protected] | 81585f3 | 2011-07-29 19:32:06 | [diff] [blame] | 373 | }; |
| 374 | |
| 375 | } // namespace aura |
| 376 | |
[email protected] | 99f07e0 | 2011-12-07 00:02:59 | [diff] [blame] | 377 | #endif // UI_AURA_ROOT_WINDOW_H_ |