Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(803)

Side by Side Diff: ui/aura/root_window.h

Issue 10825050: Introduce RootWindowHostDelegate. The RootWindowHost performs most of its communication with RootWi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/gestures/gesture_recognizer_unittest.cc ('k') | ui/aura/root_window.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "ui/aura/aura_export.h" 15 #include "ui/aura/aura_export.h"
16 #include "ui/aura/client/capture_delegate.h" 16 #include "ui/aura/client/capture_delegate.h"
17 #include "ui/aura/root_window_host_delegate.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/base/cursor/cursor.h" 19 #include "ui/base/cursor/cursor.h"
19 #include "ui/base/events.h" 20 #include "ui/base/events.h"
20 #include "ui/base/gestures/gesture_recognizer.h" 21 #include "ui/base/gestures/gesture_recognizer.h"
21 #include "ui/base/gestures/gesture_types.h" 22 #include "ui/base/gestures/gesture_types.h"
22 #include "ui/compositor/compositor.h" 23 #include "ui/compositor/compositor.h"
23 #include "ui/compositor/compositor_observer.h" 24 #include "ui/compositor/compositor_observer.h"
24 #include "ui/compositor/layer_animation_observer.h" 25 #include "ui/compositor/layer_animation_observer.h"
25 #include "ui/gfx/native_widget_types.h" 26 #include "ui/gfx/native_widget_types.h"
26 #include "ui/gfx/point.h" 27 #include "ui/gfx/point.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 RootWindow* root_window_; 72 RootWindow* root_window_;
72 DISALLOW_COPY_AND_ASSIGN(CompositorLock); 73 DISALLOW_COPY_AND_ASSIGN(CompositorLock);
73 }; 74 };
74 75
75 // RootWindow is responsible for hosting a set of windows. 76 // RootWindow is responsible for hosting a set of windows.
76 class AURA_EXPORT RootWindow : public ui::CompositorDelegate, 77 class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
77 public ui::CompositorObserver, 78 public ui::CompositorObserver,
78 public Window, 79 public Window,
79 public ui::GestureEventHelper, 80 public ui::GestureEventHelper,
80 public ui::LayerAnimationObserver, 81 public ui::LayerAnimationObserver,
81 public aura::client::CaptureDelegate { 82 public aura::client::CaptureDelegate,
83 public aura::RootWindowHostDelegate {
82 public: 84 public:
83 explicit RootWindow(const gfx::Rect& initial_bounds); 85 explicit RootWindow(const gfx::Rect& initial_bounds);
84 virtual ~RootWindow(); 86 virtual ~RootWindow();
85 87
86 static RootWindow* GetForAcceleratedWidget(gfx::AcceleratedWidget widget); 88 static RootWindow* GetForAcceleratedWidget(gfx::AcceleratedWidget widget);
87 89
88 static void set_hide_host_cursor(bool hide) { 90 static void set_hide_host_cursor(bool hide) {
89 hide_host_cursor_ = hide; 91 hide_host_cursor_ = hide;
90 } 92 }
91 static bool hide_host_cursor() { 93 static bool hide_host_cursor() {
92 return hide_host_cursor_; 94 return hide_host_cursor_;
93 } 95 }
94 96
95 ui::Compositor* compositor() { return compositor_.get(); } 97 ui::Compositor* compositor() { return compositor_.get(); }
96 gfx::NativeCursor last_cursor() const { return last_cursor_; } 98 gfx::NativeCursor last_cursor() const { return last_cursor_; }
97 Window* mouse_pressed_handler() { return mouse_pressed_handler_; } 99 Window* mouse_pressed_handler() { return mouse_pressed_handler_; }
98 bool cursor_shown() const { return cursor_shown_; } 100 bool cursor_shown() const { return cursor_shown_; }
99 101
100 void set_focus_manager(FocusManager* focus_manager) { 102 void set_focus_manager(FocusManager* focus_manager) {
101 focus_manager_ = focus_manager; 103 focus_manager_ = focus_manager;
102 } 104 }
103 105
104 // Initializes the root window. 106 // Initializes the root window.
105 void Init(); 107 void Init();
106 108
107 // Shows the root window host. 109 // Shows the root window host.
108 void ShowRootWindow(); 110 void ShowRootWindow();
109 111
112 RootWindowHostDelegate* AsRootWindowHostDelegate();
113
110 // Sets the size of the root window. 114 // Sets the size of the root window.
111 void SetHostSize(const gfx::Size& size_in_pixel); 115 void SetHostSize(const gfx::Size& size_in_pixel);
112 gfx::Size GetHostSize() const; 116 gfx::Size GetHostSize() const;
113 117
114 // Sets the bounds of the host window. 118 // Sets the bounds of the host window.
115 void SetHostBounds(const gfx::Rect& size_in_pixel); 119 void SetHostBounds(const gfx::Rect& size_in_pixel);
116 120
117 // Returns where the RootWindow is on screen. 121 // Returns where the RootWindow is on screen.
118 gfx::Point GetHostOrigin() const; 122 gfx::Point GetHostOrigin() const;
119 123
(...skipping 11 matching lines...) Expand all
131 135
132 // Clips the cursor movement to the root_window. 136 // Clips the cursor movement to the root_window.
133 bool ConfineCursorToWindow(); 137 bool ConfineCursorToWindow();
134 138
135 // Draws the necessary set of windows. 139 // Draws the necessary set of windows.
136 void Draw(); 140 void Draw();
137 141
138 // Draw the whole screen. 142 // Draw the whole screen.
139 void ScheduleFullDraw(); 143 void ScheduleFullDraw();
140 144
141 // Handles a mouse event. Returns true if handled.
142 bool DispatchMouseEvent(MouseEvent* event);
143
144 // Handles a key event. Returns true if handled.
145 bool DispatchKeyEvent(KeyEvent* event);
146
147 // Handles a scroll event. Returns true if handled.
148 bool DispatchScrollEvent(ScrollEvent* event);
149
150 // Handles a touch event. Returns true if handled.
151 bool DispatchTouchEvent(TouchEvent* event);
152
153 // Handles a gesture event. Returns true if handled. Unlike the other 145 // Handles a gesture event. Returns true if handled. Unlike the other
154 // event-dispatching function (e.g. for touch/mouse/keyboard events), gesture 146 // event-dispatching function (e.g. for touch/mouse/keyboard events), gesture
155 // events are dispatched from GestureRecognizer instead of RootWindowHost. 147 // events are dispatched from GestureRecognizer instead of RootWindowHost.
156 bool DispatchGestureEvent(GestureEvent* event); 148 bool DispatchGestureEvent(GestureEvent* event);
157 149
158 // Called when the host changes size.
159 void OnHostResized(const gfx::Size& size_in_pixel);
160
161 // Invoked when |window| is being destroyed. 150 // Invoked when |window| is being destroyed.
162 void OnWindowDestroying(Window* window); 151 void OnWindowDestroying(Window* window);
163 152
164 // Invoked when |window|'s bounds have changed. |contained_mouse| indicates if 153 // Invoked when |window|'s bounds have changed. |contained_mouse| indicates if
165 // the bounds before change contained the |last_moust_location()|. 154 // the bounds before change contained the |last_moust_location()|.
166 void OnWindowBoundsChanged(Window* window, bool contained_mouse); 155 void OnWindowBoundsChanged(Window* window, bool contained_mouse);
167 156
168 // Invoked when |window|'s visibility is changed. 157 // Invoked when |window|'s visibility is changed.
169 void OnWindowVisibilityChanged(Window* window, bool is_visible); 158 void OnWindowVisibilityChanged(Window* window, bool is_visible);
170 159
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 virtual bool DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE; 302 virtual bool DispatchCancelTouchEvent(ui::TouchEvent* event) OVERRIDE;
314 303
315 // Overridden from ui::LayerAnimationObserver: 304 // Overridden from ui::LayerAnimationObserver:
316 virtual void OnLayerAnimationEnded( 305 virtual void OnLayerAnimationEnded(
317 ui::LayerAnimationSequence* animation) OVERRIDE; 306 ui::LayerAnimationSequence* animation) OVERRIDE;
318 virtual void OnLayerAnimationScheduled( 307 virtual void OnLayerAnimationScheduled(
319 ui::LayerAnimationSequence* animation) OVERRIDE; 308 ui::LayerAnimationSequence* animation) OVERRIDE;
320 virtual void OnLayerAnimationAborted( 309 virtual void OnLayerAnimationAborted(
321 ui::LayerAnimationSequence* animation) OVERRIDE; 310 ui::LayerAnimationSequence* animation) OVERRIDE;
322 311
312 // Overridden from aura::RootWindowHostDelegate:
313 virtual bool OnHostKeyEvent(KeyEvent* event) OVERRIDE;
314 virtual bool OnHostMouseEvent(MouseEvent* event) OVERRIDE;
315 virtual bool OnHostScrollEvent(ScrollEvent* event) OVERRIDE;
316 virtual bool OnHostTouchEvent(TouchEvent* event) OVERRIDE;
317 virtual void OnHostLostCapture() OVERRIDE;
318 virtual void OnHostPaint() OVERRIDE;
319 virtual void OnHostResized(const gfx::Size& size) OVERRIDE;
320 virtual float GetDeviceScaleFactor() OVERRIDE;
321 virtual RootWindow* AsRootWindow() OVERRIDE;
322
323 // We hold and aggregate mouse drags as a way of throttling resizes when 323 // 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 324 // 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 325 // and newly incoming mouse events, typically when an event other than a mouse
326 // drag needs dispatching or a matching ReleaseMouseMoves() is called. 326 // drag needs dispatching or a matching ReleaseMouseMoves() is called.
327 // NOTE: because these methods dispatch events from RootWindowHost the 327 // NOTE: because these methods dispatch events from RootWindowHost the
328 // coordinates are in terms of the root. 328 // coordinates are in terms of the root.
329 bool DispatchMouseEventImpl(MouseEvent* event); 329 bool DispatchMouseEventImpl(MouseEvent* event);
330 bool DispatchMouseEventToTarget(MouseEvent* event, Window* target); 330 bool DispatchMouseEventToTarget(MouseEvent* event, Window* target);
331 void DispatchHeldMouseMove(); 331 void DispatchHeldMouseMove();
332 332
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 397
398 CompositorLock* compositor_lock_; 398 CompositorLock* compositor_lock_;
399 bool draw_on_compositor_unlock_; 399 bool draw_on_compositor_unlock_;
400 400
401 DISALLOW_COPY_AND_ASSIGN(RootWindow); 401 DISALLOW_COPY_AND_ASSIGN(RootWindow);
402 }; 402 };
403 403
404 } // namespace aura 404 } // namespace aura
405 405
406 #endif // UI_AURA_ROOT_WINDOW_H_ 406 #endif // UI_AURA_ROOT_WINDOW_H_
OLDNEW
« no previous file with comments | « ui/aura/gestures/gesture_recognizer_unittest.cc ('k') | ui/aura/root_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698