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

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

Issue 72503002: Remove some pass-thrus on RootWindow API in favor of exposing the RootWindowHost again. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month 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/remote_root_window_host_win.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/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_delegate.h" 19 #include "ui/aura/window_tree_host_delegate.h"
19 #include "ui/base/cursor/cursor.h" 20 #include "ui/base/cursor/cursor.h"
20 #include "ui/compositor/compositor.h" 21 #include "ui/compositor/compositor.h"
21 #include "ui/compositor/layer_animation_observer.h" 22 #include "ui/compositor/layer_animation_observer.h"
22 #include "ui/events/event_constants.h" 23 #include "ui/events/event_constants.h"
23 #include "ui/events/event_dispatcher.h" 24 #include "ui/events/event_dispatcher.h"
24 #include "ui/events/gestures/gesture_recognizer.h" 25 #include "ui/events/gestures/gesture_recognizer.h"
25 #include "ui/events/gestures/gesture_types.h" 26 #include "ui/events/gestures/gesture_types.h"
26 #include "ui/gfx/native_widget_types.h" 27 #include "ui/gfx/native_widget_types.h"
27 #include "ui/gfx/point.h" 28 #include "ui/gfx/point.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 virtual ~RootWindow(); 74 virtual ~RootWindow();
74 75
75 // Returns the RootWindowHost for the specified accelerated widget, or NULL 76 // Returns the RootWindowHost for the specified accelerated widget, or NULL
76 // if there is none associated. 77 // if there is none associated.
77 static RootWindow* GetForAcceleratedWidget(gfx::AcceleratedWidget widget); 78 static RootWindow* GetForAcceleratedWidget(gfx::AcceleratedWidget widget);
78 79
79 Window* window() { 80 Window* window() {
80 return const_cast<Window*>(const_cast<const RootWindow*>(this)->window()); 81 return const_cast<Window*>(const_cast<const RootWindow*>(this)->window());
81 } 82 }
82 const Window* window() const { return window_.get(); } 83 const Window* window() const { return window_.get(); }
84 RootWindowHost* host() {
85 return const_cast<RootWindowHost*>(
86 const_cast<const RootWindow*>(this)->host());
87 }
88 const RootWindowHost* host() const { return host_.get(); }
83 ui::Compositor* compositor() { return compositor_.get(); } 89 ui::Compositor* compositor() { return compositor_.get(); }
84 gfx::NativeCursor last_cursor() const { return last_cursor_; } 90 gfx::NativeCursor last_cursor() const { return last_cursor_; }
85 Window* mouse_pressed_handler() { return mouse_pressed_handler_; } 91 Window* mouse_pressed_handler() { return mouse_pressed_handler_; }
86 Window* mouse_moved_handler() { return mouse_moved_handler_; } 92 Window* mouse_moved_handler() { return mouse_moved_handler_; }
87 93
88 // Initializes the root window. 94 // Initializes the root window.
89 void Init(); 95 void Init();
90 96
91 // Shows the root window host.
92 void ShowRootWindow();
93
94 // Hides the root window host.
95 void HideRootWindow();
96
97 // Stop listening events in preparation for shutdown. 97 // Stop listening events in preparation for shutdown.
98 void PrepareForShutdown(); 98 void PrepareForShutdown();
99 99
100 // Repost event for re-processing. Used when exiting context menus. 100 // Repost event for re-processing. Used when exiting context menus.
101 // We only support the ET_MOUSE_PRESSED and ET_GESTURE_TAP_DOWN event 101 // We only support the ET_MOUSE_PRESSED and ET_GESTURE_TAP_DOWN event
102 // types (although the latter is currently a no-op). 102 // types (although the latter is currently a no-op).
103 void RepostEvent(const ui::LocatedEvent& event); 103 void RepostEvent(const ui::LocatedEvent& event);
104 104
105 RootWindowHostDelegate* AsRootWindowHostDelegate(); 105 RootWindowHostDelegate* AsRootWindowHostDelegate();
106 106
107 // Gets/sets the size of the host window. 107 // Gets/sets the size of the host window.
108 void SetHostSize(const gfx::Size& size_in_pixel); 108 void SetHostSize(const gfx::Size& size_in_pixel);
109 gfx::Size GetHostSize() const;
110 109
111 // Sets the bounds of the host window. 110 // Sets the bounds of the host window.
112 void SetHostBounds(const gfx::Rect& size_in_pizel); 111 void SetHostBounds(const gfx::Rect& size_in_pizel);
113 112
114 // Returns where the RootWindow is on screen.
115 gfx::Point GetHostOrigin() const;
116
117 // Sets the currently-displayed cursor. If the cursor was previously hidden 113 // Sets the currently-displayed cursor. If the cursor was previously hidden
118 // via ShowCursor(false), it will remain hidden until ShowCursor(true) is 114 // via ShowCursor(false), it will remain hidden until ShowCursor(true) is
119 // called, at which point the cursor that was last set via SetCursor() will be 115 // called, at which point the cursor that was last set via SetCursor() will be
120 // used. 116 // used.
121 void SetCursor(gfx::NativeCursor cursor); 117 void SetCursor(gfx::NativeCursor cursor);
122 118
123 // Invoked when the cursor's visibility has changed. 119 // Invoked when the cursor's visibility has changed.
124 void OnCursorVisibilityChanged(bool visible); 120 void OnCursorVisibilityChanged(bool visible);
125 121
126 // Invoked when the mouse events get enabled or disabled. 122 // Invoked when the mouse events get enabled or disabled.
127 void OnMouseEventsEnableStateChanged(bool enabled); 123 void OnMouseEventsEnableStateChanged(bool enabled);
128 124
129 // Moves the cursor to the specified location relative to the root window. 125 // Moves the cursor to the specified location relative to the root window.
130 void MoveCursorTo(const gfx::Point& location); 126 void MoveCursorTo(const gfx::Point& location);
131 127
132 // Moves the cursor to the |host_location| given in host coordinates. 128 // Moves the cursor to the |host_location| given in host coordinates.
133 void MoveCursorToHostLocation(const gfx::Point& host_location); 129 void MoveCursorToHostLocation(const gfx::Point& host_location);
134 130
135 // Clips the cursor movement to the root_window.
136 bool ConfineCursorToWindow();
137
138 // Restores the cursor movement beyond the root window.
139 void UnConfineCursor();
140
141 // Draw the damage_rect. 131 // Draw the damage_rect.
142 void ScheduleRedrawRect(const gfx::Rect& damage_rect); 132 void ScheduleRedrawRect(const gfx::Rect& damage_rect);
143 133
144 // Returns a target window for the given gesture event. 134 // Returns a target window for the given gesture event.
145 Window* GetGestureTarget(ui::GestureEvent* event); 135 Window* GetGestureTarget(ui::GestureEvent* event);
146 136
147 // Handles a gesture event. Returns true if handled. Unlike the other 137 // Handles a gesture event. Returns true if handled. Unlike the other
148 // event-dispatching function (e.g. for touch/mouse/keyboard events), gesture 138 // event-dispatching function (e.g. for touch/mouse/keyboard events), gesture
149 // events are dispatched from GestureRecognizer instead of RootWindowHost. 139 // events are dispatched from GestureRecognizer instead of RootWindowHost.
150 void DispatchGestureEvent(ui::GestureEvent* event); 140 void DispatchGestureEvent(ui::GestureEvent* event);
(...skipping 26 matching lines...) Expand all
177 // The system windowing system has sent a request that we close our window. 167 // The system windowing system has sent a request that we close our window.
178 void OnRootWindowHostCloseRequested(); 168 void OnRootWindowHostCloseRequested();
179 169
180 // Add/remove observer. There is no need to remove the observer if 170 // Add/remove observer. There is no need to remove the observer if
181 // the root window is being deleted. In particular, you SHOULD NOT remove 171 // the root window is being deleted. In particular, you SHOULD NOT remove
182 // in |WindowObserver::OnWindowDestroying| of the observer observing 172 // in |WindowObserver::OnWindowDestroying| of the observer observing
183 // the root window because it is too late to remove it. 173 // the root window because it is too late to remove it.
184 void AddRootWindowObserver(RootWindowObserver* observer); 174 void AddRootWindowObserver(RootWindowObserver* observer);
185 void RemoveRootWindowObserver(RootWindowObserver* observer); 175 void RemoveRootWindowObserver(RootWindowObserver* observer);
186 176
187 // Posts |native_event| to the platform's event queue.
188 void PostNativeEvent(const base::NativeEvent& native_event);
189
190 // Converts |point| from the root window's coordinate system to native
191 // screen's.
192 void ConvertPointToNativeScreen(gfx::Point* point) const;
193
194 // Converts |point| from native screen coordinate system to the root window's.
195 void ConvertPointFromNativeScreen(gfx::Point* point) const;
196
197 // Converts |point| from the root window's coordinate system to the 177 // Converts |point| from the root window's coordinate system to the
198 // host window's. 178 // host window's.
199 void ConvertPointToHost(gfx::Point* point) const; 179 void ConvertPointToHost(gfx::Point* point) const;
200 180
201 // Converts |point| from the host window's coordinate system to the 181 // Converts |point| from the host window's coordinate system to the
202 // root window's. 182 // root window's.
203 void ConvertPointFromHost(gfx::Point* point) const; 183 void ConvertPointFromHost(gfx::Point* point) const;
204 184
205 // Gesture Recognition ------------------------------------------------------- 185 // Gesture Recognition -------------------------------------------------------
206 186
207 // When a touch event is dispatched to a Window, it may want to process the 187 // When a touch event is dispatched to a Window, it may want to process the
208 // touch event asynchronously. In such cases, the window should consume the 188 // touch event asynchronously. In such cases, the window should consume the
209 // event during the event dispatch. Once the event is properly processed, the 189 // event during the event dispatch. Once the event is properly processed, the
210 // window should let the RootWindow know about the result of the event 190 // window should let the RootWindow know about the result of the event
211 // processing, so that gesture events can be properly created and dispatched. 191 // processing, so that gesture events can be properly created and dispatched.
212 void ProcessedTouchEvent(ui::TouchEvent* event, 192 void ProcessedTouchEvent(ui::TouchEvent* event,
213 Window* window, 193 Window* window,
214 ui::EventResult result); 194 ui::EventResult result);
215 195
216 // Returns the accelerated widget from the RootWindowHost.
217 gfx::AcceleratedWidget GetAcceleratedWidget();
218
219 // Toggles the host's full screen state.
220 void ToggleFullScreen();
221
222 // These methods are used to defer the processing of mouse/touch events 196 // These methods are used to defer the processing of mouse/touch events
223 // related to resize. A client (typically a RenderWidgetHostViewAura) can call 197 // related to resize. A client (typically a RenderWidgetHostViewAura) can call
224 // HoldPointerMoves when an resize is initiated and then ReleasePointerMoves 198 // HoldPointerMoves when an resize is initiated and then ReleasePointerMoves
225 // once the resize is completed. 199 // once the resize is completed.
226 // 200 //
227 // More than one hold can be invoked and each hold must be cancelled by a 201 // More than one hold can be invoked and each hold must be cancelled by a
228 // release before we resume normal operation. 202 // release before we resume normal operation.
229 void HoldPointerMoves(); 203 void HoldPointerMoves();
230 void ReleasePointerMoves(); 204 void ReleasePointerMoves();
231 205
232 // Sets if the window should be focused when shown.
233 void SetFocusWhenShown(bool focus_when_shown);
234
235 // Gets the last location seen in a mouse event in this root window's 206 // Gets the last location seen in a mouse event in this root window's
236 // coordinates. This may return a point outside the root window's bounds. 207 // coordinates. This may return a point outside the root window's bounds.
237 gfx::Point GetLastMouseLocationInRoot() const; 208 gfx::Point GetLastMouseLocationInRoot() const;
238 209
239 // Exposes RootWindowHost::QueryMouseLocation() for test purposes.
240 bool QueryMouseLocationForTest(gfx::Point* point) const;
241
242 void SetRootWindowTransformer(scoped_ptr<RootWindowTransformer> transformer); 210 void SetRootWindowTransformer(scoped_ptr<RootWindowTransformer> transformer);
243 gfx::Transform GetRootTransform() const; 211 gfx::Transform GetRootTransform() const;
244 212
245 void SetTransform(const gfx::Transform& transform); 213 void SetTransform(const gfx::Transform& transform);
246 214
247 void DeviceScaleFactorChanged(float device_scale_factor);
248
249 private: 215 private:
250 FRIEND_TEST_ALL_PREFIXES(RootWindowTest, KeepTranslatedEventInRoot); 216 FRIEND_TEST_ALL_PREFIXES(RootWindowTest, KeepTranslatedEventInRoot);
251 217
252 friend class Window; 218 friend class Window;
253 friend class TestScreen; 219 friend class TestScreen;
254 220
255 // The parameter for OnWindowHidden() to specify why window is hidden. 221 // The parameter for OnWindowHidden() to specify why window is hidden.
256 enum WindowHiddenReason { 222 enum WindowHiddenReason {
257 WINDOW_DESTROYED, // Window is destroyed. 223 WINDOW_DESTROYED, // Window is destroyed.
258 WINDOW_HIDDEN, // Window is hidden. 224 WINDOW_HIDDEN, // Window is hidden.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 virtual bool OnHostTouchEvent(ui::TouchEvent* event) OVERRIDE; 294 virtual bool OnHostTouchEvent(ui::TouchEvent* event) OVERRIDE;
329 virtual void OnHostCancelMode() OVERRIDE; 295 virtual void OnHostCancelMode() OVERRIDE;
330 virtual void OnHostActivated() OVERRIDE; 296 virtual void OnHostActivated() OVERRIDE;
331 virtual void OnHostLostWindowCapture() OVERRIDE; 297 virtual void OnHostLostWindowCapture() OVERRIDE;
332 virtual void OnHostLostMouseGrab() OVERRIDE; 298 virtual void OnHostLostMouseGrab() OVERRIDE;
333 virtual void OnHostPaint(const gfx::Rect& damage_rect) OVERRIDE; 299 virtual void OnHostPaint(const gfx::Rect& damage_rect) OVERRIDE;
334 virtual void OnHostMoved(const gfx::Point& origin) OVERRIDE; 300 virtual void OnHostMoved(const gfx::Point& origin) OVERRIDE;
335 virtual void OnHostResized(const gfx::Size& size) OVERRIDE; 301 virtual void OnHostResized(const gfx::Size& size) OVERRIDE;
336 virtual float GetDeviceScaleFactor() OVERRIDE; 302 virtual float GetDeviceScaleFactor() OVERRIDE;
337 virtual RootWindow* AsRootWindow() OVERRIDE; 303 virtual RootWindow* AsRootWindow() OVERRIDE;
304 virtual const RootWindow* AsRootWindow() const OVERRIDE;
338 305
339 ui::EventDispatchDetails OnHostMouseEventImpl(ui::MouseEvent* event) 306 ui::EventDispatchDetails OnHostMouseEventImpl(ui::MouseEvent* event)
340 WARN_UNUSED_RESULT; 307 WARN_UNUSED_RESULT;
341 308
342 // We hold and aggregate mouse drags and touch moves as a way of throttling 309 // We hold and aggregate mouse drags and touch moves as a way of throttling
343 // resizes when HoldMouseMoves() is called. The following methods are used to 310 // resizes when HoldMouseMoves() is called. The following methods are used to
344 // dispatch held and newly incoming mouse and touch events, typically when an 311 // dispatch held and newly incoming mouse and touch events, typically when an
345 // event other than one of these needs dispatching or a matching 312 // event other than one of these needs dispatching or a matching
346 // ReleaseMouseMoves()/ReleaseTouchMoves() is called. NOTE: because these 313 // ReleaseMouseMoves()/ReleaseTouchMoves() is called. NOTE: because these
347 // methods dispatch events from RootWindowHost the coordinates are in terms of 314 // methods dispatch events from RootWindowHost the coordinates are in terms of
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 378
412 // Used to schedule DispatchHeldEvents() when |move_hold_count_| goes to 0. 379 // Used to schedule DispatchHeldEvents() when |move_hold_count_| goes to 0.
413 base::WeakPtrFactory<RootWindow> held_event_factory_; 380 base::WeakPtrFactory<RootWindow> held_event_factory_;
414 381
415 DISALLOW_COPY_AND_ASSIGN(RootWindow); 382 DISALLOW_COPY_AND_ASSIGN(RootWindow);
416 }; 383 };
417 384
418 } // namespace aura 385 } // namespace aura
419 386
420 #endif // UI_AURA_ROOT_WINDOW_H_ 387 #endif // UI_AURA_ROOT_WINDOW_H_
OLDNEW
« no previous file with comments | « ui/aura/remote_root_window_host_win.cc ('k') | ui/aura/root_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698